[llvm] [RISCV][GISel] Select G_SELECT (G_ICMP, A, B) (PR #68247)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 12:33:08 PDT 2023
================
@@ -376,6 +389,124 @@ bool RISCVInstructionSelector::selectSExtInreg(MachineInstr &MI,
return true;
}
+/// Returns the RISCVCC::CondCode that corresponds to the CmpInst::Predicate CC.
+/// CC Must be an ICMP Predicate.
+static RISCVCC::CondCode getRISCVCCFromICMP(CmpInst::Predicate CC) {
+ switch (CC) {
+ default:
+ llvm_unreachable("Expected ICMP CmpInst::Predicate.");
+ case CmpInst::Predicate::ICMP_EQ:
+ return RISCVCC::COND_EQ;
+ case CmpInst::Predicate::ICMP_NE:
+ return RISCVCC::COND_NE;
+ case CmpInst::Predicate::ICMP_ULT:
+ return RISCVCC::COND_LTU;
+ case CmpInst::Predicate::ICMP_SLT:
+ return RISCVCC::COND_LT;
+ case CmpInst::Predicate::ICMP_UGE:
+ return RISCVCC::COND_GEU;
+ case CmpInst::Predicate::ICMP_SGE:
+ return RISCVCC::COND_GE;
+ }
+}
+
+MachineInstr *RISCVInstructionSelector::createICMPForBranch(
----------------
michaelmaitland wrote:
I built a new ICmp because it packs everything that is needed into a single data structure. Are you suggesting to have `createICMPBranch` be called something like `getSelectOperandsFromICMP` which returns a custom data structure that isn't a MachineInstr?
https://github.com/llvm/llvm-project/pull/68247
More information about the llvm-commits
mailing list