diff options
author | Ross Kirsling <ross.kirsling@sony.com> | 2025-06-24 09:51:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-24 18:51:49 +0200 |
commit | 7d2293d1d95379bbdbb6446b088219ac06b97e1e (patch) | |
tree | cbf3bd27797d6736dbd397a74e5809dea606b542 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | a84891698a2a13780d3804686ebf31d3639dd6a4 (diff) | |
download | llvm-7d2293d1d95379bbdbb6446b088219ac06b97e1e.zip llvm-7d2293d1d95379bbdbb6446b088219ac06b97e1e.tar.gz llvm-7d2293d1d95379bbdbb6446b088219ac06b97e1e.tar.bz2 |
[InstCombine] KnownBits::isNonNegative should recognize `b - a` after `a <= b` (#145105)
Alive2: https://alive2.llvm.org/ce/z/an9npN
Fixes #142283.
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, |