[llvm] InstSimplify: teach simplifyICmpWithConstant about samesign (PR #125899)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 9 21:58:45 PST 2025


================
@@ -145,6 +145,14 @@ ConstantRange ConstantRange::makeAllowedICmpRegion(CmpInst::Predicate Pred,
   }
 }
 
+ConstantRange ConstantRange::makeAsymmetricICmpRegion(CmpPredicate Pred,
+                                                      const ConstantRange &CR) {
+  if (Pred.hasSameSign() && ICmpInst::isRelational(Pred))
+    return makeAllowedICmpRegion(Pred, CR).unionWith(makeAllowedICmpRegion(
----------------
dtcxzyw wrote:

ICmp with `samesign` should give a tighter set.
Example: `makeAllowedICmpRegion` returns `[0, 4)` for `icmp samesign ult X, [2, 5)`, but `makeAsymmetricICmpRegion` returns `[INT_MIN, 4)`.


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


More information about the llvm-commits mailing list