On folding C-(X+C2) --> (C-C2)-X, we can safely attach NSW to (C-C2)-X if the 1~3 are satisfied
- A:= (X+C2) has NSW
- C-A has NSW
- C-C2 won't signed overflow
proof: https://alive2.llvm.org/ce/z/S4rQUS
pre-commit tests: https://reviews.llvm.org/D152091
Differential D152068
[InstCombine] add overflow checking on AddSub `C-(X+C2) --> (C-C2)-X` khei4 on Jun 3 2023, 9:31 AM. Authored by
Details On folding C-(X+C2) --> (C-C2)-X, we can safely attach NSW to (C-C2)-X if the 1~3 are satisfied
proof: https://alive2.llvm.org/ce/z/S4rQUS
Diff Detail
Event TimelineComment Actions This doesn't seem working. Res->setHasNoSignedWrap(I.hasNoSignedWrap() && OBO1->hasNoUnsignedWrap() && willNotOverflowSignedSub(C, C2, *Res)); Comment Actions 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 Actions Thank you for the review!
|
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.