Use the llvm-upgrade program to upgrade llvm assembly.
[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-upgrade < %s | llvm-as | 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         %I7 = phi int  [%V, %0], [%V2, %T], [%V2, %X]
22         call void %use(bool %B1)
23         call void %use(int  %I7)
24         ret void
25 }
26
27 void %test(bool %c, int %V, int %V2) {
28         br bool %c, label %T, label %F
29 T:
30         br label %F
31 F:
32         %B1 = phi bool [true, %0], [false, %T]
33         %I6 = phi int  [%V, %0], [0, %T]
34         call void %use(bool %B1)
35         call void %use(int  %I6)
36         ret void
37 }