[llvm] InstCombine: Fold samesign ult to slt with added constant when the range is known (PR #134556)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 6 12:24:45 PDT 2025


================
@@ -3165,9 +3166,13 @@ Instruction *InstCombinerImpl::foldICmpAddConstant(ICmpInst &Cmp,
     // If there is overflow, the result must be true or false.
     // TODO: Can we assert there is no overflow because InstSimplify always
     // handles those cases?
-    if (!Overflow)
+    if (!Overflow) {
----------------
nikic wrote:

The overall implementation approach here is iffy, because for the nuw+nsw+samesign case we could use both the signed and unsigned predicate, so we should try both, with a preference for unsigned.

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


More information about the llvm-commits mailing list