aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/Reassociate/negation1.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/Reassociate/negation1.ll')
-rw-r--r--test/Transforms/Reassociate/negation1.ll15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Transforms/Reassociate/negation1.ll b/test/Transforms/Reassociate/negation1.ll
new file mode 100644
index 0000000..34b943c
--- /dev/null
+++ b/test/Transforms/Reassociate/negation1.ll
@@ -0,0 +1,15 @@
+; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
+
+; Test that we can turn things like A*B + X - A*B -> X.
+
+define i32 @test1(i32 %a, i32 %b, i32 %x) {
+; CHECK-LABEL: test1
+; CHECK: ret i32 %x
+
+ %c = mul i32 %a, %b
+ %d = add i32 %c, %x
+ %c1 = mul i32 %a, %b
+ %f = sub i32 %d, %c1
+ ret i32 %f
+}
+