Use the llvm-upgrade program to upgrade llvm assembly.
[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 | not grep 'br label'
6
7 int %test(bool %B, int %A, int %B) {
8         br bool %B, label %T, label %F
9 T:
10         br label %ret
11 F:
12         br label %ret
13 ret:
14         %X = phi int [%A, %F], [%B, %T]
15         ret int %X
16 }
17
18 ; Make sure it's willing to move unconditional branches to return instructions
19 ; as well, even if the return block is shared and the source blocks are
20 ; non-empty.
21 int %test2(bool %B, int %A, int %B) {
22         br bool %B, label %T, label %F
23 T:
24         call int %test(bool true, int 5, int 8)
25         br label %ret
26 F:
27         call int %test(bool true, int 5, int 8)
28         br label %ret
29 ret:
30         ret int %A
31 }
32