summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LoopSimplify.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-21 00:54:38 +0000
committerChris Lattner <sabre@nondot.org>2008-04-21 00:54:38 +0000
commitb85979434df1c11799b84292339a47d2e317b573 (patch)
tree3965f96fea0f3ed9304895e87946bfdf8b192178 /lib/Transforms/Utils/LoopSimplify.cpp
parent48a80b07bd6856130eefc7478084b8c9c6d65d90 (diff)
downloadllvm-b85979434df1c11799b84292339a47d2e317b573.tar.gz
llvm-b85979434df1c11799b84292339a47d2e317b573.tar.bz2
llvm-b85979434df1c11799b84292339a47d2e317b573.tar.xz
Factor dominator tree and frontier updating into SplitBlockPredecessors
instead of doing it after every call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index f3e6417f44..b90f46f717 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -263,17 +263,18 @@ ReprocessLoop:
/// SplitBlockPredecessors - Split the specified block into two blocks. We want
/// to move the predecessors specified in the Preds list to point to the new
/// block, leaving the remaining predecessors pointing to BB. This method
-/// updates the SSA PHINode's and AliasAnalysis, but no other analyses.
+/// updates the SSA PHINode's, AliasAnalysis, DominatorTree and
+/// DominanceFrontier, but no other analyses.
///
BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
const char *Suffix,
const std::vector<BasicBlock*> &Preds) {
- // Create new basic block, insert right before the original block...
+ // Create new basic block, insert right before the original block.
BasicBlock *NewBB =
BasicBlock::Create(BB->getName()+Suffix, BB->getParent(), BB);
- // The preheader first gets an unconditional branch to the loop header...
+ // The preheader first gets an unconditional branch to the loop header.
BranchInst *BI = BranchInst::Create(BB, NewBB);
// For every PHI node in the block, insert a PHI node into NewBB where the
@@ -288,6 +289,11 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
// Insert dummy values as the incoming value...
PN->addIncoming(Constant::getNullValue(PN->getType()), NewBB);
}
+
+ DT->splitBlock(NewBB);
+ if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
+ DF->splitBlock(NewBB);
+
return NewBB;
}
@@ -336,7 +342,7 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
// If I is in NewBB, the Dominator call will fail, because NewBB isn't
// registered in DominatorTree yet. Handle this case explicitly.
if (!I || (I->getParent() != NewBB &&
- getAnalysis<DominatorTree>().dominates(I, PN))) {
+ DT->dominates(I, PN))) {
PN->replaceAllUsesWith(V);
if (AA) AA->deleteValue(PN);
BB->getInstList().erase(PN);
@@ -357,6 +363,10 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
Preds[i]->setUnwindDest(NewBB);
}
+ DT->splitBlock(NewBB);
+ if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
+ DF->splitBlock(NewBB);
+
return NewBB;
}
@@ -387,10 +397,6 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
if (Loop *Parent = L->getParentLoop())
Parent->addBasicBlockToLoop(NewBB, LI->getBase());
- DT->splitBlock(NewBB);
- if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
- DF->splitBlock(NewBB);
-
// Make sure that NewBB is put someplace intelligent, which doesn't mess up
// code layout too horribly.
PlaceSplitBlockCarefully(NewBB, OutsideBlocks, L);
@@ -419,11 +425,6 @@ BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
if (SuccLoop)
SuccLoop->addBasicBlockToLoop(NewBB, LI->getBase());
- // Update Dominator Information
- DT->splitBlock(NewBB);
- if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
- DF->splitBlock(NewBB);
-
return NewBB;
}
@@ -543,11 +544,6 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L) {
BasicBlock *Header = L->getHeader();
BasicBlock *NewBB = SplitBlockPredecessors(Header, ".outer", OuterLoopPreds);
- // Update dominator information
- DT->splitBlock(NewBB);
- if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
- DF->splitBlock(NewBB);
-
// Make sure that NewBB is put someplace intelligent, which doesn't mess up
// code layout too horribly.
PlaceSplitBlockCarefully(NewBB, OuterLoopPreds, L);