From 78ea89e161c0b40b730020c94121ed2922933603 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 22 Jun 2009 00:15:15 +0000 Subject: [PATCH] Fix this code to correctly handle loops with multiple exits. Until now, this hasn't mattered, because ScalarEvolution hasn't been able to compute trip counts for loops with multiple exits. But it will soon. llvm-svn: 73864 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 429de9353696..326fb38909b5 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -299,11 +299,11 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L, // If this instruction is dead now, delete it. RecursivelyDeleteTriviallyDeadInstructions(Inst); - // See if this is a single-entry LCSSA PHI node. If so, we can (and - // have to) remove - // the PHI entirely. This is safe, because the NewVal won't be variant + // If we're inserting code into the exit block rather than the + // preheader, we can (and have to) remove the PHI entirely. + // This is safe, because the NewVal won't be variant // in the loop, so we don't need an LCSSA phi node anymore. - if (NumPreds == 1) { + if (ExitBlocks.size() == 1) { PN->replaceAllUsesWith(ExitVal); RecursivelyDeleteTriviallyDeadInstructions(PN); break;