summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-08-02 00:14:16 +0000
committerChris Lattner <sabre@nondot.org>2006-08-02 00:14:16 +0000
commit4d074f795a0a52e379b2dfaa89a08f720b7ac727 (patch)
treee285d1e98a51215e9ed87c78f30e1466a2ed2e97 /llvm/lib/Analysis
parent5a2bc786be0655287aebec4bfb2dcc6cccd9fd2a (diff)
downloadbcm5719-llvm-4d074f795a0a52e379b2dfaa89a08f720b7ac727.tar.gz
bcm5719-llvm-4d074f795a0a52e379b2dfaa89a08f720b7ac727.zip
Speed up Loop::isLCSSAForm by using a binary search and single-entry cache.
This reduces LCSSA pass time from 1.5s to 0.96s when run on eon in release+asserts mode. llvm-svn: 29464
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 49162a66353..0ea513368dc 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -480,10 +480,15 @@ Value *Loop::getTripCount() const {
}
/// isLCSSAForm - Return true if the Loop is in LCSSA form
-bool Loop::isLCSSAForm() const {
- for (Loop::block_iterator BB = block_begin(), E = block_end();
- BB != E; ++BB) {
- for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end(); I != E; ++I)
+bool Loop::isLCSSAForm() const {
+ // Sort the blocks vector so that we can use binary search to do quick
+ // lookups.
+ std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
+ std::sort(LoopBBs.begin(), LoopBBs.end());
+
+ for (unsigned i = 0, e = LoopBBs.size(); i != e; ++i) {
+ BasicBlock *BB = LoopBBs[i];
+ for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
++UI) {
BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
@@ -492,9 +497,12 @@ bool Loop::isLCSSAForm() const {
UserBB = p->getIncomingBlock(OperandNo/2);
}
- if (!contains(UserBB)) {
+ // Check the current block, as a fast-path. Most values are used in the
+ // same block they are defined in.
+ if (UserBB != BB &&
+ // Otherwise, binary search LoopBBs for this block.
+ !std::binary_search(LoopBBs.begin(), LoopBBs.end(), UserBB))
return false;
- }
}
}
OpenPOWER on IntegriCloud