[PATCH] D152088: [InstCombine] add nsw on InstCombineAdd ~X + C --> (C-1) - X

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 00:25:13 PDT 2023


nikic added a comment.

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

This looks more complicated than necessary, just this should be enough: https://alive2.llvm.org/ce/z/ZWmZLv



================
Comment at: llvm/test/Transforms/InstCombine/add.ll:380
   ret i8 %C
 }
 
----------------
I think we could have a few additional tests here:
* Negative test with nuw instead of nsw.
* Non-splat vector tests with constants `-127, -126` (ok) and `-128, -127` (not ok)? This fold handles non-splat vectors, so we should check the overflow behavior there as well.


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

https://reviews.llvm.org/D152088



More information about the llvm-commits mailing list