OSDN Git Service

[NFC][InstSimplify] Add tests for add nuw %x, -1 -> -1 fold.
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 7 Jun 2018 21:19:50 +0000 (21:19 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 7 Jun 2018 21:19:50 +0000 (21:19 +0000)
commit6dc64e29f8dc050b5b2c333fc40e22137e349faa
tree9ef590322c7af9c05b47b87bc699164d4dee3fc4
parent04cb3cb23972d055e3eda437f5be71a7fe793d78
[NFC][InstSimplify] Add tests for add nuw %x, -1 -> -1 fold.

%ret = add nuw i8 %x, C
From langref:
nuw and nsw stand for “No Unsigned Wrap” and “No Signed Wrap”,
respectively. If the nuw and/or nsw keywords are present,
the result value of the add is a poison value if unsigned
and/or signed overflow, respectively, occurs.

So if C is -1, %x can only be 0, and the result is always -1.

https://rise4fun.com/Alive/sldC
Was mentioned in D47428 review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334236 91177308-0d34-0410-b5e6-96231b3b80d8
test/Transforms/InstSimplify/constantfold-add-nuw-allones-to-allones.ll [new file with mode: 0644]