Fix bug: LICM/2003-02-27-PreheaderProblem.ll
authorChris Lattner <sabre@nondot.org>
Thu, 27 Feb 2003 21:51:38 +0000 (21:51 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 27 Feb 2003 21:51:38 +0000 (21:51 +0000)
There may be a single outside predecessor and
still need a new loop-preheader if the predecessor has multiple
successors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5656 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LoopInfo.cpp

index a361e629e1a41e0ff3b75849a39b71ea55b5c773..035f92c33c3b37aa10f50a2fd40a9f4b6a4eca58 100644 (file)
@@ -200,6 +200,13 @@ BasicBlock *Loop::getLoopPreheader() const {
         return 0;             // Multiple predecessors outside the loop
       Out = *PI;
     }
+  
+  // Make sure there is only one exit out of the preheader...
+  succ_iterator SI = succ_begin(Out);
+  ++SI;
+  if (SI != succ_end(Out))
+    return 0;  // Multiple exits from the block, must not be a preheader.
+
 
   // If there is exactly one preheader, return it.  If there was zero, then Out
   // is still null.