forked from OSchip/llvm-project
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
This commit is contained in:
parent
5a2bc786be
commit
4d074f795a
|
@ -481,9 +481,14 @@ Value *Loop::getTripCount() const {
|
||||||
|
|
||||||
/// isLCSSAForm - Return true if the Loop is in LCSSA form
|
/// isLCSSAForm - Return true if the Loop is in LCSSA form
|
||||||
bool Loop::isLCSSAForm() const {
|
bool Loop::isLCSSAForm() const {
|
||||||
for (Loop::block_iterator BB = block_begin(), E = block_end();
|
// Sort the blocks vector so that we can use binary search to do quick
|
||||||
BB != E; ++BB) {
|
// lookups.
|
||||||
for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end(); I != E; ++I)
|
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;
|
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
|
||||||
++UI) {
|
++UI) {
|
||||||
BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
|
BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
|
||||||
|
@ -492,9 +497,12 @@ bool Loop::isLCSSAForm() const {
|
||||||
UserBB = p->getIncomingBlock(OperandNo/2);
|
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;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue