diff options
author | Chris Lattner <sabre@nondot.org> | 2003-02-27 22:48:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-02-27 22:48:57 +0000 |
commit | f2d9f94a3337ff5a585d5dc6f5a79862caaed309 (patch) | |
tree | 126815208164322600a0ab8efa5b3bd16ea902c6 /llvm/lib/Transforms | |
parent | 9eaef21f1f3b77bec6d10cada423c8b037d85a14 (diff) | |
download | bcm5719-llvm-f2d9f94a3337ff5a585d5dc6f5a79862caaed309.tar.gz bcm5719-llvm-f2d9f94a3337ff5a585d5dc6f5a79862caaed309.zip |
Fix bug: 2003-02-27-PreheaderExitNodeUpdate.ll by updating exit node info
llvm-svn: 5664
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopSimplify.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp index e40f1457ae4..c5adfd25534 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp @@ -192,6 +192,22 @@ void Preheaders::InsertPreheaderForLoop(Loop *L) { // We know that we have loop information to update... update it now. if (Loop *Parent = L->getParentLoop()) Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>()); + + // If the header for the loop used to be an exit node for another loop, then + // we need to update this to know that the loop-preheader is now the exit + // node. Note that the only loop that could have our header as an exit node + // is a sibling loop, ie, one with the same parent loop. + const std::vector<Loop*> *ParentSubLoops; + if (Loop *Parent = L->getParentLoop()) + ParentSubLoops = &Parent->getSubLoops(); + else // Must check top-level loops... + ParentSubLoops = &getAnalysis<LoopInfo>().getTopLevelLoops(); + + // Loop over all sibling loops, performing the substitution... + for (unsigned i = 0, e = ParentSubLoops->size(); i != e; ++i) + if ((*ParentSubLoops)[i]->hasExitBlock(Header)) + (*ParentSubLoops)[i]->changeExitBlock(Header, NewBB); + DominatorSet &DS = getAnalysis<DominatorSet>(); // Update dominator info { |