[PATCH] D152068: [InstCombine] add overflow checking on AddSub `C-(X+C2) --> (C-C2)-X`

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 3 11:41:25 PDT 2023


nikic added a comment.

> proof: https://alive2.llvm.org/ce/z/W7RXmY

I don't think this proof is correct, because the `sub nsw i8 %c1, %c2` will already be poison on overflow, so your assume doesn't do what you intended. You probably want something like this: https://alive2.llvm.org/ce/z/S4rQUS



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2004
+      Res->setHasNoSignedWrap(I.hasNoSignedWrap() &&
+                              OBO1->hasNoUnsignedWrap() &&
+                              willNotOverflowSignedSub(C, C2, *Res));
----------------
hasNoUnsignedWrap -> hasNoSignedWrap


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152068/new/

https://reviews.llvm.org/D152068



More information about the llvm-commits mailing list