blob: ef2433c11bf2304d1871d09f93c4335fba341145 [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
Reid Spencer9aafdcf2007-04-15 09:21:47 +00007; RUN: not grep phi %t.xform
8; RUN: grep ret %t.xform
Chris Lattner54636af2004-02-11 03:35:04 +00009
10declare void %use(bool)
11declare void %use(int)
12
Chris Lattner9b08fec2005-12-03 18:26:41 +000013
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]
Chris Lattner9b08fec2005-12-03 18:26:41 +000022 %I7 = phi int [%V, %0], [%V2, %T], [%V2, %X]
23 call void %use(bool %B1)
Chris Lattner9b08fec2005-12-03 18:26:41 +000024 call void %use(int %I7)
25 ret void
26}
27
Chris Lattner5dd784a2004-03-30 19:45:11 +000028void %test(bool %c, int %V, int %V2) {
Chris Lattner54636af2004-02-11 03:35:04 +000029 br bool %c, label %T, label %F
30T:
31 br label %F
32F:
33 %B1 = phi bool [true, %0], [false, %T]
Chris Lattner54636af2004-02-11 03:35:04 +000034 %I6 = phi int [%V, %0], [0, %T]
Chris Lattner54636af2004-02-11 03:35:04 +000035 call void %use(bool %B1)
Chris Lattner54636af2004-02-11 03:35:04 +000036 call void %use(int %I6)
Chris Lattner54636af2004-02-11 03:35:04 +000037 ret void
38}