diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-09-06 02:26:10 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-09-06 02:26:10 +0000 |
commit | 904199547b790d831683605a3e0f0fb5a233ff2a (patch) | |
tree | ce675911551d225cc7e7eb5d30d81d0053fe5557 /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 94bcae46d5c0481970c126a78ec62487e3dec735 (diff) | |
download | bcm5719-llvm-904199547b790d831683605a3e0f0fb5a233ff2a.tar.gz bcm5719-llvm-904199547b790d831683605a3e0f0fb5a233ff2a.zip |
Revert r80926. It causes loop unswitch assertion and slow down some JIT tests significantly.
llvm-svn: 81101
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 36709f7b435..56e5a46cb78 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -69,8 +69,8 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { // We need loop information to identify the loops... - AU.addRequiredTransitive<LoopInfo>(); - AU.addRequiredTransitive<DominatorTree>(); + AU.addRequired<LoopInfo>(); + AU.addRequired<DominatorTree>(); AU.addPreserved<LoopInfo>(); AU.addPreserved<DominatorTree>(); @@ -83,13 +83,9 @@ namespace { void verifyAnalysis() const { #ifndef NDEBUG LoopInfo *NLI = &getAnalysis<LoopInfo>(); - for (LoopInfo::iterator I = NLI->begin(), E = NLI->end(); I != E; ++I) { - // Sanity check: Check basic loop invariants. + for (LoopInfo::iterator I = NLI->begin(), E = NLI->end(); I != E; ++I) (*I)->verifyLoop(); - // Check the special guarantees that LoopSimplify makes. - assert((*I)->isLoopSimplifyForm()); - } -#endif +#endif } private: @@ -350,6 +346,15 @@ BasicBlock *LoopSimplify::InsertPreheaderForLoop(Loop *L) { BasicBlock *NewBB = SplitBlockPredecessors(Header, &OutsideBlocks[0], OutsideBlocks.size(), ".preheader", this); + + + //===--------------------------------------------------------------------===// + // Update analysis results now that we have performed the transformation + // + + // We know that we have loop information to update... update it now. + if (Loop *Parent = L->getParentLoop()) + Parent->addBasicBlockToLoop(NewBB, LI->getBase()); // Make sure that NewBB is put someplace intelligent, which doesn't mess up // code layout too horribly. @@ -372,6 +377,17 @@ BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) { LoopBlocks.size(), ".loopexit", this); + // Update Loop Information - we know that the new block will be in whichever + // loop the Exit block is in. Note that it may not be in that immediate loop, + // if the successor is some other loop header. In that case, we continue + // walking up the loop tree to find a loop that contains both the successor + // block and the predecessor block. + Loop *SuccLoop = LI->getLoopFor(Exit); + while (SuccLoop && !SuccLoop->contains(L->getHeader())) + SuccLoop = SuccLoop->getParentLoop(); + if (SuccLoop) + SuccLoop->addBasicBlockToLoop(NewBB, LI->getBase()); + return NewBB; } @@ -505,6 +521,10 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L) { else LI->changeTopLevelLoop(L, NewOuter); + // This block is going to be our new header block: add it to this loop and all + // parent loops. + NewOuter->addBasicBlockToLoop(NewBB, LI->getBase()); + // L is now a subloop of our outer loop. NewOuter->addChildLoop(L); @@ -512,10 +532,6 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L) { I != E; ++I) NewOuter->addBlockEntry(*I); - // Now reset the header in L, which had been moved by - // SplitBlockPredecessors for the outer loop. - L->moveToHeader(Header); - // Determine which blocks should stay in L and which should be moved out to // the Outer loop now. std::set<BasicBlock*> BlocksInL; |