[PATCH] D149414: [ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 29 10:46:18 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2940
+                            II->getArgOperand(0), II->getArgOperand(1),
+                            /*NSW*/ false);
       case Intrinsic::uadd_sat:
----------------
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.


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