[PATCH] D152068: [InstCombine] add overflow checking on AddSub `C-(X+C2) --> (C-C2)-X`
Kohei Asano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 3 21:38:16 PDT 2023
khei4 added a comment.
Thank you for the review!
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2002
+ BinaryOperator *Res = BinaryOperator::CreateSub(
+ ConstantExpr::getSub(C, C2, /*HasNUW=*/false, HasNSW), X);
+ auto *OBO1 = cast<OverflowingBinaryOperator>(Op1);
----------------
goldstein.w.n wrote:
> given that C-C2 is a constexpr do the flag matter at all? If not can you drop them from the constexpr, they just seem noisey.
Thank you for a good catch! In this case, giving overflow checking of `C - C2` will be a problem for `C-(X+C2)` and `(X+C2)` will signed wrapped and `C - C2` overflowcase!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152068/new/
https://reviews.llvm.org/D152068
More information about the llvm-commits
mailing list