summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2014-10-05 23:41:26 +0000
committerOwen Anderson <resistor@mac.com>2014-10-05 23:41:26 +0000
commit8373d338f6f0f5462cf10704e904b0c359dddd3e (patch)
treeca0c4faaa07a5bb9c8b44987fdb684bfa2cb77af /llvm/test/Transforms
parent2f03c8a38d57010a924f7367b3c3b57076ab242a (diff)
downloadbcm5719-llvm-8373d338f6f0f5462cf10704e904b0c359dddd3e.tar.gz
bcm5719-llvm-8373d338f6f0f5462cf10704e904b0c359dddd3e.zip
Give the Reassociate pass a bit more flexibility and autonomy when optimizing expressions.
Particularly, it addresses cases where Reassociate breaks Subtracts but then fails to optimize combinations like I1 + -I2 where I1 and I2 have the same rank and are identical. Patch by Dmitri Shtilman. llvm-svn: 219092
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/Reassociate/negation1.ll15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Reassociate/negation1.ll b/llvm/test/Transforms/Reassociate/negation1.ll
new file mode 100644
index 00000000000..34b943cf496
--- /dev/null
+++ b/llvm/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
+}
+
OpenPOWER on IntegriCloud