aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-01 19:22:20 +0000
committerChris Lattner <sabre@nondot.org>2009-11-01 19:22:20 +0000
commitc7e4e6edc4b020f71375666f913ab0eacc6366c7 (patch)
treee711e4da483e9ad109c03d10288f447ceeeec5fb /test
parent857e9996c7e3567b5d52808e922ac14c119527d4 (diff)
downloadexternal_llvm-c7e4e6edc4b020f71375666f913ab0eacc6366c7.zip
external_llvm-c7e4e6edc4b020f71375666f913ab0eacc6366c7.tar.gz
external_llvm-c7e4e6edc4b020f71375666f913ab0eacc6366c7.tar.bz2
convert to filecheck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85734 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/phi.ll69
1 files changed, 49 insertions, 20 deletions
diff --git a/test/Transforms/InstCombine/phi.ll b/test/Transforms/InstCombine/phi.ll
index 24eca72..a5a535c 100644
--- a/test/Transforms/InstCombine/phi.ll
+++ b/test/Transforms/InstCombine/phi.ll
@@ -1,44 +1,53 @@
; This test makes sure that these instructions are properly eliminated.
;
-; RUN: opt < %s -instcombine -S | not grep phi
+; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @test1(i32 %A, i1 %b) {
BB0:
br i1 %b, label %BB1, label %BB2
-BB1: ; preds = %BB0
+BB1:
; Combine away one argument PHI nodes
- %B = phi i32 [ %A, %BB0 ] ; <i32> [#uses=1]
+ %B = phi i32 [ %A, %BB0 ]
ret i32 %B
-BB2: ; preds = %BB0
+BB2:
ret i32 %A
+; CHECK: @test1
+; CHECK: BB1:
+; CHECK-NEXT: ret i32 %A
}
define i32 @test2(i32 %A, i1 %b) {
BB0:
br i1 %b, label %BB1, label %BB2
-BB1: ; preds = %BB0
+BB1:
br label %BB2
-BB2: ; preds = %BB1, %BB0
+BB2:
; Combine away PHI nodes with same values
- %B = phi i32 [ %A, %BB0 ], [ %A, %BB1 ] ; <i32> [#uses=1]
+ %B = phi i32 [ %A, %BB0 ], [ %A, %BB1 ]
ret i32 %B
+; CHECK: @test2
+; CHECK: BB2:
+; CHECK-NEXT: ret i32 %A
}
define i32 @test3(i32 %A, i1 %b) {
BB0:
br label %Loop
-Loop: ; preds = %Loop, %BB0
+Loop:
; PHI has same value always.
- %B = phi i32 [ %A, %BB0 ], [ %B, %Loop ] ; <i32> [#uses=2]
+ %B = phi i32 [ %A, %BB0 ], [ %B, %Loop ]
br i1 %b, label %Loop, label %Exit
-Exit: ; preds = %Loop
+Exit:
ret i32 %B
+; CHECK: @test3
+; CHECK: Exit:
+; CHECK-NEXT: ret i32 %A
}
define i32 @test4(i1 %b) {
@@ -48,11 +57,14 @@ BB0:
Loop: ; preds = %L2, %Loop
; PHI has same value always.
- %B = phi i32 [ %B, %L2 ], [ %B, %Loop ] ; <i32> [#uses=2]
+ %B = phi i32 [ %B, %L2 ], [ %B, %Loop ]
br i1 %b, label %L2, label %Loop
L2: ; preds = %Loop
br label %Loop
+; CHECK: @test4
+; CHECK: Loop:
+; CHECK-NEXT: br i1 %b
}
define i32 @test5(i32 %A, i1 %b) {
@@ -61,26 +73,35 @@ BB0:
Loop: ; preds = %Loop, %BB0
; PHI has same value always.
- %B = phi i32 [ %A, %BB0 ], [ undef, %Loop ] ; <i32> [#uses=1]
+ %B = phi i32 [ %A, %BB0 ], [ undef, %Loop ]
br i1 %b, label %Loop, label %Exit
Exit: ; preds = %Loop
ret i32 %B
+; CHECK: @test5
+; CHECK: Loop:
+; CHECK-NEXT: br i1 %b
+; CHECK: Exit:
+; CHECK-NEXT: ret i32 %A
}
-define i32 @test6(i32 %A, i1 %b) {
+define i32 @test6(i16 %A, i1 %b) {
BB0:
- %X = bitcast i32 %A to i32 ; <i32> [#uses=1]
+ %X = zext i16 %A to i32
br i1 %b, label %BB1, label %BB2
-BB1: ; preds = %BB0
- %Y = bitcast i32 %A to i32 ; <i32> [#uses=1]
+BB1:
+ %Y = zext i16 %A to i32
br label %BB2
-BB2: ; preds = %BB1, %BB0
+BB2:
;; Suck casts into phi
- %B = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ] ; <i32> [#uses=1]
+ %B = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]
ret i32 %B
+; CHECK: @test6
+; CHECK: BB2:
+; CHECK: zext i16 %A to i32
+; CHECK-NEXT: ret i32
}
define i32 @test7(i32 %A, i1 %b) {
@@ -89,12 +110,15 @@ BB0:
Loop: ; preds = %Loop, %BB0
; PHI is dead.
- %B = phi i32 [ %A, %BB0 ], [ %C, %Loop ] ; <i32> [#uses=1]
- %C = add i32 %B, 123 ; <i32> [#uses=1]
+ %B = phi i32 [ %A, %BB0 ], [ %C, %Loop ]
+ %C = add i32 %B, 123
br i1 %b, label %Loop, label %Exit
Exit: ; preds = %Loop
ret i32 0
+; CHECK: @test7
+; CHECK: Loop:
+; CHECK-NEXT: br i1 %b
}
define i32* @test8({ i32, i32 } *%A, i1 %b) {
@@ -110,6 +134,11 @@ BB2:
;; Suck GEPs into phi
%B = phi i32* [ %X, %BB0 ], [ %Y, %BB1 ]
ret i32* %B
+; CHECK: @test8
+; CHECK-NOT: phi
+; CHECK: BB2:
+; CHECK-NEXT: %B = getelementptr
+; CHECK-NEXT: ret i32* %B
}