When the two operands of an icmp are equal, there are five possible predicates
[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 
8 ; RUN:   grep ret %t.xform
9
10 declare void %use(bool)
11 declare void %use(int)
12
13
14 void %test2(bool %c, bool %d, int %V, int %V2) {
15         br bool %d, label %X, label %F
16 X:
17         br bool %c, label %T, label %F
18 T:
19         br label %F
20 F:
21         %B1 = phi bool [true, %0], [false, %T], [false, %X]
22         %I7 = phi int  [%V, %0], [%V2, %T], [%V2, %X]
23         call void %use(bool %B1)
24         call void %use(int  %I7)
25         ret void
26 }
27
28 void %test(bool %c, int %V, int %V2) {
29         br bool %c, label %T, label %F
30 T:
31         br label %F
32 F:
33         %B1 = phi bool [true, %0], [false, %T]
34         %I6 = phi int  [%V, %0], [0, %T]
35         call void %use(bool %B1)
36         call void %use(int  %I6)
37         ret void
38 }