aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-02-20 00:28:00 +0000
committerChris Lattner <sabre@nondot.org>2003-02-20 00:28:00 +0000
commit3a9a56e7b2f574b946edc0abb5dfa19e40f82ec1 (patch)
treedd2f45f5d4a05537612337d45a789c2340f99f2a /lib/Analysis/LoopInfo.cpp
parentae5d39e1bba338e41911d5e002c96c88d7618db8 (diff)
Fix the requisite bug that I introduced
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5605 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r--lib/Analysis/LoopInfo.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index ef4b6430ba..70bf97cacc 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -155,17 +155,19 @@ Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, const DominatorSet &DS) {
// now by moving the loop into the correct subloop.
//
Loop *SubLoop = BBMI->second;
- Loop *OldSubLoopParent = SubLoop->getParentLoop();
- if (OldSubLoopParent != L) {
- // Remove SubLoop from OldSubLoopParent's list of subloops...
- std::vector<Loop*>::iterator I =
- std::find(OldSubLoopParent->SubLoops.begin(),
- OldSubLoopParent->SubLoops.end(), SubLoop);
- assert(I != OldSubLoopParent->SubLoops.end()
- && "Loop parent doesn't contain loop?");
- OldSubLoopParent->SubLoops.erase(I);
- SubLoop->ParentLoop = L;
- L->SubLoops.push_back(SubLoop);
+ if (SubLoop->getHeader() == *I) { // Only do this once for the loop...
+ Loop *OldSubLoopParent = SubLoop->getParentLoop();
+ if (OldSubLoopParent != L) {
+ // Remove SubLoop from OldSubLoopParent's list of subloops...
+ std::vector<Loop*>::iterator I =
+ std::find(OldSubLoopParent->SubLoops.begin(),
+ OldSubLoopParent->SubLoops.end(), SubLoop);
+ assert(I != OldSubLoopParent->SubLoops.end()
+ && "Loop parent doesn't contain loop?");
+ OldSubLoopParent->SubLoops.erase(I);
+ SubLoop->ParentLoop = L;
+ L->SubLoops.push_back(SubLoop);
+ }
}
}
}