diff options
author | Duncan Sands <baldrick@free.fr> | 2011-01-18 11:50:19 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2011-01-18 11:50:19 +0000 |
commit | b2f3c383ec62b959ee27d0a5fb890894c4e49e86 (patch) | |
tree | 9e8fa6c36cc54ea8f971e2293d918371c8b05dd0 /test/Transforms/InstSimplify | |
parent | fe02c69f84ad52d42be934e4fe702f03e4991a6a (diff) | |
download | llvm-b2f3c383ec62b959ee27d0a5fb890894c4e49e86.tar.gz llvm-b2f3c383ec62b959ee27d0a5fb890894c4e49e86.tar.bz2 llvm-b2f3c383ec62b959ee27d0a5fb890894c4e49e86.tar.xz |
For completeness, generalize the (X + Y) - Y -> X transform and add X - (X + 1) -> -1.
These were not recommended by my auto-simplifier since they don't fire often enough.
However they do fire from time to time, for example they remove one subtraction from
the final bitcode for 483.xalancbmk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123755 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstSimplify')
-rw-r--r-- | test/Transforms/InstSimplify/2010-12-20-Reassociate.ll | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Transforms/InstSimplify/2010-12-20-Reassociate.ll b/test/Transforms/InstSimplify/2010-12-20-Reassociate.ll index 03d5c33f87..1e2f7fae43 100644 --- a/test/Transforms/InstSimplify/2010-12-20-Reassociate.ll +++ b/test/Transforms/InstSimplify/2010-12-20-Reassociate.ll @@ -70,3 +70,23 @@ define i32 @sub1(i32 %x, i32 %y) { ret i32 %r ; CHECK: ret i32 %y } + +define i32 @sub2(i32 %x) { +; CHECK: @sub2 +; X - (X + 1) -> -1 + %xp1 = add i32 %x, 1 + %r = sub i32 %x, %xp1 + ret i32 %r +; CHECK: ret i32 -1 +} + +define i32 @sub3(i32 %x, i32 %y) { +; CHECK: @sub3 +; ((X + 1) + Y) - (Y + 1) -> X + %xp1 = add i32 %x, 1 + %lhs = add i32 %xp1, %y + %rhs = add i32 %y, 1 + %r = sub i32 %lhs, %rhs + ret i32 %r +; CHECK: ret i32 %x +} |