diff --git a/llvm/include/llvm/CodeGen/GlobalISel/ConstantFoldingMIRBuilder.h b/llvm/include/llvm/CodeGen/GlobalISel/ConstantFoldingMIRBuilder.h --- a/llvm/include/llvm/CodeGen/GlobalISel/ConstantFoldingMIRBuilder.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/ConstantFoldingMIRBuilder.h @@ -54,6 +54,17 @@ return buildConstant(Dst, MaybeCst->getSExtValue()); break; } + case TargetOpcode::G_SEXT_INREG: { + assert(DstOps.size() == 1 && "Invalid dst ops"); + assert(SrcOps.size() == 2 && "Invalid src ops"); + const DstOp &Dst = DstOps[0]; + const SrcOp &Src0 = SrcOps[0]; + const SrcOp &Src1 = SrcOps[1]; + if (auto MaybeCst = ConstantFoldExtOp( + Opc, Src0.getReg(), Src1.getImm().getSExtValue(), *getMRI())) + return buildConstant(Dst, MaybeCst->getSExtValue()); + break; + } } return MachineIRBuilder::buildInstr(Opc, DstOps, SrcOps); } diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h --- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h @@ -104,24 +104,18 @@ unsigned DstReg = MI.getOperand(0).getReg(); unsigned SrcReg = lookThroughCopyInstrs(MI.getOperand(1).getReg()); - // sext(trunc x) - > ashr (shl (aext/copy/trunc x), c), c + // sext(trunc x) - > (sext_inreg (aext/copy/trunc x), c) unsigned TruncSrc; if (mi_match(SrcReg, MRI, m_GTrunc(m_Reg(TruncSrc)))) { LLT DstTy = MRI.getType(DstReg); - // Guess on the RHS shift amount type, which should be re-legalized if - // applicable. - if (isInstUnsupported({TargetOpcode::G_SHL, {DstTy, DstTy}}) || - isInstUnsupported({TargetOpcode::G_ASHR, {DstTy, DstTy}}) || - isConstantUnsupported(DstTy)) + if (isInstUnsupported({TargetOpcode::G_SEXT_INREG, {DstTy}})) return false; LLVM_DEBUG(dbgs() << ".. Combine MI: " << MI;); LLT SrcTy = MRI.getType(SrcReg); - unsigned ShAmt = DstTy.getScalarSizeInBits() - SrcTy.getScalarSizeInBits(); - auto MIBShAmt = Builder.buildConstant(DstTy, ShAmt); - auto MIBShl = Builder.buildInstr( - TargetOpcode::G_SHL, {DstTy}, - {Builder.buildAnyExtOrTrunc(DstTy, TruncSrc), MIBShAmt}); - Builder.buildInstr(TargetOpcode::G_ASHR, {DstReg}, {MIBShl, MIBShAmt}); + unsigned SizeInBits = SrcTy.getScalarSizeInBits(); + Builder.buildInstr( + TargetOpcode::G_SEXT_INREG, {DstReg}, + {Builder.buildAnyExtOrTrunc(DstTy, TruncSrc), APInt(64, SizeInBits)}); markInstAndDefDead(MI, *MRI.getVRegDef(SrcReg), DeadInsts); return true; } diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h --- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -143,5 +143,8 @@ Optional ConstantFoldBinOp(unsigned Opcode, const unsigned Op1, const unsigned Op2, const MachineRegisterInfo &MRI); + +Optional ConstantFoldExtOp(unsigned Opcode, const unsigned Op1, + uint64_t Imm, const MachineRegisterInfo &MRI); } // End namespace llvm. #endif diff --git a/llvm/include/llvm/Support/TargetOpcodes.def b/llvm/include/llvm/Support/TargetOpcodes.def --- a/llvm/include/llvm/Support/TargetOpcodes.def +++ b/llvm/include/llvm/Support/TargetOpcodes.def @@ -351,6 +351,7 @@ // Generic sign extend HANDLE_TARGET_OPCODE(G_SEXT) +HANDLE_TARGET_OPCODE(G_SEXT_INREG) // Generic zero extend HANDLE_TARGET_OPCODE(G_ZEXT) diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -33,6 +33,20 @@ let hasSideEffects = 0; } +// Sign extend the a value from an arbitrary bit position, copying the sign bit +// into all bits above it. This is equivalent to a shl + ashr pair with an +// appropriate shift amount. $sz is an immediate (MachineOperand::isImm() +// returns true) to allow targets to have some bitwidths legal and others +// lowered. This opcode is particularly useful if the target has sign-extension +// instructions that are cheaper than the constituent shifts as the optimizer is +// able to make decisions on whether it's better to hang on to the G_SEXT_INREG +// or to lower it and optimize the individual shifts. +def G_SEXT_INREG : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$src, untyped_imm:$sz); + let hasSideEffects = 0; +} + // Zero extend the underlying scalar type of an operation, putting zero bits // into the newly-created space. def G_ZEXT : GenericInstruction { diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td --- a/llvm/include/llvm/Target/Target.td +++ b/llvm/include/llvm/Target/Target.td @@ -817,6 +817,7 @@ class TypedOperand : Operand { let OperandType = Ty; bit IsPointer = 0; + bit IsImmediate = 0; } def type0 : TypedOperand<"OPERAND_GENERIC_0">; @@ -835,6 +836,12 @@ def ptype5 : TypedOperand<"OPERAND_GENERIC_5">; } +// untyped_imm is for operands where isImm() will be true. It currently has no +// and is only used to avoid using `unknown`. +def untyped_imm : TypedOperand<"OPERAND_UNKNOWN"> { + let IsImmediate = 1; +} + /// zero_reg definition - Special node to stand for the zero register. /// def zero_reg; diff --git a/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp --- a/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp @@ -162,6 +162,17 @@ return buildConstant(DstOps[0], Cst->getSExtValue()); break; } + case TargetOpcode::G_SEXT_INREG: { + assert(DstOps.size() == 1 && "Invalid dst ops"); + assert(SrcOps.size() == 2 && "Invalid src ops"); + const DstOp &Dst = DstOps[0]; + const SrcOp &Src0 = SrcOps[0]; + const SrcOp &Src1 = SrcOps[1]; + if (auto MaybeCst = ConstantFoldExtOp( + Opc, Src0.getReg(), Src1.getImm().getSExtValue(), *getMRI())) + return buildConstant(Dst, MaybeCst->getSExtValue()); + break; + } } bool CanCopy = checkCopyToDefsPossible(DstOps); if (!canPerformCSEForOpc(Opc)) diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp --- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp @@ -695,6 +695,101 @@ narrowScalarDst(MI, NarrowTy, 0, TargetOpcode::G_ZEXT); Observer.changedInstr(MI); return Legalized; + case TargetOpcode::G_SEXT_INREG: { + if (TypeIdx != 0) + return UnableToLegalize; + + if (!MI.getOperand(2).isImm()) + return UnableToLegalize; + int64_t SizeInBits = MI.getOperand(2).getImm(); + + // So long as the new type has more bits than the bits we're extending we + // don't need to break it apart. + if (NarrowTy.getScalarSizeInBits() >= SizeInBits) { + Observer.changingInstr(MI); + MI.getOperand(2).setImm(SizeInBits); + // We don't lose any non-extension bits by truncating the src and + // sign-extending the dst. + MachineOperand &MO1 = MI.getOperand(1); + auto TruncMIB = MIRBuilder.buildTrunc(NarrowTy, MO1.getReg()); + MO1.setReg(TruncMIB->getOperand(0).getReg()); + + MachineOperand &MO2 = MI.getOperand(0); + unsigned DstExt = MRI.createGenericVirtualRegister(NarrowTy); + MIRBuilder.setInsertPt(MIRBuilder.getMBB(), ++MIRBuilder.getInsertPt()); + MIRBuilder.buildInstr(TargetOpcode::G_SEXT, {MO2.getReg()}, {DstExt}); + MO2.setReg(DstExt); + Observer.changedInstr(MI); + return Legalized; + } + + // Break it apart. Components below the extension point are unmodified. The + // component containing the extension point becomes a narrower SEXT_INREG. + // Components above it are ashr'd from the component containing the + // extension point. + if (SizeOp0 % NarrowSize != 0) + return UnableToLegalize; + int NumParts = SizeOp0 / NarrowSize; + + // List the registers where the destination will be scattered. + SmallVector DstRegs; + // List the registers where the source will be split. + SmallVector SrcRegs; + + // Create all the temporary registers. + for (int i = 0; i < NumParts; ++i) { + unsigned SrcReg = MRI.createGenericVirtualRegister(NarrowTy); + + SrcRegs.push_back(SrcReg); + } + + // Explode the big arguments into smaller chunks. + MIRBuilder.buildUnmerge(SrcRegs, MI.getOperand(1).getReg()); + + unsigned AshrCstReg = + MIRBuilder.buildConstant(NarrowTy, NarrowTy.getScalarSizeInBits() - 1) + ->getOperand(0) + .getReg(); + unsigned FullExtensionReg = 0; + unsigned PartialExtensionReg = 0; + + // Do the operation on each small part. + for (int i = 0; i < NumParts; ++i) { + if ((i + 1) * NarrowTy.getScalarSizeInBits() < SizeInBits) + DstRegs.push_back(SrcRegs[i]); + else if (i * NarrowTy.getScalarSizeInBits() > SizeInBits) { + assert(PartialExtensionReg && + "Expected to visit partial extension before full"); + if (FullExtensionReg) { + DstRegs.push_back(FullExtensionReg); + continue; + } + DstRegs.push_back(MIRBuilder + .buildInstr(TargetOpcode::G_ASHR, {NarrowTy}, + {PartialExtensionReg, AshrCstReg}) + ->getOperand(0) + .getReg()); + FullExtensionReg = DstRegs.back(); + } else { + DstRegs.push_back( + MIRBuilder + .buildInstr( + TargetOpcode::G_SEXT_INREG, {NarrowTy}, + {SrcRegs[i], + APInt(NarrowTy.getScalarSizeInBits(), + SizeInBits % NarrowTy.getScalarSizeInBits())}) + ->getOperand(0) + .getReg()); + PartialExtensionReg = DstRegs.back(); + } + } + + // Gather the destination registers into the final destination. + unsigned DstReg = MI.getOperand(0).getReg(); + MIRBuilder.buildMerge(DstReg, DstRegs); + MI.eraseFromParent(); + return Legalized; + } } } @@ -1355,6 +1450,15 @@ widenScalarDst(MI, WideTy, 0); Observer.changedInstr(MI); return Legalized; + case TargetOpcode::G_SEXT_INREG: + if (TypeIdx != 0) + return UnableToLegalize; + + Observer.changingInstr(MI); + widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_ANYEXT); + widenScalarDst(MI, WideTy, 0, TargetOpcode::G_TRUNC); + Observer.changedInstr(MI); + return Legalized; } } @@ -1596,6 +1700,22 @@ MI.eraseFromParent(); return Legalized; } + + case TargetOpcode::G_SEXT_INREG: { + assert(MI.getOperand(2).isImm() && "Expected immediate"); + int64_t SizeInBits = MI.getOperand(2).getImm(); + + unsigned DstReg = MI.getOperand(0).getReg(); + unsigned SrcReg = MI.getOperand(1).getReg(); + LLT DstTy = MRI.getType(DstReg); + unsigned TmpRes = MRI.createGenericVirtualRegister(DstTy); + + auto MIBSz = MIRBuilder.buildConstant(DstTy, DstTy.getScalarSizeInBits() - SizeInBits); + MIRBuilder.buildInstr(TargetOpcode::G_SHL, {TmpRes}, {SrcReg, MIBSz->getOperand(0).getReg()}); + MIRBuilder.buildInstr(TargetOpcode::G_ASHR, {DstReg}, {TmpRes, MIBSz->getOperand(0).getReg()}); + MI.eraseFromParent(); + return Legalized; + } } } diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp --- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp @@ -361,6 +361,23 @@ return None; } +Optional llvm::ConstantFoldExtOp(unsigned Opcode, const unsigned Op1, + uint64_t Imm, + const MachineRegisterInfo &MRI) { + auto MaybeOp1Cst = getConstantVRegVal(Op1, MRI); + if (MaybeOp1Cst) { + LLT Ty = MRI.getType(Op1); + APInt C1(Ty.getSizeInBits(), *MaybeOp1Cst, true); + switch (Opcode) { + default: + break; + case TargetOpcode::G_SEXT_INREG: + return C1.trunc(Imm).sext(C1.getBitWidth()); + } + } + return None; +} + void llvm::getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU) { AU.addPreserved(); } diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1312,6 +1312,23 @@ break; } + case TargetOpcode::G_SEXT_INREG: { + if (!MI->getOperand(2).isImm()) { + report("G_SEXT_INREG expects an immediate operand #2", MI); + break; + } + + LLT DstTy = MRI->getType(MI->getOperand(0).getReg()); + LLT SrcTy = MRI->getType(MI->getOperand(1).getReg()); + verifyVectorElementMatch(DstTy, SrcTy, MI); + + int64_t Imm = MI->getOperand(2).getImm(); + if (Imm <= 0) + report("G_SEXT_INREG size must be >= 1", MI); + if (Imm >= SrcTy.getScalarSizeInBits()) + report("G_SEXT_INREG size must be less than source bit width", MI); + break; + } default: break; } diff --git a/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp --- a/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp @@ -347,6 +347,8 @@ getActionDefinitionsBuilder(G_TRUNC).alwaysLegal(); + getActionDefinitionsBuilder(G_SEXT_INREG).lower(); + // FP conversions getActionDefinitionsBuilder(G_FPTRUNC).legalFor( {{s16, s32}, {s16, s64}, {s32, s64}, {v4s16, v4s32}, {v2s32, v2s64}}); diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -660,6 +660,8 @@ .scalarize(1); } + getActionDefinitionsBuilder(G_SEXT_INREG).lower(); + computeTables(); verify(*ST.getInstrInfo()); } diff --git a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp --- a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp +++ b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp @@ -84,6 +84,8 @@ getActionDefinitionsBuilder({G_SEXT, G_ZEXT, G_ANYEXT}) .legalForCartesianProduct({s32}, {s1, s8, s16}); + getActionDefinitionsBuilder(G_SEXT_INREG).lower(); + getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR}) .legalFor({s32}) .minScalar(0, s32); diff --git a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp --- a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp +++ b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp @@ -97,6 +97,8 @@ getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV}) .legalFor({s32, s64}); + getActionDefinitionsBuilder(G_SEXT_INREG).lower(); + computeTables(); verify(*ST.getInstrInfo()); } diff --git a/llvm/lib/Target/X86/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/X86LegalizerInfo.cpp --- a/llvm/lib/Target/X86/X86LegalizerInfo.cpp +++ b/llvm/lib/Target/X86/X86LegalizerInfo.cpp @@ -158,6 +158,7 @@ setAction({G_ANYEXT, Ty}, Legal); } setAction({G_ANYEXT, s128}, Legal); + getActionDefinitionsBuilder(G_SEXT_INREG).lower(); // Comparison setAction({G_ICMP, s1}, Legal); diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-extends.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-extends.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-extends.ll @@ -0,0 +1,30 @@ +; RUN: llc -O0 -mtriple=aarch64-apple-ios -global-isel -stop-after=irtranslator %s -o - | FileCheck %s + +; Test that extends correctly translate to G_[ZS]EXT. The translator will never +; emit a G_SEXT_INREG. + +define i32 @test_zext(i32 %a) { + ; CHECK-LABEL: name: test_zext + ; CHECK: %0:_(s32) = COPY $w0 + ; CHECK: %1:_(s8) = G_TRUNC %0(s32) + ; CHECK: %2:_(s16) = G_ZEXT %1(s8) + ; CHECK: %3:_(s32) = G_ZEXT %2(s16) + ; CHECK: $w0 = COPY %3(s32) + %tmp0 = trunc i32 %a to i8 + %tmp1 = zext i8 %tmp0 to i16 + %tmp2 = zext i16 %tmp1 to i32 + ret i32 %tmp2 +} + +define i32 @test_sext(i32 %a) { + ; CHECK-LABEL: name: test_sext + ; CHECK: %0:_(s32) = COPY $w0 + ; CHECK: %1:_(s8) = G_TRUNC %0(s32) + ; CHECK: %2:_(s16) = G_SEXT %1(s8) + ; CHECK: %3:_(s32) = G_SEXT %2(s16) + ; CHECK: $w0 = COPY %3(s32) + %tmp0 = trunc i32 %a to i8 + %tmp1 = sext i8 %tmp0 to i16 + %tmp2 = sext i16 %tmp1 to i32 + ret i32 %tmp2 +} diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-div.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-div.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-div.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-div.mir @@ -5,26 +5,26 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_div - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; CHECK: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] - ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) - ; CHECK: $w0 = COPY [[COPY2]](s32) - ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; CHECK: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC2]], [[C2]] - ; CHECK: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC3]], [[C2]] - ; CHECK: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] - ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[UDIV]](s32) - ; CHECK: $w0 = COPY [[COPY3]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; CHECK-DAG: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] + ; CHECK-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY2]](s32) + ; CHECK-DAG: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; CHECK-DAG: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC2]], [[C2]] + ; CHECK-DAG: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC3]], [[C2]] + ; CHECK-DAG: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] + ; CHECK-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[UDIV]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY3]](s32) %0:_(s64) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s8) = G_TRUNC %0(s64) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-ext.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-ext.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-ext.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-ext.mir @@ -5,63 +5,63 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_ext - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC]](s32) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC1]](s32) - ; CHECK: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC2]](s32) - ; CHECK: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC3]](s32) - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) - ; CHECK: $x0 = COPY [[COPY1]](s64) - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 255 - ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) - ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]] - ; CHECK: $x0 = COPY [[AND]](s64) - ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) - ; CHECK: $x0 = COPY [[COPY3]](s64) - ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 32 - ; CHECK: [[COPY4:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY4]], [[C1]] - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C1]] - ; CHECK: $x0 = COPY [[ASHR]](s64) - ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 - ; CHECK: [[TRUNC4:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC4]], [[C2]] - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C2]] - ; CHECK: $w0 = COPY [[ASHR1]](s32) - ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; CHECK: [[TRUNC5:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC5]], [[C3]] - ; CHECK: $w0 = COPY [[AND1]](s32) - ; CHECK: [[TRUNC6:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC6]](s32) - ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK: [[TRUNC7:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[TRUNC7]], [[C4]] - ; CHECK: $w0 = COPY [[AND2]](s32) - ; CHECK: [[TRUNC8:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC8]](s32) - ; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[TRUNC9:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[TRUNC9]], [[C5]] - ; CHECK: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C5]] - ; CHECK: $w0 = COPY [[ASHR2]](s32) - ; CHECK: [[TRUNC10:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[AND3:%[0-9]+]]:_(s32) = G_AND [[TRUNC10]], [[C4]] - ; CHECK: $w0 = COPY [[AND3]](s32) - ; CHECK: [[TRUNC11:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC11]](s32) - ; CHECK: [[TRUNC12:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: $w0 = COPY [[TRUNC12]](s32) - ; CHECK: [[FPEXT:%[0-9]+]]:_(s64) = G_FPEXT [[TRUNC12]](s32) - ; CHECK: $x0 = COPY [[FPEXT]](s64) - ; CHECK: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 - ; CHECK: $w0 = COPY [[C7]](s32) - ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF - ; CHECK: $w0 = COPY [[DEF]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC]](s32) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC1]](s32) + ; CHECK-DAG: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC2]](s32) + ; CHECK-DAG: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC3]](s32) + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) + ; CHECK-DAG: $x0 = COPY [[COPY1]](s64) + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 255 + ; CHECK-DAG: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) + ; CHECK-DAG: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]] + ; CHECK-DAG: $x0 = COPY [[AND]](s64) + ; CHECK-DAG: [[COPY3:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) + ; CHECK-DAG: $x0 = COPY [[COPY3]](s64) + ; CHECK-DAG: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 32 + ; CHECK-DAG: [[COPY4:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY4]], [[C1]] + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C1]] + ; CHECK-DAG: $x0 = COPY [[ASHR]](s64) + ; CHECK-DAG: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 + ; CHECK-DAG: [[TRUNC4:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC4]], [[C2]] + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C2]] + ; CHECK-DAG: $w0 = COPY [[ASHR1]](s32) + ; CHECK-DAG: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; CHECK-DAG: [[TRUNC5:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC5]], [[C3]] + ; CHECK-DAG: $w0 = COPY [[AND1]](s32) + ; CHECK-DAG: [[TRUNC6:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC6]](s32) + ; CHECK-DAG: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-DAG: [[TRUNC7:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[AND2:%[0-9]+]]:_(s32) = G_AND [[TRUNC7]], [[C4]] + ; CHECK-DAG: $w0 = COPY [[AND2]](s32) + ; CHECK-DAG: [[TRUNC8:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC8]](s32) + ; CHECK-DAG: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[TRUNC9:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[TRUNC9]], [[C5]] + ; CHECK-DAG: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C5]] + ; CHECK-DAG: $w0 = COPY [[ASHR2]](s32) + ; CHECK-DAG: [[TRUNC10:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[AND3:%[0-9]+]]:_(s32) = G_AND [[TRUNC10]], [[C4]] + ; CHECK-DAG: $w0 = COPY [[AND3]](s32) + ; CHECK-DAG: [[TRUNC11:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC11]](s32) + ; CHECK-DAG: [[TRUNC12:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: $w0 = COPY [[TRUNC12]](s32) + ; CHECK-DAG: [[FPEXT:%[0-9]+]]:_(s64) = G_FPEXT [[TRUNC12]](s32) + ; CHECK-DAG: $x0 = COPY [[FPEXT]](s64) + ; CHECK-DAG: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 + ; CHECK-DAG: $w0 = COPY [[C7]](s32) + ; CHECK-DAG: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF + ; CHECK-DAG: $w0 = COPY [[DEF]](s32) %0:_(s64) = COPY $x0 %1:_(s1) = G_TRUNC %0(s64) %19:_(s32) = G_ANYEXT %1(s1) @@ -120,9 +120,9 @@ liveins: $w0 ; CHECK-LABEL: name: test_anyext_anyext - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: $w0 = COPY [[COPY1]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY1]](s32) %0:_(s32) = COPY $w0 %1:_(s1) = G_TRUNC %0(s32) %2:_(s8) = G_ANYEXT %1(s1) @@ -137,12 +137,12 @@ liveins: $w0 ; CHECK-LABEL: name: test_anyext_sext - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]] - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]] - ; CHECK: $w0 = COPY [[ASHR]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]] + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]] + ; CHECK-DAG: $w0 = COPY [[ASHR]](s32) %0:_(s32) = COPY $w0 %1:_(s1) = G_TRUNC %0(s32) %2:_(s8) = G_SEXT %1(s1) @@ -157,11 +157,11 @@ liveins: $w0 ; CHECK-LABEL: name: test_anyext_zext - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]] - ; CHECK: $w0 = COPY [[AND]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]] + ; CHECK-DAG: $w0 = COPY [[AND]](s32) %0:_(s32) = COPY $w0 %1:_(s1) = G_TRUNC %0(s32) %2:_(s8) = G_ZEXT %1(s1) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-gep.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-gep.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-gep.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-gep.mir @@ -5,14 +5,14 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_gep_small - ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 56 - ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY1]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY2]], [[C]] - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]] - ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[ASHR]](s64) - ; CHECK: $x0 = COPY [[GEP]](p0) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(p0) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 56 + ; CHECK-DAG: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY1]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY2]], [[C]] + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]] + ; CHECK-DAG: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[ASHR]](s64) + ; CHECK-DAG: $x0 = COPY [[GEP]](p0) %0:_(p0) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s8) = G_TRUNC %1(s64) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-itofp.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-itofp.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-itofp.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-itofp.mir @@ -147,13 +147,13 @@ bb.0: liveins: $w0 ; CHECK-LABEL: name: test_sitofp_s32_s1 - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) - ; CHECK: $w0 = COPY [[SITOFP]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: $w0 = COPY [[SITOFP]](s32) %0:_(s32) = COPY $w0 %1:_(s1) = G_TRUNC %0 %2:_(s32) = G_SITOFP %1 @@ -184,13 +184,13 @@ bb.0: liveins: $w0 ; CHECK-LABEL: name: test_sitofp_s64_s8 - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[ASHR]](s32) - ; CHECK: $x0 = COPY [[SITOFP]](s64) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: $x0 = COPY [[SITOFP]](s64) %0:_(s32) = COPY $w0 %1:_(s8) = G_TRUNC %0 %2:_(s64) = G_SITOFP %1 @@ -249,13 +249,13 @@ bb.0: liveins: $w0 ; CHECK-LABEL: name: test_sitofp_s32_s16 - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) - ; CHECK: $w0 = COPY [[SITOFP]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: $w0 = COPY [[SITOFP]](s32) %0:_(s32) = COPY $w0 %1:_(s16) = G_TRUNC %0 %2:_(s32) = G_SITOFP %1 diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir @@ -5,12 +5,12 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_urem_64 - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: [[UDIV:%[0-9]+]]:_(s64) = G_UDIV [[COPY]], [[COPY1]] - ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[UDIV]], [[COPY1]] - ; CHECK: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[COPY]], [[MUL]] - ; CHECK: $x0 = COPY [[SUB]](s64) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: [[UDIV:%[0-9]+]]:_(s64) = G_UDIV [[COPY]], [[COPY1]] + ; CHECK-DAG: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[UDIV]], [[COPY1]] + ; CHECK-DAG: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[COPY]], [[MUL]] + ; CHECK-DAG: $x0 = COPY [[SUB]](s64) %0:_(s64) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s64) = G_UREM %0, %1 @@ -22,14 +22,14 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_srem_32 - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[TRUNC]], [[TRUNC1]] - ; CHECK: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[TRUNC1]] - ; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[TRUNC]], [[MUL]] - ; CHECK: $w0 = COPY [[SUB]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[TRUNC]], [[TRUNC1]] + ; CHECK-DAG: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[TRUNC1]] + ; CHECK-DAG: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[TRUNC]], [[MUL]] + ; CHECK-DAG: $w0 = COPY [[SUB]](s32) %0:_(s64) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s32) = G_TRUNC %0(s64) @@ -43,24 +43,24 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_srem_8 - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC]], [[C]] - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]] - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C]] - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]] - ; CHECK: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] - ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) - ; CHECK: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY2]], [[TRUNC2]] - ; CHECK: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[MUL]](s32) - ; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[TRUNC3]], [[COPY3]] - ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) - ; CHECK: $w0 = COPY [[COPY4]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC]], [[C]] + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]] + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C]] + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]] + ; CHECK-DAG: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] + ; CHECK-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) + ; CHECK-DAG: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY2]], [[TRUNC2]] + ; CHECK-DAG: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[MUL]](s32) + ; CHECK-DAG: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[TRUNC3]], [[COPY3]] + ; CHECK-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY4]](s32) %0:_(s64) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s8) = G_TRUNC %0(s64) @@ -75,24 +75,24 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_frem - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp - ; CHECK: $d0 = COPY [[COPY]](s64) - ; CHECK: $d1 = COPY [[COPY1]](s64) - ; CHECK: BL &fmod, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $d0, implicit $d1, implicit-def $d0 - ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $d0 - ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp - ; CHECK: $x0 = COPY [[COPY2]](s64) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp - ; CHECK: $s0 = COPY [[TRUNC]](s32) - ; CHECK: $s1 = COPY [[TRUNC1]](s32) - ; CHECK: BL &fmodf, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $s0, implicit $s1, implicit-def $s0 - ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY $s0 - ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp - ; CHECK: $w0 = COPY [[COPY3]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp + ; CHECK-DAG: $d0 = COPY [[COPY]](s64) + ; CHECK-DAG: $d1 = COPY [[COPY1]](s64) + ; CHECK-DAG: BL &fmod, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $d0, implicit $d1, implicit-def $d0 + ; CHECK-DAG: [[COPY2:%[0-9]+]]:_(s64) = COPY $d0 + ; CHECK-DAG: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp + ; CHECK-DAG: $x0 = COPY [[COPY2]](s64) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp + ; CHECK-DAG: $s0 = COPY [[TRUNC]](s32) + ; CHECK-DAG: $s1 = COPY [[TRUNC1]](s32) + ; CHECK-DAG: BL &fmodf, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $s0, implicit $s1, implicit-def $s0 + ; CHECK-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY $s0 + ; CHECK-DAG: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp + ; CHECK-DAG: $w0 = COPY [[COPY3]](s32) %0:_(s64) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s64) = G_FREM %0, %1 diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sext.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sext.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-sext.mir @@ -0,0 +1,16 @@ +# RUN: llc -march=aarch64 -run-pass=legalizer %s -o - | FileCheck %s +--- +name: test_sext_inreg +body: | + bb.0.entry: + liveins: $w0, $w1 + ; CHECK-LABEL: name: test_sext_inreg + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $w1 + ; CHECK-DAG: [[I25:%[0-9]+]]:_(s32) = G_CONSTANT i32 25 + ; CHECK-DAG: [[SEXT1:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[I25]] + ; CHECK-DAG: [[SEXT2:%[0-9]+]]:_(s32) = G_ASHR [[SEXT1]], [[I25]] + ; CHECK-DAG: $w0 = COPY [[SEXT2]](s32) + %0:_(s32) = COPY $w1 + %2:_(s32) = G_SEXT_INREG %0(s32), 7 + $w0 = COPY %2(s32) +... diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-shift.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-shift.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-shift.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-shift.mir @@ -5,31 +5,31 @@ body: | bb.0.entry: ; CHECK-LABEL: name: test_shift - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]] - ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C1]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) - ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) - ; CHECK: $w0 = COPY [[COPY2]](s32) - ; CHECK: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC2]], [[C]] - ; CHECK: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[TRUNC3]], [[C]] - ; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[AND2]], [[AND1]](s32) - ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[LSHR]](s32) - ; CHECK: $w0 = COPY [[COPY3]](s32) - ; CHECK: [[TRUNC4:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) - ; CHECK: [[AND3:%[0-9]+]]:_(s32) = G_AND [[TRUNC4]], [[C]] - ; CHECK: [[TRUNC5:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC5]], [[AND3]](s32) - ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SHL1]](s32) - ; CHECK: $w0 = COPY [[COPY4]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]] + ; CHECK-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[TRUNC1]], [[C1]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) + ; CHECK-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY2]](s32) + ; CHECK-DAG: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC2]], [[C]] + ; CHECK-DAG: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[AND2:%[0-9]+]]:_(s32) = G_AND [[TRUNC3]], [[C]] + ; CHECK-DAG: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[AND2]], [[AND1]](s32) + ; CHECK-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[LSHR]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY3]](s32) + ; CHECK-DAG: [[TRUNC4:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64) + ; CHECK-DAG: [[AND3:%[0-9]+]]:_(s32) = G_AND [[TRUNC4]], [[C]] + ; CHECK-DAG: [[TRUNC5:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[TRUNC5]], [[AND3]](s32) + ; CHECK-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SHL1]](s32) + ; CHECK-DAG: $w0 = COPY [[COPY4]](s32) %0:_(s64) = COPY $x0 %1:_(s64) = COPY $x1 %2:_(s8) = G_TRUNC %0(s64) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-undef.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-undef.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-undef.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-undef.mir @@ -24,11 +24,11 @@ liveins: ; CHECK-LABEL: name: test_implicit_def_s3 - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 61 - ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[DEF]], [[C]](s64) - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]](s64) - ; CHECK: $x0 = COPY [[ASHR]](s64) + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 61 + ; CHECK-DAG: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[DEF]], [[C]](s64) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]](s64) + ; CHECK-DAG: $x0 = COPY [[ASHR]](s64) %0:_(s3) = G_IMPLICIT_DEF %1:_(s64) = G_SEXT %0 $x0 = COPY %1(s64) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -177,6 +177,9 @@ # DEBUG-NEXT: G_SEXT (opcode {{[0-9]+}}): 2 type indices # DEBUG: .. type index coverage check SKIPPED: user-defined predicate detected # +# DEBUG-NEXT: G_SEXT_INREG (opcode {{[0-9]+}}): 1 type index +# DEBUG: .. type index coverage check SKIPPED: user-defined predicate detected +# # DEBUG-NEXT: G_ZEXT (opcode {{[0-9]+}}): 2 type indices # DEBUG: .. type index coverage check SKIPPED: user-defined predicate detected # diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-sext.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-sext.mir --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-sext.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-sext.mir @@ -9,16 +9,16 @@ liveins: $vgpr0_vgpr1 ; CHECK-LABEL: name: test_sext_trunc_v2s32_to_v2s16_to_v2s32 - ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY [[COPY]](<2 x s32>) - ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C]](s32) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) - ; CHECK: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY [[COPY]](<2 x s32>) + ; CHECK-DAG: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C]](s32) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; CHECK-DAG: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) + ; CHECK-DAG: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>) %0:_(<2 x s32>) = COPY $vgpr0_vgpr1 %1:_(<2 x s16>) = G_TRUNC %0 %2:_(<2 x s32>) = G_SEXT %1 @@ -32,21 +32,21 @@ liveins: $vgpr0_vgpr1 ; CHECK-LABEL: name: test_sext_trunc_v2s32_to_v2s16_to_v2s64 - ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1 - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48 - ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[UV]](s32) - ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT [[UV1]](s32) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[TRUNC]](s32) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT1]], [[TRUNC1]](s32) - ; CHECK: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC2]](s32) - ; CHECK: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[SHL1]], [[TRUNC3]](s32) - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[ASHR]](s64), [[ASHR1]](s64) - ; CHECK: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[BUILD_VECTOR]](<2 x s64>) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48 + ; CHECK-DAG: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[UV]](s32) + ; CHECK-DAG: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT [[UV1]](s32) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[TRUNC]](s32) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT1]], [[TRUNC1]](s32) + ; CHECK-DAG: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC2]](s32) + ; CHECK-DAG: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[SHL1]], [[TRUNC3]](s32) + ; CHECK-DAG: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[ASHR]](s64), [[ASHR1]](s64) + ; CHECK-DAG: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[BUILD_VECTOR]](<2 x s64>) %0:_(<2 x s32>) = COPY $vgpr0_vgpr1 %1:_(<2 x s16>) = G_TRUNC %0 %2:_(<2 x s64>) = G_SEXT %1 @@ -60,13 +60,12 @@ liveins: $vgpr0_vgpr1 ; CHECK-LABEL: name: test_sext_trunc_v2s32_to_v2s8_to_v2s16 - ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1 - ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 8 - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[C]](s16), [[C]](s16) - ; CHECK: [[TRUNC:%[0-9]+]]:_(<2 x s16>) = G_TRUNC [[COPY]](<2 x s32>) - ; CHECK: [[SHL:%[0-9]+]]:_(<2 x s16>) = G_SHL [[TRUNC]], [[BUILD_VECTOR]](<2 x s16>) - ; CHECK: [[ASHR:%[0-9]+]]:_(<2 x s16>) = G_ASHR [[SHL]], [[BUILD_VECTOR]](<2 x s16>) - ; CHECK: $vgpr0 = COPY [[ASHR]](<2 x s16>) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1 + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(<2 x s16>) = G_TRUNC [[COPY]](<2 x s32>) + ; The G_SEXT_INREG doesn't lower here because G_TRUNC is both illegal and + ; unable to legalize. This prevents further legalization. + ; CHECK-DAG: [[SEXT_INREG:%[0-9]+]]:_(<2 x s16>) = G_SEXT_INREG [[TRUNC]], 8 + ; CHECK-DAG: $vgpr0 = COPY [[SEXT_INREG]](<2 x s16>) %0:_(<2 x s32>) = COPY $vgpr0_vgpr1 %1:_(<2 x s8>) = G_TRUNC %0 %2:_(<2 x s16>) = G_SEXT %1 @@ -80,18 +79,18 @@ liveins: $vgpr0_vgpr1_vgpr2 ; CHECK-LABEL: name: test_sext_trunc_v3s32_to_v3s16_to_v3s32 - ; CHECK: [[COPY:%[0-9]+]]:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[COPY1:%[0-9]+]]:_(<3 x s32>) = COPY [[COPY]](<3 x s32>) - ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<3 x s32>) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C]](s32) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C]](s32) - ; CHECK: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[UV2]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; CHECK: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<3 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32), [[ASHR2]](s32) - ; CHECK: $vgpr0_vgpr1_vgpr2 = COPY [[BUILD_VECTOR]](<3 x s32>) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(<3 x s32>) = COPY [[COPY]](<3 x s32>) + ; CHECK-DAG: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<3 x s32>) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C]](s32) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C]](s32) + ; CHECK-DAG: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[UV2]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; CHECK-DAG: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) + ; CHECK-DAG: [[BUILD_VECTOR:%[0-9]+]]:_(<3 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32), [[ASHR2]](s32) + ; CHECK-DAG: $vgpr0_vgpr1_vgpr2 = COPY [[BUILD_VECTOR]](<3 x s32>) %0:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2 %1:_(<3 x s16>) = G_TRUNC %0 %2:_(<3 x s32>) = G_SEXT %1 diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-ext-legalizer.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-ext-legalizer.mir --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-ext-legalizer.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-ext-legalizer.mir @@ -8,14 +8,14 @@ liveins: $vgpr0_vgpr1 ; CHECK-LABEL: name: test_sext_trunc_i64_i32_i64 - ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1 - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32 - ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[TRUNC]](s32) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC1]](s32) - ; CHECK: $vgpr0_vgpr1 = COPY [[ASHR]](s64) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[TRUNC]](s32) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC1]](s32) + ; CHECK-DAG: $vgpr0_vgpr1 = COPY [[ASHR]](s64) %0:_(s64) = COPY $vgpr0_vgpr1 %1:_(s32) = G_TRUNC %0 %2:_(s64) = G_SEXT %1 diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-ashr.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-ashr.mir --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-ashr.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-ashr.mir @@ -124,15 +124,15 @@ liveins: $vgpr0, $vgpr1 ; SI-LABEL: name: test_ashr_s16_s32 - ; SI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; SI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 - ; SI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; SI: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; SI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) - ; SI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; SI: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[COPY1]](s32) - ; SI: [[COPY3:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) - ; SI: $vgpr0 = COPY [[COPY3]](s32) + ; SI-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; SI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 + ; SI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; SI-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; SI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) + ; SI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; SI-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[COPY1]](s32) + ; SI-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) + ; SI-DAG: $vgpr0 = COPY [[COPY3]](s32) ; VI-LABEL: name: test_ashr_s16_s32 ; VI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 @@ -162,18 +162,18 @@ liveins: $vgpr0, $vgpr1 ; SI-LABEL: name: test_ashr_s16_s16 - ; SI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; SI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 - ; SI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535 - ; SI: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; SI: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; SI: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; SI: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; SI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C1]](s32) - ; SI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; SI: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) - ; SI: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) - ; SI: $vgpr0 = COPY [[COPY4]](s32) + ; SI-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; SI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 + ; SI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535 + ; SI-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; SI-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; SI-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; SI-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; SI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C1]](s32) + ; SI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; SI-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) + ; SI-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) + ; SI-DAG: $vgpr0 = COPY [[COPY4]](s32) ; VI-LABEL: name: test_ashr_s16_s16 ; VI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 @@ -206,18 +206,18 @@ liveins: $vgpr0, $vgpr1 ; SI-LABEL: name: test_ashr_s16_i8 - ; SI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; SI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 - ; SI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; SI: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; SI: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; SI: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; SI: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; SI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C1]](s32) - ; SI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; SI: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) - ; SI: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) - ; SI: $vgpr0 = COPY [[COPY4]](s32) + ; SI-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; SI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 + ; SI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; SI-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; SI-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; SI-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; SI-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; SI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C1]](s32) + ; SI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; SI-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) + ; SI-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) + ; SI-DAG: $vgpr0 = COPY [[COPY4]](s32) ; VI-LABEL: name: test_ashr_s16_i8 ; VI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 @@ -258,50 +258,50 @@ liveins: $vgpr0, $vgpr1 ; SI-LABEL: name: test_ashr_i8_i8 - ; SI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; SI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 - ; SI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; SI: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; SI: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; SI: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; SI: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; SI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C1]](s32) - ; SI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; SI: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) - ; SI: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) - ; SI: $vgpr0 = COPY [[COPY4]](s32) + ; SI-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; SI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 + ; SI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; SI-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; SI-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; SI-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; SI-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; SI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C1]](s32) + ; SI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; SI-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[ASHR]], [[AND]](s32) + ; SI-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ASHR1]](s32) + ; SI-DAG: $vgpr0 = COPY [[COPY4]](s32) ; VI-LABEL: name: test_ashr_i8_i8 - ; VI: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 - ; VI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; VI: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; VI: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32) - ; VI: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[COPY3]] - ; VI: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[AND]](s32) - ; VI: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8 - ; VI: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[C1]](s32) - ; VI: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32) - ; VI: [[SHL:%[0-9]+]]:_(s16) = G_SHL [[TRUNC2]], [[TRUNC1]](s16) - ; VI: [[ASHR:%[0-9]+]]:_(s16) = G_ASHR [[SHL]], [[TRUNC1]](s16) - ; VI: [[ASHR1:%[0-9]+]]:_(s16) = G_ASHR [[ASHR]], [[TRUNC]](s16) - ; VI: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ASHR1]](s16) - ; VI: $vgpr0 = COPY [[ANYEXT]](s32) + ; VI-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; VI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 + ; VI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; VI-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; VI-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32) + ; VI-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[COPY3]] + ; VI-DAG: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[AND]](s32) + ; VI-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8 + ; VI-DAG: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[C1]](s32) + ; VI-DAG: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32) + ; VI-DAG: [[SHL:%[0-9]+]]:_(s16) = G_SHL [[TRUNC2]], [[TRUNC1]](s16) + ; VI-DAG: [[ASHR:%[0-9]+]]:_(s16) = G_ASHR [[SHL]], [[TRUNC1]](s16) + ; VI-DAG: [[ASHR1:%[0-9]+]]:_(s16) = G_ASHR [[ASHR]], [[TRUNC]](s16) + ; VI-DAG: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ASHR1]](s16) + ; VI-DAG: $vgpr0 = COPY [[ANYEXT]](s32) ; GFX9-LABEL: name: test_ashr_i8_i8 - ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; GFX9: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 - ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; GFX9: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; GFX9: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32) - ; GFX9: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[COPY3]] - ; GFX9: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[AND]](s32) - ; GFX9: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8 - ; GFX9: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[C1]](s32) - ; GFX9: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32) - ; GFX9: [[SHL:%[0-9]+]]:_(s16) = G_SHL [[TRUNC2]], [[TRUNC1]](s16) - ; GFX9: [[ASHR:%[0-9]+]]:_(s16) = G_ASHR [[SHL]], [[TRUNC1]](s16) - ; GFX9: [[ASHR1:%[0-9]+]]:_(s16) = G_ASHR [[ASHR]], [[TRUNC]](s16) - ; GFX9: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ASHR1]](s16) - ; GFX9: $vgpr0 = COPY [[ANYEXT]](s32) + ; GFX9-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; GFX9-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 + ; GFX9-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; GFX9-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; GFX9-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32) + ; GFX9-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[COPY3]] + ; GFX9-DAG: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[AND]](s32) + ; GFX9-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8 + ; GFX9-DAG: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[C1]](s32) + ; GFX9-DAG: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32) + ; GFX9-DAG: [[SHL:%[0-9]+]]:_(s16) = G_SHL [[TRUNC2]], [[TRUNC1]](s16) + ; GFX9-DAG: [[ASHR:%[0-9]+]]:_(s16) = G_ASHR [[SHL]], [[TRUNC1]](s16) + ; GFX9-DAG: [[ASHR1:%[0-9]+]]:_(s16) = G_ASHR [[ASHR]], [[TRUNC]](s16) + ; GFX9-DAG: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ASHR1]](s16) + ; GFX9-DAG: $vgpr0 = COPY [[ANYEXT]](s32) %0:_(s32) = COPY $vgpr0 %1:_(s32) = COPY $vgpr1 %2:_(s8) = G_TRUNC %0 diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract-vector-elt.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract-vector-elt.mir --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract-vector-elt.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract-vector-elt.mir @@ -187,19 +187,19 @@ bb.0: ; CHECK-LABEL: name: extract_vector_elt_0_v2i8_i32 - ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 - ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY [[DEF]](<2 x s32>) - ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C1]](s32) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C1]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C1]](s32) - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) - ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x s32>), [[C]](s32) - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[EVEC]](s32) - ; CHECK: $vgpr0 = COPY [[COPY1]](s32) + ; CHECK-DAG: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 + ; CHECK-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY [[DEF]](<2 x s32>) + ; CHECK-DAG: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C1]](s32) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C1]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C1]](s32) + ; CHECK-DAG: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) + ; CHECK-DAG: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x s32>), [[C]](s32) + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[EVEC]](s32) + ; CHECK-DAG: $vgpr0 = COPY [[COPY1]](s32) %0:_(<2 x s8>) = G_IMPLICIT_DEF %1:_(s32) = G_CONSTANT i32 0 %2:_(s8) = G_EXTRACT_VECTOR_ELT %0, %1 @@ -233,19 +233,19 @@ bb.0: ; CHECK-LABEL: name: extract_vector_elt_0_v2i1_i32 - ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 - ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 - ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY [[DEF]](<2 x s32>) - ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C1]](s32) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C1]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C1]](s32) - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) - ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x s32>), [[C]](s32) - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[EVEC]](s32) - ; CHECK: $vgpr0 = COPY [[COPY1]](s32) + ; CHECK-DAG: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 + ; CHECK-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY [[DEF]](<2 x s32>) + ; CHECK-DAG: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C1]](s32) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C1]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C1]](s32) + ; CHECK-DAG: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) + ; CHECK-DAG: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x s32>), [[C]](s32) + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[EVEC]](s32) + ; CHECK-DAG: $vgpr0 = COPY [[COPY1]](s32) %0:_(<2 x s1>) = G_IMPLICIT_DEF %1:_(s32) = G_CONSTANT i32 0 %2:_(s1) = G_EXTRACT_VECTOR_ELT %0, %1 @@ -260,20 +260,20 @@ bb.0: ; CHECK-LABEL: name: extract_vector_elt_0_v2i1_i1 - ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF - ; CHECK: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 false - ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 - ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY [[DEF]](<2 x s32>) - ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C1]](s32) - ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C1]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; CHECK: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C1]](s32) - ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) - ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[C]](s1) - ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x s32>), [[SEXT]](s32) - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[EVEC]](s32) - ; CHECK: $vgpr0 = COPY [[COPY1]](s32) + ; CHECK-DAG: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF + ; CHECK-DAG: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 false + ; CHECK-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY [[DEF]](<2 x s32>) + ; CHECK-DAG: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[UV]], [[C1]](s32) + ; CHECK-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[UV1]], [[C1]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; CHECK-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C1]](s32) + ; CHECK-DAG: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ASHR]](s32), [[ASHR1]](s32) + ; CHECK-DAG: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[C]](s1) + ; CHECK-DAG: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x s32>), [[SEXT]](s32) + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[EVEC]](s32) + ; CHECK-DAG: $vgpr0 = COPY [[COPY1]](s32) %0:_(<2 x s1>) = G_IMPLICIT_DEF %1:_(s1) = G_CONSTANT i1 false %2:_(s1) = G_EXTRACT_VECTOR_ELT %0, %1 diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sext.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sext.mir --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sext.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sext.mir @@ -23,14 +23,14 @@ liveins: $vgpr0 ; CHECK-LABEL: name: test_sext_s16_to_s64 - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48 - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s32) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[TRUNC]](s32) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC1]](s32) - ; CHECK: $vgpr0_vgpr1 = COPY [[ASHR]](s64) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48 + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s32) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[TRUNC]](s32) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC1]](s32) + ; CHECK-DAG: $vgpr0_vgpr1 = COPY [[ASHR]](s64) %0:_(s32) = COPY $vgpr0 %1:_(s16) = G_TRUNC %0 %2:_(s64) = G_SEXT %1 @@ -44,12 +44,12 @@ liveins: $vgpr0 ; CHECK-LABEL: name: test_sext_s16_to_s32 - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: $vgpr0 = COPY [[ASHR]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: $vgpr0 = COPY [[ASHR]](s32) %0:_(s32) = COPY $vgpr0 %1:_(s16) = G_TRUNC %0 %2:_(s32) = G_SEXT %1 @@ -63,12 +63,12 @@ liveins: $vgpr0 ; CHECK-LABEL: name: test_sext_i1_to_s32 - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; CHECK: $vgpr0 = COPY [[ASHR]](s32) + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 31 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; CHECK-DAG: $vgpr0 = COPY [[ASHR]](s32) %0:_(s32) = COPY $vgpr0 %1:_(s1) = G_TRUNC %0 %2:_(s32) = G_SEXT %1 diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-flat.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-flat.mir --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-flat.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-flat.mir @@ -12,13 +12,13 @@ ; SI: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p0) :: (load 1) ; SI: $vgpr0 = COPY [[SEXTLOAD]](s32) ; VI-LABEL: name: test_sextload_flat_i32_i8 - ; VI: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 - ; VI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 1) - ; VI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) - ; VI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; VI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; VI: $vgpr0 = COPY [[ASHR]](s32) + ; VI-DAG: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 + ; VI-DAG: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 1) + ; VI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; VI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) + ; VI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; VI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; VI-DAG: $vgpr0 = COPY [[ASHR]](s32) %0:_(p0) = COPY $vgpr0_vgpr1 %1:_(s32) = G_SEXTLOAD %0 :: (load 1, addrspace 0) $vgpr0 = COPY %1 @@ -34,13 +34,13 @@ ; SI: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p0) :: (load 2) ; SI: $vgpr0 = COPY [[SEXTLOAD]](s32) ; VI-LABEL: name: test_sextload_flat_i32_i16 - ; VI: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 - ; VI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 2) - ; VI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) - ; VI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; VI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; VI: $vgpr0 = COPY [[ASHR]](s32) + ; VI-DAG: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 + ; VI-DAG: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 2) + ; VI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; VI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) + ; VI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; VI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; VI-DAG: $vgpr0 = COPY [[ASHR]](s32) %0:_(p0) = COPY $vgpr0_vgpr1 %1:_(s32) = G_SEXTLOAD %0 :: (load 2, addrspace 0) $vgpr0 = COPY %1 @@ -57,14 +57,14 @@ ; SI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[SEXTLOAD]](s32) ; SI: $vgpr0 = COPY [[COPY1]](s32) ; VI-LABEL: name: test_sextload_flat_i31_i8 - ; VI: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 - ; VI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 1) - ; VI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) - ; VI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; VI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; VI: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ASHR]](s32) - ; VI: $vgpr0 = COPY [[COPY2]](s32) + ; VI-DAG: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 + ; VI-DAG: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 1) + ; VI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; VI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) + ; VI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; VI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; VI-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ASHR]](s32) + ; VI-DAG: $vgpr0 = COPY [[COPY2]](s32) %0:_(p0) = COPY $vgpr0_vgpr1 %1:_(s31) = G_SEXTLOAD %0 :: (load 1, addrspace 0) %2:_(s32) = G_ANYEXT %1 @@ -82,14 +82,14 @@ ; SI: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[SEXTLOAD]](s32) ; SI: $vgpr0_vgpr1 = COPY [[SEXT]](s64) ; VI-LABEL: name: test_sextload_flat_i64_i8 - ; VI: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 - ; VI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 1) - ; VI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) - ; VI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; VI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; VI: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[ASHR]](s32) - ; VI: $vgpr0_vgpr1 = COPY [[SEXT]](s64) + ; VI-DAG: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 + ; VI-DAG: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 1) + ; VI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; VI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) + ; VI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; VI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; VI-DAG: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[ASHR]](s32) + ; VI-DAG: $vgpr0_vgpr1 = COPY [[SEXT]](s64) %0:_(p0) = COPY $vgpr0_vgpr1 %1:_(s64) = G_SEXTLOAD %0 :: (load 1, addrspace 0) $vgpr0_vgpr1 = COPY %1 @@ -106,14 +106,14 @@ ; SI: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[SEXTLOAD]](s32) ; SI: $vgpr0_vgpr1 = COPY [[SEXT]](s64) ; VI-LABEL: name: test_sextload_flat_i64_i16 - ; VI: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 - ; VI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 2) - ; VI: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; VI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) - ; VI: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) - ; VI: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; VI: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[ASHR]](s32) - ; VI: $vgpr0_vgpr1 = COPY [[SEXT]](s64) + ; VI-DAG: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1 + ; VI-DAG: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 2) + ; VI-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; VI-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32) + ; VI-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[C]](s32) + ; VI-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; VI-DAG: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[ASHR]](s32) + ; VI-DAG: $vgpr0_vgpr1 = COPY [[SEXT]](s64) %0:_(p0) = COPY $vgpr0_vgpr1 %1:_(s64) = G_SEXTLOAD %0 :: (load 2, addrspace 0) $vgpr0_vgpr1 = COPY %1 diff --git a/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-divmod.mir b/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-divmod.mir --- a/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-divmod.mir +++ b/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-divmod.mir @@ -122,13 +122,13 @@ ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1 ; The G_TRUNC will combine with the extensions introduced by the legalizer, ; leading to the following complicated sequences. - ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] - ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] - ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] - ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] - ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] - ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] + ; CHECK-DAG: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] + ; CHECK-DAG: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] + ; CHECK-DAG: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] + ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] + ; CHECK-DAG: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] + ; CHECK-DAG: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] %0(s32) = COPY $r0 %1(s16) = G_TRUNC %0(s32) %2(s32) = COPY $r1 @@ -228,13 +228,13 @@ ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1 ; The G_TRUNC will combine with the extensions introduced by the legalizer, ; leading to the following complicated sequences. - ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] - ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] - ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] - ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] - ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] - ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] + ; CHECK-DAG: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] + ; CHECK-DAG: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] + ; CHECK-DAG: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] + ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] + ; CHECK-DAG: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] + ; CHECK-DAG: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] %0(s32) = COPY $r0 %1(s8) = G_TRUNC %0(s32) %2(s32) = COPY $r1 @@ -414,13 +414,13 @@ ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1 ; The G_TRUNC will combine with the extensions introduced by the legalizer, ; leading to the following complicated sequences. - ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] - ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] - ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] - ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] - ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] - ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] + ; CHECK-DAG: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] + ; CHECK-DAG: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] + ; CHECK-DAG: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] + ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] + ; CHECK-DAG: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] + ; CHECK-DAG: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] %0(s32) = COPY $r0 %1(s16) = G_TRUNC %0(s32) %2(s32) = COPY $r1 @@ -526,13 +526,13 @@ ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1 ; The G_TRUNC will combine with the extensions introduced by the legalizer, ; leading to the following complicated sequences. - ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] - ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] - ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] - ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] - ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] - ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] + ; CHECK-DAG: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY [[R0]] + ; CHECK-DAG: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]] + ; CHECK-DAG: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]] + ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]] + ; CHECK-DAG: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]] + ; CHECK-DAG: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]] %0(s32) = COPY $r0 %1(s8) = G_TRUNC %0(s32) %2(s32) = COPY $r1 diff --git a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/add.mir b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/add.mir --- a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/add.mir +++ b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/add.mir @@ -46,17 +46,17 @@ ; MIPS32-LABEL: name: add_i8_sext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]] - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ADD]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ADD]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -135,17 +135,17 @@ ; MIPS32-LABEL: name: add_i16_sext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]] - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ADD]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ADD]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 diff --git a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/constants.mir b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/constants.mir --- a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/constants.mir +++ b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/constants.mir @@ -53,13 +53,13 @@ body: | bb.1.entry: ; MIPS32-LABEL: name: signed_i16 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -32768 - ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY [[C]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C1]] - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]] - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -32768 + ; MIPS32-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY [[C]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C1]] + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]] + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %0:_(s16) = G_CONSTANT i16 -32768 %1:_(s32) = G_SEXT %0(s16) $v0 = COPY %1(s32) @@ -73,13 +73,13 @@ body: | bb.1.entry: ; MIPS32-LABEL: name: signed_i8 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -128 - ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY [[C]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C1]] - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]] - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -128 + ; MIPS32-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY [[C]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C1]] + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]] + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %0:_(s8) = G_CONSTANT i8 -128 %1:_(s32) = G_SEXT %0(s8) $v0 = COPY %1(s32) diff --git a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/mul.mir b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/mul.mir --- a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/mul.mir +++ b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/mul.mir @@ -47,17 +47,17 @@ ; MIPS32-LABEL: name: mul_i8_sext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY2]], [[COPY3]] - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[MUL]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[MUL]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -136,17 +136,17 @@ ; MIPS32-LABEL: name: mul_i16_sext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY2]], [[COPY3]] - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[MUL]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[MUL]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 diff --git a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/rem_and_div.mir b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/rem_and_div.mir --- a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/rem_and_div.mir +++ b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/rem_and_div.mir @@ -30,21 +30,21 @@ ; MIPS32-LABEL: name: sdiv_i8 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) - ; MIPS32: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; MIPS32: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) - ; MIPS32: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR2]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) + ; MIPS32-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; MIPS32-DAG: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) + ; MIPS32-DAG: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR2]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -65,21 +65,21 @@ ; MIPS32-LABEL: name: sdiv_i16 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) - ; MIPS32: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; MIPS32: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) - ; MIPS32: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR2]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) + ; MIPS32-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; MIPS32-DAG: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[ASHR]], [[ASHR1]] + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SDIV]](s32) + ; MIPS32-DAG: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR2]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -161,21 +161,21 @@ ; MIPS32-LABEL: name: srem_i8 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) - ; MIPS32: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; MIPS32: [[SREM:%[0-9]+]]:_(s32) = G_SREM [[ASHR]], [[ASHR1]] - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SREM]](s32) - ; MIPS32: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR2]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) + ; MIPS32-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; MIPS32-DAG: [[SREM:%[0-9]+]]:_(s32) = G_SREM [[ASHR]], [[ASHR1]] + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SREM]](s32) + ; MIPS32-DAG: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR2]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -196,21 +196,21 @@ ; MIPS32-LABEL: name: srem_i16 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) - ; MIPS32: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) - ; MIPS32: [[SREM:%[0-9]+]]:_(s32) = G_SREM [[ASHR]], [[ASHR1]] - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SREM]](s32) - ; MIPS32: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR2]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY2]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[COPY3]], [[C]](s32) + ; MIPS32-DAG: [[ASHR1:%[0-9]+]]:_(s32) = G_ASHR [[SHL1]], [[C]](s32) + ; MIPS32-DAG: [[SREM:%[0-9]+]]:_(s32) = G_SREM [[ASHR]], [[ASHR1]] + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SREM]](s32) + ; MIPS32-DAG: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR2:%[0-9]+]]:_(s32) = G_ASHR [[SHL2]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR2]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -292,20 +292,20 @@ ; MIPS32-LABEL: name: udiv_i8 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] - ; MIPS32: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] - ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UDIV]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] + ; MIPS32-DAG: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] + ; MIPS32-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UDIV]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -326,20 +326,20 @@ ; MIPS32-LABEL: name: udiv_i16 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] - ; MIPS32: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] - ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UDIV]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] + ; MIPS32-DAG: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]] + ; MIPS32-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UDIV]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -421,20 +421,20 @@ ; MIPS32-LABEL: name: urem_i8 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] - ; MIPS32: [[UREM:%[0-9]+]]:_(s32) = G_UREM [[AND]], [[AND1]] - ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UREM]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] + ; MIPS32-DAG: [[UREM:%[0-9]+]]:_(s32) = G_UREM [[AND]], [[AND1]] + ; MIPS32-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UREM]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -455,20 +455,20 @@ ; MIPS32-LABEL: name: urem_i16 ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] - ; MIPS32: [[UREM:%[0-9]+]]:_(s32) = G_UREM [[AND]], [[AND1]] - ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UREM]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]] + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]] + ; MIPS32-DAG: [[UREM:%[0-9]+]]:_(s32) = G_UREM [[AND]], [[AND1]] + ; MIPS32-DAG: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[UREM]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C1]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C1]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 diff --git a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/sub.mir b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/sub.mir --- a/llvm/test/CodeGen/Mips/GlobalISel/legalizer/sub.mir +++ b/llvm/test/CodeGen/Mips/GlobalISel/legalizer/sub.mir @@ -45,17 +45,17 @@ ; MIPS32-LABEL: name: sub_i8_sext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]] - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -106,14 +106,14 @@ ; MIPS32-LABEL: name: sub_i8_aext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]] - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) - ; MIPS32: $v0 = COPY [[COPY4]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) + ; MIPS32-DAG: $v0 = COPY [[COPY4]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s8) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 @@ -134,17 +134,17 @@ ; MIPS32-LABEL: name: sub_i16_sext ; MIPS32: liveins: $a0, $a1 - ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 - ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 - ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) - ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]] - ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) - ; MIPS32: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) - ; MIPS32: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) - ; MIPS32: $v0 = COPY [[ASHR]](s32) - ; MIPS32: RetRA implicit $v0 + ; MIPS32-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $a0 + ; MIPS32-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1 + ; MIPS32-DAG: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32) + ; MIPS32-DAG: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; MIPS32-DAG: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY2]], [[COPY3]] + ; MIPS32-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; MIPS32-DAG: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SUB]](s32) + ; MIPS32-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY4]], [[C]](s32) + ; MIPS32-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[C]](s32) + ; MIPS32-DAG: $v0 = COPY [[ASHR]](s32) + ; MIPS32: RetRA implicit $v0 %2:_(s32) = COPY $a0 %0:_(s16) = G_TRUNC %2(s32) %3:_(s32) = COPY $a1 diff --git a/llvm/test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir b/llvm/test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir --- a/llvm/test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir +++ b/llvm/test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir @@ -76,15 +76,15 @@ liveins: $edi ; CHECK-LABEL: name: test_sext_i1 - ; CHECK: [[COPY:%[0-9]+]]:_(s8) = COPY $dil - ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s8) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s64) - ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[TRUNC]](s8) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s64) - ; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC1]](s8) - ; CHECK: $rax = COPY [[ASHR]](s64) - ; CHECK: RET 0, implicit $rax + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s8) = COPY $dil + ; CHECK-DAG: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 63 + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s8) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ANYEXT]], [[TRUNC]](s8) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s64) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[TRUNC1]](s8) + ; CHECK-DAG: $rax = COPY [[ASHR]](s64) + ; CHECK: RET 0, implicit $rax %0(s8) = COPY $dil %1(s1) = G_TRUNC %0(s8) %2(s64) = G_SEXT %1(s1) diff --git a/llvm/test/CodeGen/X86/GlobalISel/x86_64-legalize-sitofp.mir b/llvm/test/CodeGen/X86/GlobalISel/x86_64-legalize-sitofp.mir --- a/llvm/test/CodeGen/X86/GlobalISel/x86_64-legalize-sitofp.mir +++ b/llvm/test/CodeGen/X86/GlobalISel/x86_64-legalize-sitofp.mir @@ -87,17 +87,17 @@ ; CHECK-LABEL: name: int8_to_float ; CHECK: liveins: $edi - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s32) - ; CHECK: $xmm0 = COPY [[ANYEXT]](s128) - ; CHECK: RET 0, implicit $xmm0 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $edi + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s32) + ; CHECK-DAG: $xmm0 = COPY [[ANYEXT]](s128) + ; CHECK: RET 0, implicit $xmm0 %1:_(s32) = COPY $edi %0:_(s8) = G_TRUNC %1(s32) %2:_(s32) = G_SITOFP %0(s8) @@ -121,17 +121,17 @@ ; CHECK-LABEL: name: int16_to_float ; CHECK: liveins: $edi - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s32) - ; CHECK: $xmm0 = COPY [[ANYEXT]](s128) - ; CHECK: RET 0, implicit $xmm0 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $edi + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s32) + ; CHECK-DAG: $xmm0 = COPY [[ANYEXT]](s128) + ; CHECK: RET 0, implicit $xmm0 %1:_(s32) = COPY $edi %0:_(s16) = G_TRUNC %1(s32) %2:_(s32) = G_SITOFP %0(s16) @@ -207,17 +207,17 @@ ; CHECK-LABEL: name: int8_to_double ; CHECK: liveins: $edi - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[ASHR]](s32) - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s64) - ; CHECK: $xmm0 = COPY [[ANYEXT]](s128) - ; CHECK: RET 0, implicit $xmm0 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $edi + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s64) + ; CHECK-DAG: $xmm0 = COPY [[ANYEXT]](s128) + ; CHECK: RET 0, implicit $xmm0 %1:_(s32) = COPY $edi %0:_(s8) = G_TRUNC %1(s32) %2:_(s64) = G_SITOFP %0(s8) @@ -241,17 +241,17 @@ ; CHECK-LABEL: name: int16_to_double ; CHECK: liveins: $edi - ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi - ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 - ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) - ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) - ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) - ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) - ; CHECK: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[ASHR]](s32) - ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s64) - ; CHECK: $xmm0 = COPY [[ANYEXT]](s128) - ; CHECK: RET 0, implicit $xmm0 + ; CHECK-DAG: [[COPY:%[0-9]+]]:_(s32) = COPY $edi + ; CHECK-DAG: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 + ; CHECK-DAG: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32) + ; CHECK-DAG: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY1]], [[TRUNC]](s8) + ; CHECK-DAG: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[C]](s32) + ; CHECK-DAG: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[TRUNC1]](s8) + ; CHECK-DAG: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[ASHR]](s32) + ; CHECK-DAG: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[SITOFP]](s64) + ; CHECK-DAG: $xmm0 = COPY [[ANYEXT]](s128) + ; CHECK: RET 0, implicit $xmm0 %1:_(s32) = COPY $edi %0:_(s16) = G_TRUNC %1(s32) %2:_(s64) = G_SITOFP %0(s16) diff --git a/llvm/test/MachineVerifier/test_g_sext_inreg.mir b/llvm/test/MachineVerifier/test_g_sext_inreg.mir new file mode 100644 --- /dev/null +++ b/llvm/test/MachineVerifier/test_g_sext_inreg.mir @@ -0,0 +1,53 @@ +# RUN: not llc -verify-machineinstrs -run-pass none -o /dev/null %s 2>&1 | FileCheck %s + +--- | + + target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" + target triple = "aarch64--" + define void @test() { ret void } + +... + +--- +name: test +registers: + - { id: 0, class: gpr } + - { id: 1, class: gpr } + - { id: 2, class: gpr } + - { id: 3, class: gpr } + - { id: 4, class: gpr } + - { id: 5, class: gpr } + - { id: 6, class: gpr } + - { id: 7, class: gpr } +body: | + bb.0: + liveins: $x0 + %0(s64) = COPY $x0 + %1(<4 x s16>) = COPY $x0 + + ; CHECK: *** Bad machine code: G_SEXT_INREG expects an immediate operand #2 *** + ; CHECK: instruction: %2:gpr(s64) = G_SEXT_INREG + %2(s64) = G_SEXT_INREG %0, %0 + + ; CHECK: *** Bad machine code: G_SEXT_INREG expects an immediate operand #2 *** + ; CHECK: instruction: %3:gpr(s64) = G_SEXT_INREG + %3(s64) = G_SEXT_INREG %0, i8 8 + + ; CHECK: *** Bad machine code: Type mismatch in generic instruction *** + ; CHECK: instruction: %4:gpr(<2 x s32>) = G_SEXT_INREG + ; CHECK: *** Bad machine code: operand types must be all-vector or all-scalar *** + ; CHECK: instruction: %4:gpr(<2 x s32>) = G_SEXT_INREG + %4(<2 x s32>) = G_SEXT_INREG %0, 8 + + ; CHECK: *** Bad machine code: operand types must preserve number of vector elements *** + ; CHECK: instruction: %5:gpr(<2 x s32>) = G_SEXT_INREG + %5(<2 x s32>) = G_SEXT_INREG %1, 8 + + ; CHECK: *** Bad machine code: G_SEXT_INREG size must be >= 1 *** + ; CHECK: instruction: %6:gpr(s64) = G_SEXT_INREG + %6(s64) = G_SEXT_INREG %0, 0 + + ; CHECK: *** Bad machine code: G_SEXT_INREG size must be less than source bit width *** + ; CHECK: instruction: %7:gpr(s64) = G_SEXT_INREG + %7(s64) = G_SEXT_INREG %0, 128 +... diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp --- a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp +++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp @@ -729,4 +729,130 @@ EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF; } + +TEST_F(GISelMITest, WidenSEXTINREG) { + if (!TM) + return; + + // Declare your legalization info + DefineLegalizerInfo( + A, { getActionDefinitionsBuilder(G_SEXT_INREG).legalFor({s64}); }); + // Build Instr + auto MIB = B.buildInstr( + TargetOpcode::G_SEXT_INREG, {LLT::scalar(32)}, + {B.buildInstr(TargetOpcode::G_TRUNC, {LLT::scalar(32)}, {Copies[0]}), + APInt(32, 8)}); + AInfo Info(MF->getSubtarget()); + DummyGISelObserver Observer; + LegalizerHelper Helper(*MF, Info, Observer, B); + // Perform Legalization + ASSERT_TRUE(Helper.widenScalar(*MIB, 0, LLT::scalar(64)) == + LegalizerHelper::LegalizeResult::Legalized); + + auto CheckStr = R"( + CHECK: [[T0:%[0-9]+]]:_(s32) = G_TRUNC + CHECK: [[T1:%[0-9]+]]:_(s64) = G_ANYEXT [[T0]]:_(s32) + CHECK: [[T2:%[0-9]+]]:_(s64) = G_SEXT_INREG [[T1]]:_, 8 + CHECK: [[T3:%[0-9]+]]:_(s32) = G_TRUNC [[T2]]:_(s64) + )"; + + // Check + ASSERT_TRUE(CheckMachineFunction(*MF, CheckStr)); +} + +TEST_F(GISelMITest, NarrowSEXTINREG) { + if (!TM) + return; + + // Declare your legalization info, these aren't actually relevant to the test. + DefineLegalizerInfo( + A, { getActionDefinitionsBuilder(G_SEXT_INREG).legalFor({s64}); }); + // Build Instr + auto MIB = B.buildInstr( + TargetOpcode::G_SEXT_INREG, {LLT::scalar(16)}, + {B.buildInstr(TargetOpcode::G_TRUNC, {LLT::scalar(16)}, {Copies[0]}), + APInt(16, 8)}); + MIB->getParent()->dump(); + AInfo Info(MF->getSubtarget()); + DummyGISelObserver Observer; + LegalizerHelper Helper(*MF, Info, Observer, B); + // Perform Legalization + ASSERT_TRUE(Helper.narrowScalar(*MIB, 0, LLT::scalar(10)) == + LegalizerHelper::LegalizeResult::Legalized); + MIB->getParent()->dump(); + + auto CheckStr = R"( + CHECK: [[T0:%[0-9]+]]:_(s16) = G_TRUNC + CHECK: [[T1:%[0-9]+]]:_(s10) = G_TRUNC [[T0]]:_(s16) + CHECK: [[T2:%[0-9]+]]:_(s10) = G_SEXT_INREG [[T1]]:_, 8 + CHECK: [[T3:%[0-9]+]]:_(s16) = G_SEXT [[T2]]:_(s10) + )"; + + // Check + ASSERT_TRUE(CheckMachineFunction(*MF, CheckStr)); +} + +TEST_F(GISelMITest, NarrowSEXTINREG2) { + if (!TM) + return; + + // Declare your legalization info, these aren't actually relevant to the test. + DefineLegalizerInfo( + A, { getActionDefinitionsBuilder(G_SEXT_INREG).legalFor({s64}); }); + // Build Instr + auto MIB = B.buildInstr( + TargetOpcode::G_SEXT_INREG, {LLT::scalar(32)}, + {B.buildInstr(TargetOpcode::G_TRUNC, {LLT::scalar(32)}, {Copies[0]}), + APInt(32, 9)}); + AInfo Info(MF->getSubtarget()); + DummyGISelObserver Observer; + LegalizerHelper Helper(*MF, Info, Observer, B); + // Perform Legalization + ASSERT_TRUE(Helper.narrowScalar(*MIB, 0, LLT::scalar(8)) == + LegalizerHelper::LegalizeResult::Legalized); + MF->dump(); + + auto CheckStr = R"( + CHECK: [[T0:%[0-9]+]]:_(s32) = G_TRUNC + CHECK: [[T1:%[0-9]+]]:_(s8), [[T2:%[0-9]+]]:_(s8), [[T3:%[0-9]+]]:_(s8), [[T4:%[0-9]+]]:_(s8) = G_UNMERGE_VALUES [[T0]]:_(s32) + CHECK: [[CST2:%[0-9]+]]:_(s8) = G_CONSTANT i8 7 + CHECK: [[T5:%[0-9]+]]:_(s8) = G_SEXT_INREG [[T2]]:_, 1 + CHECK: [[T6:%[0-9]+]]:_(s8) = G_ASHR [[T5]]:_, [[CST2]]:_ + CHECK: [[T7:%[0-9]+]]:_(s32) = G_MERGE_VALUES [[T1]]:_(s8), [[T5]]:_(s8), [[T6]]:_(s8), [[T6]]:_(s8) + )"; + + // Check + ASSERT_TRUE(CheckMachineFunction(*MF, CheckStr)); +} + +TEST_F(GISelMITest, LowerSEXTINREG) { + if (!TM) + return; + + // Declare your legalization info, these aren't actually relevant to the test. + DefineLegalizerInfo( + A, { getActionDefinitionsBuilder(G_SEXT_INREG).legalFor({s64}); }); + // Build Instr + auto MIB = B.buildInstr( + TargetOpcode::G_SEXT_INREG, {LLT::scalar(32)}, + {B.buildInstr(TargetOpcode::G_TRUNC, {LLT::scalar(32)}, {Copies[0]}), + APInt(32, 8)}); + AInfo Info(MF->getSubtarget()); + DummyGISelObserver Observer; + LegalizerHelper Helper(*MF, Info, Observer, B); + // Perform Legalization + ASSERT_TRUE(Helper.lower(*MIB, 0, LLT()) == + LegalizerHelper::LegalizeResult::Legalized); + MF->dump(); + + auto CheckStr = R"( + CHECK: [[T1:%[0-9]+]]:_(s32) = G_TRUNC + CHECK: [[CST:%[0-9]+]]:_(s32) = G_CONSTANT i32 24 + CHECK: [[T2:%[0-9]+]]:_(s32) = G_SHL [[T1]]:_, [[CST]]:_ + CHECK: [[T3:%[0-9]+]]:_(s32) = G_ASHR [[T2]]:_, [[CST]]:_ + )"; + + // Check + ASSERT_TRUE(CheckMachineFunction(*MF, CheckStr)); +} } // namespace diff --git a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp --- a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp +++ b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp @@ -266,6 +266,22 @@ match = mi_match(MIBCSub->getOperand(0).getReg(), MRI, m_ICst(Cst)); EXPECT_TRUE(match); EXPECT_EQ(Cst, 0); + + auto MIBCSext1 = + CFB1.buildInstr(TargetOpcode::G_SEXT_INREG, {s32}, + {CFB1.buildConstant(s32, 0x01), APInt(32, 8)}); + // This should be a constant now. + match = mi_match(MIBCSext1->getOperand(0).getReg(), MRI, m_ICst(Cst)); + EXPECT_TRUE(match); + EXPECT_EQ(Cst, 1); + + auto MIBCSext2 = CFB1.buildInstr( + TargetOpcode::G_SEXT_INREG, {s32}, + {CFB1.buildConstant(s32, 0x80), APInt(32, 8)}); + // This should be a constant now. + match = mi_match(MIBCSext2->getOperand(0).getReg(), MRI, m_ICst(Cst)); + EXPECT_TRUE(match); + EXPECT_EQ(Cst, -0x80); } TEST(PatternMatchInstr, MatchFPUnaryOp) {