summaryrefslogtreecommitdiff
path: root/test/Transforms/Reassociate
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-17 20:51:26 +0000
committerChris Lattner <sabre@nondot.org>2008-02-17 20:51:26 +0000
commit0b0803ae1508ff514dd7b471a2a3bcd1e83cb0ef (patch)
tree14c62f7634cd8cca1b6beeef3e942ed56d95d5e0 /test/Transforms/Reassociate
parentf06c3c29acb5560f27d18f8498cefcd4f58be08b (diff)
downloadllvm-0b0803ae1508ff514dd7b471a2a3bcd1e83cb0ef.tar.gz
llvm-0b0803ae1508ff514dd7b471a2a3bcd1e83cb0ef.tar.bz2
llvm-0b0803ae1508ff514dd7b471a2a3bcd1e83cb0ef.tar.xz
Split up subtracts into add+negate if they have a reassociable use or operand
that is also a subtract. This implements PR2047 and Transforms/Reassociate/subtest2.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47241 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/Reassociate')
-rw-r--r--test/Transforms/Reassociate/subtest2.ll13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Transforms/Reassociate/subtest2.ll b/test/Transforms/Reassociate/subtest2.ll
new file mode 100644
index 0000000000..c81e9b38de
--- /dev/null
+++ b/test/Transforms/Reassociate/subtest2.ll
@@ -0,0 +1,13 @@
+; With sub reassociation, constant folding can eliminate the uses of %a.
+;
+; RUN: llvm-as < %s | opt -reassociate -instcombine | llvm-dis | grep %a | count 1
+; PR2047
+
+define i32 @test(i32 %a, i32 %b, i32 %c) nounwind {
+entry:
+ %tmp3 = sub i32 %a, %b ; <i32> [#uses=1]
+ %tmp5 = sub i32 %tmp3, %c ; <i32> [#uses=1]
+ %tmp7 = sub i32 %tmp5, %a ; <i32> [#uses=1]
+ ret i32 %tmp7
+}
+