2004-02-11 03:35:04 +00:00
|
|
|
; Test a bunch of cases where the cfg simplification code should
|
|
|
|
; be able to fold PHI nodes into computation in common cases. Folding the PHI
|
|
|
|
; nodes away allows the branches to be eliminated, performing a simple form of
|
|
|
|
; 'if conversion'.
|
|
|
|
|
2006-12-02 04:23:10 +00:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis > %t.xform
|
2007-04-15 09:21:47 +00:00
|
|
|
; RUN: not grep phi %t.xform
|
|
|
|
; RUN: grep ret %t.xform
|
2004-02-11 03:35:04 +00:00
|
|
|
|
|
|
|
declare void %use(bool)
|
|
|
|
declare void %use(int)
|
|
|
|
|
2005-12-03 18:26:41 +00:00
|
|
|
|
|
|
|
void %test2(bool %c, bool %d, int %V, int %V2) {
|
|
|
|
br bool %d, label %X, label %F
|
|
|
|
X:
|
|
|
|
br bool %c, label %T, label %F
|
|
|
|
T:
|
|
|
|
br label %F
|
|
|
|
F:
|
|
|
|
%B1 = phi bool [true, %0], [false, %T], [false, %X]
|
|
|
|
%I7 = phi int [%V, %0], [%V2, %T], [%V2, %X]
|
|
|
|
call void %use(bool %B1)
|
|
|
|
call void %use(int %I7)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2004-03-30 19:45:11 +00:00
|
|
|
void %test(bool %c, int %V, int %V2) {
|
2004-02-11 03:35:04 +00:00
|
|
|
br bool %c, label %T, label %F
|
|
|
|
T:
|
|
|
|
br label %F
|
|
|
|
F:
|
|
|
|
%B1 = phi bool [true, %0], [false, %T]
|
|
|
|
%I6 = phi int [%V, %0], [0, %T]
|
|
|
|
call void %use(bool %B1)
|
|
|
|
call void %use(int %I6)
|
|
|
|
ret void
|
|
|
|
}
|