blob: ef2433c11bf2304d1871d09f93c4335fba341145 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; 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
10declare void %use(bool)
11declare void %use(int)
12
13
14void %test2(bool %c, bool %d, int %V, int %V2) {
15 br bool %d, label %X, label %F
16X:
17 br bool %c, label %T, label %F
18T:
19 br label %F
20F:
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
28void %test(bool %c, int %V, int %V2) {
29 br bool %c, label %T, label %F
30T:
31 br label %F
32F:
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}