diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-07-15 08:20:22 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-07-15 08:20:22 +0000 | 
| commit | f2c018c0c1300695d14d37e1af1aed9c26dbf8a9 (patch) | |
| tree | 93808cccffbed3afe5bfba95d2030dc420e7d467 /llvm/lib/Transforms/Scalar | |
| parent | 9b1f3dc99076eaee7b52607b1f50921e1e2517c2 (diff) | |
| download | bcm5719-llvm-f2c018c0c1300695d14d37e1af1aed9c26dbf8a9.tar.gz bcm5719-llvm-f2c018c0c1300695d14d37e1af1aed9c26dbf8a9.zip  | |
Fix PR404 try #2
This version takes about 1s longer than the previous one (down to 2.35s),
but on the positive side, it actually works :)
llvm-svn: 14856
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopSimplify.cpp | 16 | 
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp index b2752089d44..ada858e1dda 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp @@ -43,6 +43,7 @@  #include "llvm/Support/CFG.h"  #include "llvm/Transforms/Utils/Local.h"  #include "Support/SetOperations.h" +#include "Support/SetVector.h"  #include "Support/Statistic.h"  #include "Support/DepthFirstIterator.h"  using namespace llvm; @@ -153,21 +154,20 @@ bool LoopSimplify::ProcessLoop(Loop *L) {    // predecessors from outside of the loop, split the edge now.    std::vector<BasicBlock*> ExitBlocks;    L->getExitBlocks(ExitBlocks); -  for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { -    BasicBlock *ExitBlock = ExitBlocks[i]; + +  SetVector<BasicBlock*> ExitBlockSet(ExitBlocks.begin(), ExitBlocks.end()); +  for (SetVector<BasicBlock*>::iterator I = ExitBlockSet.begin(), +         E = ExitBlockSet.end(); I != E; ++I) { +    BasicBlock *ExitBlock = *I;      for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock);           PI != PE; ++PI)        if (!L->contains(*PI)) { -        BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock); -        for (unsigned j = i; j != ExitBlocks.size(); ++j) -          if (ExitBlocks[j] == ExitBlock) -            ExitBlocks[j] = NewBB; - +        RewriteLoopExitBlock(L, ExitBlock);          NumInserted++;          Changed = true;          break;        } -    } +  }    // If the header has more than two predecessors at this point (from the    // preheader and from multiple backedges), we must adjust the loop.  | 

