diff options
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 2389322..93c2221 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -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 && !KnownOut.isNonNegative() && + isImpliedByDomCondition(ICmpInst::ICMP_SLE, Op1, Op0, Q.CxtI, Q.DL) + .value_or(false)) + KnownOut.makeNonNegative(); } static void computeKnownBitsMul(const Value *Op0, const Value *Op1, bool NSW, |