[llvm] [InstCombine] KnownBits::isNonNegative should recognize `b - a` after `a <= b` (PR #145105)
    Nikita Popov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jun 23 00:07:34 PDT 2025
    
    
  
================
@@ -362,6 +362,11 @@ static void computeKnownBitsAddSub(bool Add, const Value *Op0, const Value *Op1,
 
   computeKnownBits(Op0, DemandedElts, Known2, Q, Depth + 1);
   KnownOut = KnownBits::computeForAddSub(Add, NSW, NUW, Known2, KnownOut);
+
+  if (!Add && NSW &&
----------------
nikic wrote:
```suggestion
  if (!Add && NSW && !KnownOut.isNonNegative() &&
```
Avoid the dom cond check if it doesn't add new information.
https://github.com/llvm/llvm-project/pull/145105
    
    
More information about the llvm-commits
mailing list