[llvm] [InstCombine] Fold zext(icmp ne X, C) to X - C when X is in (C, C+1) (PR #208914)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 02:33:06 PDT 2026


================
@@ -1407,6 +1407,28 @@ Instruction *InstCombinerImpl::transformZExtICmp(ICmpInst *Cmp,
         return replaceInstUsesWith(Zext, IntCast);
       }
     }
+
+    ConstantRange CR = computeConstantRange(Cmp->getOperand(0), false, SQ);
----------------
andjo403 wrote:

computeConstantRange (is recursive so kind of slow) is done for all cmp instructions only needed for EQ/NE

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


More information about the llvm-commits mailing list