[llvm] [Knowbits] Make nuw and nsw support in computeForAddSub optimal (PR #83382)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 23:10:38 PST 2024


================
@@ -1221,8 +1225,10 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
       return I->getOperand(0);
 
     bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
+    bool NUW = cast<OverflowingBinaryOperator>(I)->hasNoUnsignedWrap();
     computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
-    Known = KnownBits::computeForAddSub(/*Add*/ false, NSW, LHSKnown, RHSKnown);
+    Known = KnownBits::computeForAddSub(/*Add*/ false, NSW, NUW, LHSKnown,
----------------
arsenm wrote:

```suggestion
    Known = KnownBits::computeForAddSub(/*Add=*/ false, NSW, NUW, LHSKnown,
```

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


More information about the llvm-commits mailing list