aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-11-10 04:13:31 +0000
committerNadav Rotem <nrotem@apple.com>2013-11-10 04:13:31 +0000
commit30150a128c7b2488225331417153ccec75bac65c (patch)
tree9dda8d3f33330407319195c979403e9202b568e2
parent20f1fe5c50c1a8ea69e635b4928c7f46e10c8cac (diff)
downloadexternal_llvm-30150a128c7b2488225331417153ccec75bac65c.zip
external_llvm-30150a128c7b2488225331417153ccec75bac65c.tar.gz
external_llvm-30150a128c7b2488225331417153ccec75bac65c.tar.bz2
SimplifyCFG has a heuristics for out-of-order processors that decides when it is worthwhile to merge branches. It tries to estimate if the operands of the instruction that we want to hoist are ready. This commit marks function arguments as 'ready' because they require no calculation. This boosts libquantum and a few other workloads from the testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194346 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp2
-rw-r--r--test/Transforms/SimplifyCFG/common-dest-folding.ll28
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 1398697..d36d9dc 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2096,7 +2096,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) {
for (Instruction::op_iterator OI = BonusInst->op_begin(),
OE = BonusInst->op_end(); OI != OE; ++OI) {
Value *V = *OI;
- if (!isa<Constant>(V))
+ if (!isa<Constant>(V) && !isa<Argument>(V))
UsedValues.insert(V);
}
diff --git a/test/Transforms/SimplifyCFG/common-dest-folding.ll b/test/Transforms/SimplifyCFG/common-dest-folding.ll
new file mode 100644
index 0000000..10fb7d4
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/common-dest-folding.ll
@@ -0,0 +1,28 @@
+; RUN: opt < %s -simplifycfg -S | FileCheck %s
+
+;CHECK: @foo
+;CHECK: and i32 %c1, %k
+;CHECK: icmp eq i32
+;CHECK: and i32 %c2, %k
+;CHECK: icmp eq i32
+;CHECK: or i1
+;CHECK: ret
+define i32 @foo(i32 %k, i32 %c1, i32 %c2) {
+ %1 = and i32 %c1, %k
+ %2 = icmp eq i32 %1, 0
+ br i1 %2, label %8, label %3
+
+; <label>:3 ; preds = %0
+ %4 = and i32 %c2, %k
+ %5 = icmp eq i32 %4, 0
+ br i1 %5, label %8, label %6
+
+; <label>:6 ; preds = %3
+ %7 = tail call i32 (...)* @bar() nounwind
+ br label %8
+
+; <label>:8 ; preds = %3, %0, %6
+ ret i32 undef
+}
+
+declare i32 @bar(...)