summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-11-12 22:37:16 +0000
committerNadav Rotem <nrotem@apple.com>2013-11-12 22:37:16 +0000
commitf3bd3ea3fe1abf414d3a38a684f3df7382a1a8d5 (patch)
treef2716ac4ae229b5166132b81ef9bfa9b2667a0fd /test/Transforms/SimplifyCFG
parent714e04b84ac5c2342f468aa55953694e4cdf3834 (diff)
downloadllvm-f3bd3ea3fe1abf414d3a38a684f3df7382a1a8d5.tar.gz
llvm-f3bd3ea3fe1abf414d3a38a684f3df7382a1a8d5.tar.bz2
llvm-f3bd3ea3fe1abf414d3a38a684f3df7382a1a8d5.tar.xz
FoldBranchToCommonDest merges branches into a single branch with or/and of the condition. It has a heuristics for estimating when some of the dependencies are processed by out-of-order processors. This patch adds another rule to the heuristics that says that if the "BonusInstruction" that we speculatively execute is used by the condition of the second branch then it is okay to hoist it. This change exposes more opportunities for other passes to transform the code. It does not matter that much that we if-convert the code because the selectiondag builder splits or/and branches into multiple branches when profitable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG')
-rw-r--r--test/Transforms/SimplifyCFG/common-dest-folding.ll29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/common-dest-folding.ll b/test/Transforms/SimplifyCFG/common-dest-folding.ll
index 10fb7d497d..0aa3b2c560 100644
--- a/test/Transforms/SimplifyCFG/common-dest-folding.ll
+++ b/test/Transforms/SimplifyCFG/common-dest-folding.ll
@@ -25,4 +25,33 @@ define i32 @foo(i32 %k, i32 %c1, i32 %c2) {
ret i32 undef
}
+;CHECK: @conduse
+;CHECK: shl i32 1, %c1
+;CHECK-NEXT: shl i32 1, %c2
+;CHECK-NEXT: and i32
+;CHECK-NEXT: icmp eq i32
+;CHECK-NEXT: and i32
+;CHECK-NEXT: icmp eq i32
+;CHECK: ret
+define i32 @conduse(i32 %k, i32 %c1, i32 %c2) #0 {
+bb:
+ %tmp = shl i32 1, %c1
+ %tmp4 = shl i32 1, %c2
+ %tmp1 = and i32 %tmp, %k
+ %tmp2 = icmp eq i32 %tmp1, 0
+ br i1 %tmp2, label %bb9, label %bb3
+
+bb3: ; preds = %bb
+ %tmp5 = and i32 %tmp4, %k
+ %tmp6 = icmp eq i32 %tmp5, 0
+ br i1 %tmp6, label %bb9, label %bb7
+
+bb7: ; preds = %bb3
+ %tmp8 = tail call i32 (...)* @bar() #1
+ br label %bb9
+
+bb9: ; preds = %bb7, %bb3, %bb
+ ret i32 undef
+}
+
declare i32 @bar(...)