For PR1319:
[oota-llvm.git] / test / Transforms / SimplifyCFG / UncondBranchToReturn.ll
1 ; The unify-function-exit-nodes pass often makes basic blocks that just contain
2 ; a PHI node and a return.  Make sure the simplify cfg can straighten out this
3 ; important case.  This is basically the most trivial form of tail-duplication.
4
5 ; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
6 ; RUN:    not grep {br label}
7
8 int %test(bool %B, int %A, int %B) {
9         br bool %B, label %T, label %F
10 T:
11         br label %ret
12 F:
13         br label %ret
14 ret:
15         %X = phi int [%A, %F], [%B, %T]
16         ret int %X
17 }
18
19 ; Make sure it's willing to move unconditional branches to return instructions
20 ; as well, even if the return block is shared and the source blocks are
21 ; non-empty.
22 int %test2(bool %B, int %A, int %B) {
23         br bool %B, label %T, label %F
24 T:
25         call int %test(bool true, int 5, int 8)
26         br label %ret
27 F:
28         call int %test(bool true, int 5, int 8)
29         br label %ret
30 ret:
31         ret int %A
32 }
33