summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/BasicBlock.cpp
diff options
context:
space:
mode:
authorJingyue Wu <jingyue@google.com>2015-05-15 17:54:48 +0000
committerJingyue Wu <jingyue@google.com>2015-05-15 17:54:48 +0000
commit154eb5aa1d9c829715d13c9a047d4498be4d2e2a (patch)
tree3e7a47b1737c62724e40b83a620e11141a000abc /llvm/lib/IR/BasicBlock.cpp
parent1675b4a57f21b01e5b78f2ba95fb37945acff831 (diff)
downloadbcm5719-llvm-154eb5aa1d9c829715d13c9a047d4498be4d2e2a.tar.gz
bcm5719-llvm-154eb5aa1d9c829715d13c9a047d4498be4d2e2a.zip
Add a speculative execution pass
Summary: This is a pass for speculative execution of instructions for simple if-then (triangle) control flow. It's aimed at GPUs, but could perhaps be used in other contexts. Enabling this pass gives us a 1.0% geomean improvement on Google benchmark suites, with one benchmark improving 33%. Credit goes to Jingyue Wu for writing an earlier version of this pass. Patched by Bjarke Roune. Test Plan: This patch adds a set of tests in test/Transforms/SpeculativeExecution/spec.ll The pass is controlled by a flag which defaults to having the pass not run. Reviewers: eliben, dberlin, meheff, jingyue, hfinkel Reviewed By: jingyue, hfinkel Subscribers: majnemer, jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D9360 llvm-svn: 237459
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
-rw-r--r--llvm/lib/IR/BasicBlock.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 23ec7052954..e6a4585a936 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -238,6 +238,14 @@ BasicBlock *BasicBlock::getUniquePredecessor() {
return PredBB;
}
+BasicBlock *BasicBlock::getSingleSuccessor() {
+ succ_iterator SI = succ_begin(this), E = succ_end(this);
+ if (SI == E) return nullptr; // no successors
+ BasicBlock *TheSucc = *SI;
+ ++SI;
+ return (SI == E) ? TheSucc : nullptr /* multiple successors */;
+}
+
BasicBlock *BasicBlock::getUniqueSuccessor() {
succ_iterator SI = succ_begin(this), E = succ_end(this);
if (SI == E) return NULL; // No successors
OpenPOWER on IntegriCloud