expand testcase, which has been in my tree for a while now
[oota-llvm.git] / test / Transforms / SimplifyCFG / PhiEliminate.ll
1 ; Test a bunch of cases where the cfg simplification code should
2 ; be able to fold PHI nodes into computation in common cases.  Folding the PHI
3 ; nodes away allows the branches to be eliminated, performing a simple form of
4 ; 'if conversion'.
5
6 ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis > %t.xform
7 ; RUN: not grep phi %t.xform && grep ret %t.xform
8
9 declare void %use(bool)
10 declare void %use(int)
11
12
13 void %test2(bool %c, bool %d, int %V, int %V2) {
14         br bool %d, label %X, label %F
15 X:
16         br bool %c, label %T, label %F
17 T:
18         br label %F
19 F:
20         %B1 = phi bool [true, %0], [false, %T], [false, %X]
21         %B2 = phi bool [true, %T], [false, %0], [false, %X]
22         %I1 = phi int  [1, %T], [0, %0], [2, %X]
23         %I2 = phi int  [1, %0], [0, %T], [3, %X]
24         %I3 = phi int  [17, %T], [0, %0], [4, %X]
25         %I4 = phi int  [17, %T], [5, %0], [44, %X]
26         %I5 = phi int  [%V, %T], [0, %0], [%V, %X]
27         %I6 = phi int  [%V, %0], [0, %T], [%V, %X]
28         %I7 = phi int  [%V, %0], [%V2, %T], [%V2, %X]
29         call void %use(bool %B1)
30         call void %use(bool %B2)
31         call void %use(int  %I1)
32         call void %use(int  %I2)
33         call void %use(int  %I3)
34         call void %use(int  %I4)
35         call void %use(int  %I5)
36         call void %use(int  %I6)
37         call void %use(int  %I7)
38         ret void
39 }
40
41 void %test(bool %c, int %V, int %V2) {
42         br bool %c, label %T, label %F
43 T:
44         br label %F
45 F:
46         %B1 = phi bool [true, %0], [false, %T]
47         %B2 = phi bool [true, %T], [false, %0]
48         %I1 = phi int  [1, %T], [0, %0]
49         %I2 = phi int  [1, %0], [0, %T]
50         %I3 = phi int  [17, %T], [0, %0]
51         %I4 = phi int  [17, %T], [5, %0]
52         %I5 = phi int  [%V, %T], [0, %0]
53         %I6 = phi int  [%V, %0], [0, %T]
54         %I7 = phi int  [%V, %0], [%V2, %T]
55         call void %use(bool %B1)
56         call void %use(bool %B2)
57         call void %use(int  %I1)
58         call void %use(int  %I2)
59         call void %use(int  %I3)
60         call void %use(int  %I4)
61         call void %use(int  %I5)
62         call void %use(int  %I6)
63         call void %use(int  %I7)
64         ret void
65 }