[PATCH] D149414: [ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 29 12:20:27 PDT 2023
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2940
+ II->getArgOperand(0), II->getArgOperand(1),
+ /*NSW*/ false);
case Intrinsic::uadd_sat:
----------------
goldstein.w.n wrote:
> nikic wrote:
> > I think you can set NSW=true here, based on the following reasoning: If the addition were to overflow, then the result would be either SignedMin or SignedMax, neither of which is zero. As such, we can ignore overflow cases.
> I don't think we have `NSW` I tried:
> https://alive2.llvm.org/ce/z/ZBJP5e to see if `sadd.sat` was a superset and think we might run into some edge cases.
> https://alive2.llvm.org/ce/z/9Hz7sn OTOH verifies.
Here's a variant of your proof that works: https://alive2.llvm.org/ce/z/qFwKbT You need to use logical or in this case.
Alternatively, this one also works: https://alive2.llvm.org/ce/z/6px6Ss
We have to exclude undef due to use count increases, but that's just an artifact of the proof.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149414/new/
https://reviews.llvm.org/D149414
More information about the llvm-commits
mailing list