diff options
author | Robert Lougher <rob.lougher@gmail.com> | 2019-05-07 19:36:41 +0000 |
---|---|---|
committer | Robert Lougher <rob.lougher@gmail.com> | 2019-05-07 19:36:41 +0000 |
commit | 8681ef8f41db61586fdc4d252a1ea89e0958ce46 (patch) | |
tree | 781d7e43bfe06b7531a8c27c30eda6f8e37d92fa /llvm/test/Transforms/InstCombine/with_overflow.ll | |
parent | 4727221734403b86d5bb6385fee7e7fec6fa52ff (diff) | |
download | bcm5719-llvm-8681ef8f41db61586fdc4d252a1ea89e0958ce46.tar.gz bcm5719-llvm-8681ef8f41db61586fdc4d252a1ea89e0958ce46.zip |
[InstCombine] Add new combine to add folding
(X | C1) + C2 --> (X | C1) ^ C1 iff (C1 == -C2)
I verified the correctness using Alive:
https://rise4fun.com/Alive/YNV
This transform enables the following transform that already exists in
instcombine:
(X | Y) ^ Y --> X & ~Y
As a result, the full expected transform is:
(X | C1) + C2 --> X & ~C1 iff (C1 == -C2)
There already exists the transform in the sub case:
(X | Y) - Y --> X & ~Y
However this does not trigger in the case where Y is constant due to an earlier
transform:
X - (-C) --> X + C
With this new add fold, both the add and sub constant cases are handled.
Patch by Chris Dawson.
Differential Revision: https://reviews.llvm.org/D61517
llvm-svn: 360185
Diffstat (limited to 'llvm/test/Transforms/InstCombine/with_overflow.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/with_overflow.ll | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/test/Transforms/InstCombine/with_overflow.ll b/llvm/test/Transforms/InstCombine/with_overflow.ll index e80da2afe2f..b15e37ce6e0 100644 --- a/llvm/test/Transforms/InstCombine/with_overflow.ll +++ b/llvm/test/Transforms/InstCombine/with_overflow.ll @@ -531,10 +531,9 @@ define { i32, i1 } @umul_canonicalize_constant_arg0(i32 %x) nounwind { define { i8, i1 } @uadd_always_overflow(i8 %x) nounwind { ; CHECK-LABEL: @uadd_always_overflow( -; CHECK-NEXT: [[Y:%.*]] = or i8 [[X:%.*]], -64 -; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[Y]], 64 -; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { i8, i1 } { i8 undef, i1 true }, i8 [[A]], 0 -; CHECK-NEXT: ret { i8, i1 } [[TMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], 63 +; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { i8, i1 } { i8 undef, i1 true }, i8 [[TMP1]], 0 +; CHECK-NEXT: ret { i8, i1 } [[TMP2]] ; %y = or i8 %x, 192 %a = call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %y, i8 64) |