Fix PR404: Loop simplify is really slow on 252.eon

This eliminates an N*N*logN algorithm from the loop simplify pass, replacing
it with a much simpler and faster alternative.  In a debug build, this reduces
gccas time on eon from 85s to 42s.

llvm-svn: 14851
This commit is contained in:
Chris Lattner 2004-07-15 04:27:04 +00:00
parent a4d8ce6399
commit 70177e402d
1 changed files with 12 additions and 12 deletions

View File

@ -147,6 +147,9 @@ bool LoopSimplify::ProcessLoop(Loop *L) {
Changed = true;
}
DominatorSet &DS = getAnalysis<DominatorSet>(); // Update dominator info
// Next, check to make sure that all exit nodes of the loop only have
// predecessors that are inside of the loop. This check guarantees that the
// loop preheader/header will dominate the exit blocks. If the exit block has
@ -155,9 +158,7 @@ bool LoopSimplify::ProcessLoop(Loop *L) {
L->getExitBlocks(ExitBlocks);
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
BasicBlock *ExitBlock = ExitBlocks[i];
for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock);
PI != PE; ++PI)
if (!L->contains(*PI)) {
if (!DS.dominates(L->getHeader(), ExitBlock)) {
BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock);
for (unsigned j = i; j != ExitBlocks.size(); ++j)
if (ExitBlocks[j] == ExitBlock)
@ -165,7 +166,6 @@ bool LoopSimplify::ProcessLoop(Loop *L) {
NumInserted++;
Changed = true;
break;
}
}