summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-16 06:35:19 +0000
committerChris Lattner <sabre@nondot.org>2004-02-16 06:35:19 +0000
commit5ea27d820a7873400d0c5e8e18253489e1d99c85 (patch)
tree70e2e4c83059de1373d0f9ac519f6875a785c81a /test
parent7059f2e76baaa70b0b940a038b55810590fc2d20 (diff)
downloadllvm-5ea27d820a7873400d0c5e8e18253489e1d99c85.tar.gz
llvm-5ea27d820a7873400d0c5e8e18253489e1d99c85.tar.bz2
llvm-5ea27d820a7873400d0c5e8e18253489e1d99c85.tar.xz
New testcase, details in the comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/SimplifyCFG/UncondBranchToReturn.ll32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll
new file mode 100644
index 0000000000..6e943f35fb
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll
@@ -0,0 +1,32 @@
+; The unify-function-exit-nodes pass often makes basic blocks that just contain
+; a PHI node and a return. Make sure the simplify cfg can straighten out this
+; important case. This is basically the most trivial form of tail-duplication.
+
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep 'br label'
+
+int %test(bool %B, int %A, int %B) {
+ br bool %B, label %T, label %F
+T:
+ br label %ret
+F:
+ br label %ret
+ret:
+ %X = phi int [%A, %F], [%B, %T]
+ ret int %X
+}
+
+; Make sure it's willing to move unconditional branches to return instructions
+; as well, even if the return block is shared and the source blocks are
+; non-empty.
+int %test2(bool %B, int %A, int %B) {
+ br bool %B, label %T, label %F
+T:
+ call int %test(bool true, int 5, int 8)
+ br label %ret
+F:
+ call int %test(bool true, int 5, int 8)
+ br label %ret
+ret:
+ ret int %A
+}
+