blob: f8e06c0dd3cfa42d27ec5160b4710be15a6471ef [file] [log] [blame]
Chris Lattner54636af2004-02-11 03:35:04 +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
John Criswell2942e632004-03-17 02:31:29 +00006; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis > %t.xform
7; RUN: not grep phi %t.xform && grep ret %t.xform
Chris Lattner54636af2004-02-11 03:35:04 +00008
9declare void %use(bool)
10declare void %use(int)
11
Chris Lattner9b08fec2005-12-03 18:26:41 +000012
13void %test2(bool %c, bool %d, int %V, int %V2) {
14 br bool %d, label %X, label %F
15X:
16 br bool %c, label %T, label %F
17T:
18 br label %F
19F:
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
Chris Lattner5dd784a2004-03-30 19:45:11 +000041void %test(bool %c, int %V, int %V2) {
Chris Lattner54636af2004-02-11 03:35:04 +000042 br bool %c, label %T, label %F
43T:
44 br label %F
45F:
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]
Chris Lattner5dd784a2004-03-30 19:45:11 +000054 %I7 = phi int [%V, %0], [%V2, %T]
Chris Lattner54636af2004-02-11 03:35:04 +000055 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)
Chris Lattner4971b722004-03-30 19:45:39 +000063 call void %use(int %I7)
Chris Lattner54636af2004-02-11 03:35:04 +000064 ret void
65}