[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Jul 15 01:20:33 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
LoopSimplify.cpp updated: 1.46 -> 1.47
---
Log message:
Fix PR404: http://llvm.cs.uiuc.edu/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 :)
---
Diffs of the changes: (+8 -8)
Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.46 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.47
--- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.46 Thu Jul 15 00:36:31 2004
+++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Thu Jul 15 03:20:22 2004
@@ -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 @@
// 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.
More information about the llvm-commits
mailing list