diff --git a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp --- a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp +++ b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp @@ -45,13 +45,27 @@ getRegClassForTypeOnBank(LLT Ty, const RegisterBank &RB, bool GetAllRegSet = false) const; + // tblgen-erated 'select' implementation, used as the initial selector for + // the patterns that don't require complex C++. bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const; + + // A lowering phase that runs before any selection attempts. + // Returns true if the instruction was modified. + bool preISelLower(MachineInstr &MI, MachineIRBuilder &MIB, + MachineRegisterInfo &MRI) const; + + // Custom selection methods bool selectCopy(MachineInstr &MI, MachineRegisterInfo &MRI) const; bool selectConstant(MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI) const; ComplexRendererFns selectS32ShiftMask(MachineOperand &Root) const; + void renderNegImm(MachineInstrBuilder &MIB, const MachineInstr &MI, + int OpIdx) const; + void renderImmPlus1(MachineInstrBuilder &MIB, const MachineInstr &MI, + int OpIdx) const; + const RISCVSubtarget &STI; const RISCVInstrInfo &TII; const RISCVRegisterInfo &TRI; @@ -107,6 +121,10 @@ MachineFunction &MF = *MBB.getParent(); MachineRegisterInfo &MRI = MF.getRegInfo(); MachineIRBuilder MIB(MF); + MIB.setInstrAndDebugLoc(MI); + + if (preISelLower(MI, MIB, MRI)) + Opc = MI.getOpcode(); if (!isPreISelGenericOpcode(Opc)) { // Certain non-generic instructions also need some special handling. @@ -119,8 +137,6 @@ if (selectImpl(MI, *CoverageInfo)) return true; - MIB.setInstrAndDebugLoc(MI); - switch (Opc) { case TargetOpcode::G_ANYEXT: case TargetOpcode::G_TRUNC: @@ -139,6 +155,74 @@ return true; } +bool RISCVInstructionSelector::preISelLower(MachineInstr &MI, + MachineIRBuilder &MIB, + MachineRegisterInfo &MRI) const { + unsigned Opc = MI.getOpcode(); + + switch (Opc) { + case TargetOpcode::G_ICMP: { + // FIXME: We need this custom lowering code since we can't match this + // pattern in tablegen, since the register is named and can't be dead. + // But it's strange to have only this case here. + unsigned Pred = MI.getOperand(1).getPredicate(); + Register SrcReg2 = MI.getOperand(3).getReg(); + + bool HasImm = false; + int64_t Imm; + const MachineInstr *Src2 = MRI.getVRegDef(SrcReg2); + if (Src2->getOpcode() == TargetOpcode::G_CONSTANT) { + Imm = Src2->getOperand(1).getCImm()->getSExtValue(); + HasImm = (Imm >= -2049 && Imm < 0) || (Imm > 0 && Imm <= 2046); + } + + switch (Pred) { + case CmpInst::Predicate::ICMP_UGT: + case CmpInst::Predicate::ICMP_SGT: { + bool IsSigned = Pred == CmpInst::Predicate::ICMP_SGT; + Pred = IsSigned? CmpInst::Predicate::ICMP_SLT : CmpInst::Predicate::ICMP_ULT; + + if (!IsSigned && HasImm && Imm == -1) { + MI.removeOperand(3); + MI.removeOperand(2); + MI.removeOperand(1); + MI.setDesc(TII.get(TargetOpcode::COPY)); + MI.addOperand(MachineOperand::CreateReg(RISCV::X0, false)); + return true; + } + + return false; + } + default: + return false; + } + break; + } + default: + return false; + } + + return true; +} + +void RISCVInstructionSelector::renderNegImm(MachineInstrBuilder &MIB, + const MachineInstr &MI, + int OpIdx) const { + assert(MI.getOpcode() == TargetOpcode::G_CONSTANT && OpIdx == -1 && + "Expected G_CONSTANT"); + int64_t CstVal = MI.getOperand(1).getCImm()->getSExtValue(); + MIB.addImm(-CstVal); +} + +void RISCVInstructionSelector::renderImmPlus1(MachineInstrBuilder &MIB, + const MachineInstr &MI, + int OpIdx) const { + assert(MI.getOpcode() == TargetOpcode::G_CONSTANT && OpIdx == -1 && + "Expected G_CONSTANT"); + int64_t CstVal = MI.getOperand(1).getCImm()->getSExtValue(); + MIB.addImm(CstVal + 1); +} + const TargetRegisterClass *RISCVInstructionSelector::getRegClassForTypeOnBank( LLT Ty, const RegisterBank &RB, bool GetAllRegSet) const { if (RB.getID() == RISCV::GPRRegBankID) { diff --git a/llvm/lib/Target/RISCV/RISCVGISel.td b/llvm/lib/Target/RISCV/RISCVGISel.td --- a/llvm/lib/Target/RISCV/RISCVGISel.td +++ b/llvm/lib/Target/RISCV/RISCVGISel.td @@ -15,6 +15,25 @@ include "RISCV.td" +def simm12Plus1 : ImmLeaf(Imm) && Imm != -2048) || Imm == 2048;}]>; + +// FIXME: This doesn't check that the G_CONSTANT we're deriving the immediate +// from is only used once +def simm12Minus1Nonzero : ImmLeaf 0 && Imm <= 2046);}]>; + +// Return an immediate value plus 1. +def ImmPlus1 : SDNodeXFormgetTargetConstant(N->getSExtValue() + 1, SDLoc(N), + N->getValueType(0));}]>; + +def GINegImm : GICustomOperandRenderer<"renderNegImm">, + GISDNodeXFormEquiv; + +def GIImmPlus1 : GICustomOperandRenderer<"renderImmPlus1">, + GISDNodeXFormEquiv; + // FIXME: This is labelled as handling 's32', however the ComplexPattern it // refers to handles both i32 and i64 based on the HwMode. Currently this LLT // parameter appears to be ignored so this pattern works for both, however we @@ -43,3 +62,33 @@ def : Pat<(i32 (udiv GPR:$rs1, GPR:$rs2)), (DIVUW GPR:$rs1, GPR:$rs2)>; def : Pat<(i32 (urem GPR:$rs1, GPR:$rs2)), (REMUW GPR:$rs1, GPR:$rs2)>; } + +// Define pattern expansions for setcc operations that aren't directly +// handled by a RISC-V instruction. +// FIXME: Handle the immediate cases +def : Pat<(XLenVT (seteq (XLenVT GPR:$rs1), 0)), (SLTIU GPR:$rs1, 1)>; +def : Pat<(XLenVT (seteq (XLenVT GPR:$rs1), simm12Plus1:$imm12)), + (SLTIU (ADDI GPR:$rs1, (NegImm simm12Plus1:$imm12)), 1)>; +def : Pat<(XLenVT (seteq (XLenVT GPR:$rs1), GPR:$rs2)), + (SLTIU (XOR GPR:$rs1, GPR:$rs2), 1)>; +def : Pat<(XLenVT (setne (XLenVT GPR:$rs1), 0)), (SLTU (XLenVT X0), GPR:$rs1)>; +def : Pat<(XLenVT (setne (XLenVT GPR:$rs1), GPR:$rs2)), + (SLTU (XLenVT X0), (XOR GPR:$rs1, GPR:$rs2))>; +def : Pat<(XLenVT (setne (XLenVT GPR:$rs1), simm12Plus1:$imm12)), + (SLTU (XLenVT X0), (ADDI GPR:$rs1, (NegImm simm12Plus1:$imm12)))>; +def : Pat<(XLenVT (setugt (XLenVT GPR:$rs1), GPR:$rs2)), + (SLTU GPR:$rs2, GPR:$rs1)>; +def : Pat<(XLenVT (setuge (XLenVT GPR:$rs1), GPR:$rs2)), + (XORI (SLTU GPR:$rs1, GPR:$rs2), 1)>; +def : Pat<(XLenVT (setule (XLenVT GPR:$rs1), GPR:$rs2)), + (XORI (SLTU GPR:$rs2, GPR:$rs1), 1)>; +def : Pat<(XLenVT (setgt (XLenVT GPR:$rs1), GPR:$rs2)), + (SLT GPR:$rs2, GPR:$rs1)>; +def : Pat<(XLenVT (setge (XLenVT GPR:$rs1), GPR:$rs2)), + (XORI (SLT GPR:$rs1, GPR:$rs2), 1)>; +def : Pat<(XLenVT (setle (XLenVT GPR:$rs1), GPR:$rs2)), + (XORI (SLT GPR:$rs2, GPR:$rs1), 1)>; +def : Pat<(XLenVT (setgt (XLenVT GPR:$rs1), simm12Minus1Nonzero:$imm)), + (XORI (SLTI GPR:$rs1, (ImmPlus1 simm12Minus1Nonzero:$imm)), 1)>; +def : Pat<(XLenVT (setugt (XLenVT GPR:$rs1), simm12Minus1Nonzero:$imm)), + (XORI (SLTIU GPR:$rs1, (ImmPlus1 simm12Minus1Nonzero:$imm)), 1)>; diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp32.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp32.mir @@ -0,0 +1,559 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -march=riscv32 -run-pass=instruction-select -simplify-mir -verify-machineinstrs %s -o - \ +# RUN: | FileCheck -check-prefix=RV32I %s +--- +name: cmp_ult_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ult_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[COPY1]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(ult), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_slt_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_slt_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY]], [[COPY1]] + ; RV32I-NEXT: $x10 = COPY [[SLT]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(slt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugt_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ugt_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY1]], [[COPY]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(ugt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_sgt_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_sgt_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY1]], [[COPY]] + ; RV32I-NEXT: $x10 = COPY [[SLT]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(sgt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_eq_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_eq_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[XOR:%[0-9]+]]:gpr = XOR [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[XOR]], 1 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(eq), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ne_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ne_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[XOR:%[0-9]+]]:gpr = XOR [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[XOR]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(ne), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ule_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ule_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY1]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(ule), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_sle_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_sle_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY1]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(sle), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_uge_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_uge_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(uge), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_sge_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_sge_i32 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = COPY $x11 + %2:gprb(s32) = G_ICMP intpred(sge), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ulti_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ulti_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[COPY]], 10 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(ult), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_slti_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_slti_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTI:%[0-9]+]]:gpr = SLTI [[COPY]], 10 + ; RV32I-NEXT: $x10 = COPY [[SLTI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(slt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugti_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ugti_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[COPY]], 11 + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTIU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(ugt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_sgti_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_sgti_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTI:%[0-9]+]]:gpr = SLTI [[COPY]], 11 + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTI]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(sgt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_eqi_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_eqi_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], -10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[ADDI]], 1 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(eq), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_nei_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_nei_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], -10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ADDI]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(ne), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ulei_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ulei_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[ADDI]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(ule), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_slei_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_slei_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[ADDI]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(sle), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugei_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ugei_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[ADDI]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(uge), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_sgei_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_sgei_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY]], [[ADDI]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 10 + %2:gprb(s32) = G_ICMP intpred(sge), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_eq0_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_eq0_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[COPY]], 1 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 0 + %2:gprb(s32) = G_ICMP intpred(eq), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ne0_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ne0_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[COPY]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 0 + %2:gprb(s32) = G_ICMP intpred(ne), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugt_neg1_i32 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ugt_neg1_i32 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x0 + ; RV32I-NEXT: $x10 = COPY [[COPY]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s32) = COPY $x10 + %1:gprb(s32) = G_CONSTANT i32 -1 + %2:gprb(s32) = G_ICMP intpred(ugt), %0, %1 + $x10 = COPY %2(s32) + PseudoRET implicit $x10 + +... diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp64.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp64.mir @@ -0,0 +1,560 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -march=riscv64 -run-pass=instruction-select -simplify-mir -verify-machineinstrs %s -o - \ +# RUN: | FileCheck -check-prefix=RV32I %s +--- +name: cmp_ult_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ult_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[COPY1]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(ult), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_slt_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_slt_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY]], [[COPY1]] + ; RV32I-NEXT: $x10 = COPY [[SLT]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(slt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugt_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ugt_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY1]], [[COPY]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(ugt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_sgt_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_sgt_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY1]], [[COPY]] + ; RV32I-NEXT: $x10 = COPY [[SLT]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(sgt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_eq_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_eq_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[XOR:%[0-9]+]]:gpr = XOR [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[XOR]], 1 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(eq), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ne_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ne_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[XOR:%[0-9]+]]:gpr = XOR [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[XOR]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(ne), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ule_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_ule_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY1]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(ule), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_sle_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_sle_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY1]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(sle), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_uge_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_uge_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(uge), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_sge_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10, $x11 + + ; RV32I-LABEL: name: cmp_sge_i64 + ; RV32I: liveins: $x10, $x11 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY]], [[COPY1]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = COPY $x11 + %2:gprb(s64) = G_ICMP intpred(sge), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ulti_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ulti_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[COPY]], 10 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(ult), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_slti_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_slti_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTI:%[0-9]+]]:gpr = SLTI [[COPY]], 10 + ; RV32I-NEXT: $x10 = COPY [[SLTI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(slt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugti_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ugti_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[COPY]], 11 + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTIU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(ugt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_sgti_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_sgti_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTI:%[0-9]+]]:gpr = SLTI [[COPY]], 11 + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTI]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(sgt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_eqi_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_eqi_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], -10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[ADDI]], 1 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(eq), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_nei_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_nei_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], -10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ADDI]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(ne), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ulei_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ulei_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[ADDI]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(ule), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_slei_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_slei_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[ADDI]], [[COPY]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(sle), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugei_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ugei_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[ADDI]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLTU]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(uge), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_sgei_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_sgei_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 10 + ; RV32I-NEXT: [[SLT:%[0-9]+]]:gpr = SLT [[COPY]], [[ADDI]] + ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[SLT]], 1 + ; RV32I-NEXT: $x10 = COPY [[XORI]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(sge), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_eq0_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_eq0_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[SLTIU:%[0-9]+]]:gpr = SLTIU [[COPY]], 1 + ; RV32I-NEXT: $x10 = COPY [[SLTIU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 0 + %2:gprb(s64) = G_ICMP intpred(eq), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ne0_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ne0_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10 + ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], -10 + ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ADDI]] + ; RV32I-NEXT: $x10 = COPY [[SLTU]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 10 + %2:gprb(s64) = G_ICMP intpred(ne), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +... +--- +name: cmp_ugt_neg1_i64 +legalized: true +regBankSelected: true +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x10 + + ; RV32I-LABEL: name: cmp_ugt_neg1_i64 + ; RV32I: liveins: $x10 + ; RV32I-NEXT: {{ $}} + ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x0 + ; RV32I-NEXT: $x10 = COPY [[COPY]] + ; RV32I-NEXT: PseudoRET implicit $x10 + %0:gprb(s64) = COPY $x10 + %1:gprb(s64) = G_CONSTANT i64 -1 + %2:gprb(s64) = G_ICMP intpred(ugt), %0, %1 + $x10 = COPY %2(s64) + PseudoRET implicit $x10 + +...