diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-14 01:09:02 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-14 01:09:02 +0000 |
commit | 65d1e2b6e74fcd370093cbe518ebc15cbc445ad4 (patch) | |
tree | 5a0c2c13f04ddb9f735b3de426ceaa69400b2230 /lib | |
parent | a342026504e65e2c8dc5600dab4b45ab4f94026d (diff) |
Fix indvars to not assume that a loop with a single unique exit
block has a single unique exiting block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 365589dc0d..911545d86f 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/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); |