[llvm-branch-commits] [llvm] [InstCombine] Move more icmp folds keyed on Op0 into the switch (PR #244766)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 22 12:18:26 PST 2026


================
@@ -8155,6 +8218,88 @@ Instruction *InstCombinerImpl::foldICmpCommutative(CmpPredicate Pred,
   }
 }
 
+// Folds that each require Op0 to be a particular operator.
+Instruction *InstCombinerImpl::foldICmpByOp0(ICmpInst &I) {
+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
+  ICmpInst::Predicate Pred = I.getPredicate();
+  switch (Operator::getOpcode(Op0)) {
+  case Instruction::BitCast:
+    if (Instruction *Res = foldICmpBitCast(I))
+      return Res;
+    if (Instruction *Res = foldICmpWithCastOp(I))
+      return Res;
+    return foldReductionIdiom(I, Builder, DL);
----------------
nikic wrote:

This one also compares to zero RHS.

https://github.com/llvm/llvm-project/pull/244766


More information about the llvm-branch-commits mailing list