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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 22:13:57 PST 2024


================
@@ -2318,7 +2321,11 @@ static bool isNonZeroRecurrence(const PHINode *PN) {
 
 static bool isNonZeroAdd(const APInt &DemandedElts, unsigned Depth,
                          const SimplifyQuery &Q, unsigned BitWidth, Value *X,
-                         Value *Y, bool NSW) {
+                         Value *Y, bool NSW, bool NUW) {
+  if (NUW)
+    return isKnownNonZero(Y, DemandedElts, Depth, Q) ||
+           isKnownNonZero(X, DemandedElts, Depth, Q);
----------------
dtcxzyw wrote:

Can we reuse known bits with `WithCache`?


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


More information about the llvm-commits mailing list