[llvm-commits] CVS: llvm/lib/Analysis/LoopInfo.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu May 15 13:08:01 PDT 2003


Changes in directory llvm/lib/Analysis:

LoopInfo.cpp updated: 1.36 -> 1.37

---
Log message:

Fix bug: Analysis/LoopInfo/2003-05-15-NestingProblem.ll


---
Diffs of the changes:

Index: llvm/lib/Analysis/LoopInfo.cpp
diff -u llvm/lib/Analysis/LoopInfo.cpp:1.36 llvm/lib/Analysis/LoopInfo.cpp:1.37
--- llvm/lib/Analysis/LoopInfo.cpp:1.36	Sat Apr 26 14:34:18 2003
+++ llvm/lib/Analysis/LoopInfo.cpp	Thu May 15 13:03:51 2003
@@ -122,6 +122,12 @@
 #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 @@
       // 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





More information about the llvm-commits mailing list