[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 27 15:51:01 PST 2003


Changes in directory llvm/lib/Transforms/Scalar:

LoopPreheaders.cpp updated: 1.5 -> 1.6

---
Log message:

  * Don't forget to update Loop information!
  * Remove bogus assertion: there may be a single outside predecessor and 
    still need a new loop-preheader if the predecessor has multiple 
    successors.  See bug: LICM/2003-02-27-PreheaderProblem.ll



---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp
diff -u llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.5 llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.6
--- llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.5	Thu Feb 27 14:27:08 2003
+++ llvm/lib/Transforms/Scalar/LoopPreheaders.cpp	Thu Feb 27 15:50:19 2003
@@ -179,8 +179,6 @@
       if (!L->contains(*PI))           // Coming in from outside the loop?
         OutsideBlocks.push_back(*PI);  // Keep track of it...
   
-  assert(OutsideBlocks.size() != 1 && "Loop already has a preheader!");
-  
   // Split out the loop pre-header
   BasicBlock *NewBB =
     SplitBlockPredecessors(Header, ".preheader", OutsideBlocks);
@@ -281,6 +279,11 @@
   BasicBlock *NewBB =
     SplitBlockPredecessors(Exit, ".loopexit", LoopBlocks);
   
+  // Update Loop Information - we know that the new block will be in the parent
+  // loop of L.
+  if (Loop *Parent = L->getParentLoop())
+    Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>());
+
   // Update dominator information...  The blocks that dominate NewBB are the
   // intersection of the dominators of predecessors, plus the block itself.
   // The newly created basic block does not dominate anything except itself.
@@ -363,6 +366,5 @@
         }
       }
     }
-
   }
 }





More information about the llvm-commits mailing list