Use the llvm-upgrade program to upgrade llvm assembly.
[oota-llvm.git] / test / Transforms / InstCombine / phi.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep phi
5
6 implementation
7
8 int %test1(int %A, bool %b) {
9 BB0:    br bool %b, label %BB1, label %BB2
10 BB1:
11         %B = phi int [%A, %BB0]     ; Combine away one argument PHI nodes
12         ret int %B
13 BB2:
14         ret int %A
15 }
16
17 int %test2(int %A, bool %b) {
18 BB0:    br bool %b, label %BB1, label %BB2
19 BB1:
20         br label %BB2
21 BB2:
22         %B = phi int [%A, %BB0], [%A, %BB1]     ; Combine away PHI nodes with same values
23         ret int %B
24 }
25
26 int %test3(int %A, bool %b) {
27 BB0: br label %Loop
28
29 Loop:
30         %B = phi int [%A, %BB0], [%B, %Loop]    ; PHI has same value always.
31         br bool %b, label %Loop, label %Exit
32 Exit:
33         ret int %B
34 }
35
36 int %test4(bool %b) {
37 BB0:  ret int 7                                 ; Loop is unreachable
38
39 Loop:
40         %B = phi int [%B, %L2], [%B, %Loop]     ; PHI has same value always.
41         br bool %b, label %L2, label %Loop
42 L2:
43         br label %Loop
44 }
45
46 int %test5(int %A, bool %b) {
47 BB0: br label %Loop
48
49 Loop:
50         %B = phi int [%A, %BB0], [undef, %Loop]    ; PHI has same value always.
51         br bool %b, label %Loop, label %Exit
52 Exit:
53         ret int %B
54 }
55
56 uint %test6(int %A, bool %b) {
57 BB0:
58         %X = cast int %A to uint
59         br bool %b, label %BB1, label %BB2
60 BB1:
61         %Y = cast int %A to uint
62         br label %BB2
63 BB2:
64         %B = phi uint [%X, %BB0], [%Y, %BB1] ;; Suck casts into phi
65         ret uint %B
66 }
67