summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-14 01:09:02 +0000
committerDan Gohman <gohman@apple.com>2009-07-14 01:09:02 +0000
commit03d5d0f4519c1723866b1253b0a3125d7ce16da5 (patch)
tree1a6b8f4d06aa4780e4fa63f176c52d5145d7a117 /llvm/lib/Transforms
parent6f6d86481594a025df4008a2fae172122b4750b4 (diff)
downloadbcm5719-llvm-03d5d0f4519c1723866b1253b0a3125d7ce16da5.tar.gz
bcm5719-llvm-03d5d0f4519c1723866b1253b0a3125d7ce16da5.zip
Fix indvars to not assume that a loop with a single unique exit
block has a single unique exiting block. llvm-svn: 75579
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp12
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);
OpenPOWER on IntegriCloud