From e1d4fb3c2cf6b71c40293f9f18c92a0a14f29f7a Mon Sep 17 00:00:00 2001 From: Chris Lattner <sabre@nondot.org> Date: Thu, 27 Feb 2003 21:51:38 +0000 Subject: [PATCH] Fix bug: LICM/2003-02-27-PreheaderProblem.ll There may be a single outside predecessor and still need a new loop-preheader if the predecessor has multiple successors. llvm-svn: 5656 --- lib/Analysis/LoopInfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index a361e629e1a..035f92c33c3 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -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.