diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 365589dc0da..911545d86f3 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -281,17 +281,15 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L, // If this instruction is dead now, delete it. RecursivelyDeleteTriviallyDeadInstructions(Inst); - // 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 (ExitBlocks.size() == 1) { + if (NumPreds == 1) { + // Completely replace a single-pred PHI. This is safe, because the + // NewVal won't be variant in the loop, so we don't need an LCSSA phi + // node anymore. PN->replaceAllUsesWith(ExitVal); RecursivelyDeleteTriviallyDeadInstructions(PN); - break; } } - if (ExitBlocks.size() != 1) { + if (NumPreds != 1) { // Clone the PHI and delete the original one. This lets IVUsers and // any other maps purge the original user from their records. PHINode *NewPN = PN->clone(*Context); |