blob: 9411b33f7b38652ff16944ce2af0b61a6ceabf80 [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
Reid Spencer69ccadd2006-12-02 04:23:10 +00006; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis > %t.xform
John Criswell2942e632004-03-17 02:31:29 +00007; 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]
Chris Lattner9b08fec2005-12-03 18:26:41 +000021 %I7 = phi int [%V, %0], [%V2, %T], [%V2, %X]
22 call void %use(bool %B1)
Chris Lattner9b08fec2005-12-03 18:26:41 +000023 call void %use(int %I7)
24 ret void
25}
26
Chris Lattner5dd784a2004-03-30 19:45:11 +000027void %test(bool %c, int %V, int %V2) {
Chris Lattner54636af2004-02-11 03:35:04 +000028 br bool %c, label %T, label %F
29T:
30 br label %F
31F:
32 %B1 = phi bool [true, %0], [false, %T]
Chris Lattner54636af2004-02-11 03:35:04 +000033 %I6 = phi int [%V, %0], [0, %T]
Chris Lattner54636af2004-02-11 03:35:04 +000034 call void %use(bool %B1)
Chris Lattner54636af2004-02-11 03:35:04 +000035 call void %use(int %I6)
Chris Lattner54636af2004-02-11 03:35:04 +000036 ret void
37}