summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-05-15 18:03:51 +0000
committerChris Lattner <sabre@nondot.org>2003-05-15 18:03:51 +0000
commit0e416df2b292e2b5c0dfe89ced8a610e852dd155 (patch)
treec166976eab61f3db7de0a7b0e1896ad9aa4ecbee /llvm/lib/Analysis/LoopInfo.cpp
parentb4cb0090a585205cbb61205b30a0861a7de62ffd (diff)
downloadbcm5719-llvm-0e416df2b292e2b5c0dfe89ced8a610e852dd155.tar.gz
bcm5719-llvm-0e416df2b292e2b5c0dfe89ced8a610e852dd155.zip
Fix bug: Analysis/LoopInfo/2003-05-15-NestingProblem.ll
llvm-svn: 6230
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 7a1daa089e2..251714cb002 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -122,6 +122,12 @@ void LoopInfo::print(std::ostream &OS) const {
#endif
}
+static bool isNotAlreadyContainedIn(Loop *SubLoop, Loop *ParentLoop) {
+ if (SubLoop == 0) return true;
+ if (SubLoop == ParentLoop) return false;
+ return isNotAlreadyContainedIn(SubLoop->getParentLoop(), ParentLoop);
+}
+
Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, const DominatorSet &DS) {
if (BBMap.find(BB) != BBMap.end()) return 0; // Haven't processed this node?
@@ -150,7 +156,7 @@ Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, const DominatorSet &DS) {
// this child loop gets added to a part of the current loop, making it a
// sibling to the current loop. We have to reparent this loop.
if (Loop *SubLoop = const_cast<Loop*>(getLoopFor(X)))
- if (SubLoop->getHeader() == X && X != BB) {
+ if (SubLoop->getHeader() == X && isNotAlreadyContainedIn(SubLoop, L)) {
// Remove the subloop from it's current parent...
assert(SubLoop->ParentLoop && SubLoop->ParentLoop != L);
Loop *SLP = SubLoop->ParentLoop; // SubLoopParent
OpenPOWER on IntegriCloud