summaryrefslogtreecommitdiff
path: root/test/Transforms/Reassociate
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-04-22 10:11:26 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-04-22 10:11:26 +0000
commita3e3481c5715c2dc9778be3450701ecc7299b24f (patch)
treeded83c101c30fe913a4123961d860da2dc1e00ec /test/Transforms/Reassociate
parent71f8bc37f217fed18468f7610ac24cbb99c3e6fb (diff)
downloadllvm-a3e3481c5715c2dc9778be3450701ecc7299b24f.tar.gz
llvm-a3e3481c5715c2dc9778be3450701ecc7299b24f.tar.bz2
llvm-a3e3481c5715c2dc9778be3450701ecc7299b24f.tar.xz
Tidy up this test more:
1) Make the checked assertions a bit more precise. We really want the canonical forms coming out of reassociate to be exactly what is expected. 2) Remove other passes, and switch the test to actually directly check that reassociate makes the important transforms and canonicalizations. 3) Fold in a related test case now that we're using FileCheck. Make the same tidying changes to it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/Reassociate')
-rw-r--r--test/Transforms/Reassociate/mulfactor.ll30
-rw-r--r--test/Transforms/Reassociate/mulfactor2.ll15
2 files changed, 23 insertions, 22 deletions
diff --git a/test/Transforms/Reassociate/mulfactor.ll b/test/Transforms/Reassociate/mulfactor.ll
index 0afcbf9c87..5e6fbeb1ca 100644
--- a/test/Transforms/Reassociate/mulfactor.ll
+++ b/test/Transforms/Reassociate/mulfactor.ll
@@ -1,11 +1,13 @@
-; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
+; RUN: opt < %s -reassociate -S | FileCheck %s
-define i32 @f(i32 %a, i32 %b) {
-; CHECK: @f
-; CHECK: mul
-; CHECK: mul
-; CHECK-NOT: mul
-; CHECK: ret
+define i32 @test1(i32 %a, i32 %b) {
+; CHECK: @test1
+; CHECK: mul i32 %a, %a
+; CHECK-NEXT: mul i32 %a, 2
+; CHECK-NEXT: add
+; CHECK-NEXT: mul
+; CHECK-NEXT: add
+; CHECK-NEXT: ret
entry:
%tmp.2 = mul i32 %a, %a
@@ -17,3 +19,17 @@ entry:
ret i32 %tmp.11
}
+define i32 @test2(i32 %t) {
+; CHECK: @test2
+; CHECK: mul
+; CHECK-NEXT: add
+; CHECK-NEXT: ret
+
+entry:
+ %a = mul i32 %t, 6
+ %b = mul i32 %t, 36
+ %c = add i32 %b, 15
+ %d = add i32 %c, %a
+ ret i32 %d
+}
+
diff --git a/test/Transforms/Reassociate/mulfactor2.ll b/test/Transforms/Reassociate/mulfactor2.ll
deleted file mode 100644
index 8116554196..0000000000
--- a/test/Transforms/Reassociate/mulfactor2.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; This should turn into one multiply and one add.
-
-; RUN: opt < %s -instcombine -reassociate -instcombine -S > %t
-; RUN: grep mul %t | count 1
-; RUN: grep add %t | count 1
-
-define i32 @main(i32 %t) {
- %tmp.3 = mul i32 %t, 12 ; <i32> [#uses=1]
- %tmp.4 = add i32 %tmp.3, 5 ; <i32> [#uses=1]
- %tmp.6 = mul i32 %t, 6 ; <i32> [#uses=1]
- %tmp.8 = mul i32 %tmp.4, 3 ; <i32> [#uses=1]
- %tmp.9 = add i32 %tmp.8, %tmp.6 ; <i32> [#uses=1]
- ret i32 %tmp.9
-}
-