From: Tim Northover Date: Wed, 19 Jul 2017 22:08:08 +0000 (+0000) Subject: GlobalISel: fix SUBREG_TO_REG implementation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e81b44f152a897f07df39cc1259fa1aea4944181;p=llvm GlobalISel: fix SUBREG_TO_REG implementation. The first argument needs to be an immediate rather than a register. Should fix some crashes in the verifier bot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308540 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AArch64/AArch64InstructionSelector.cpp b/lib/Target/AArch64/AArch64InstructionSelector.cpp index 0c9c1b35440..148e973bb1c 100644 --- a/lib/Target/AArch64/AArch64InstructionSelector.cpp +++ b/lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -780,6 +780,29 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const { return constrainSelectedInstRegOperands(I, TII, TRI, RBI); } + case TargetOpcode::G_UNMERGE_VALUES: { + // + LLT SrcTy = MRI.getType(I.getOperand(1).getReg()); + // Larger extracts are vectors, same-size extracts should be something else + // by now (either split up or simplified to a COPY). + if (SrcTy.getSizeInBits() > 64 || Ty.getSizeInBits() > 32) + return false; + + I.setDesc(TII.get(AArch64::UBFMXri)); + MachineInstrBuilder(MF, I).addImm(I.getOperand(2).getImm() + + Ty.getSizeInBits() - 1); + + unsigned DstReg = MRI.createGenericVirtualRegister(LLT::scalar(64)); + BuildMI(MBB, std::next(I.getIterator()), I.getDebugLoc(), + TII.get(AArch64::COPY)) + .addDef(I.getOperand(0).getReg()) + .addUse(DstReg, 0, AArch64::sub_32); + RBI.constrainGenericRegister(I.getOperand(0).getReg(), + AArch64::GPR32RegClass, MRI); + I.getOperand(0).setReg(DstReg); + + return constrainSelectedInstRegOperands(I, TII, TRI, RBI); + } case TargetOpcode::G_INSERT: { LLT SrcTy = MRI.getType(I.getOperand(2).getReg()); @@ -798,7 +821,7 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const { BuildMI(MBB, I.getIterator(), I.getDebugLoc(), TII.get(AArch64::SUBREG_TO_REG)) .addDef(SrcReg) - .addUse(0) + .addImm(0) .addUse(I.getOperand(2).getReg()) .addImm(AArch64::sub_32); RBI.constrainGenericRegister(I.getOperand(2).getReg(), diff --git a/test/CodeGen/AArch64/GlobalISel/select-insert-extract.mir b/test/CodeGen/AArch64/GlobalISel/select-insert-extract.mir index 8248a63732c..e88e151bd24 100644 --- a/test/CodeGen/AArch64/GlobalISel/select-insert-extract.mir +++ b/test/CodeGen/AArch64/GlobalISel/select-insert-extract.mir @@ -15,11 +15,11 @@ body: | %1:gpr(s64) = G_IMPLICIT_DEF ; CHECK: body: - ; CHECK: [[TMP:%[0-9]+]] = SUBREG_TO_REG _, %0, 15 + ; CHECK: [[TMP:%[0-9]+]] = SUBREG_TO_REG 0, %0, 15 ; CHECK: %2 = BFMXri %1, [[TMP]], 0, 31 %2:gpr(s64) = G_INSERT %1, %0, 0 - ; CHECK: [[TMP:%[0-9]+]] = SUBREG_TO_REG _, %0, 15 + ; CHECK: [[TMP:%[0-9]+]] = SUBREG_TO_REG 0, %0, 15 ; CHECK: %3 = BFMXri %1, [[TMP]], 51, 31 %3:gpr(s64) = G_INSERT %1, %0, 13