diff options
author | Dan Gohman <gohman@apple.com> | 2008-07-21 21:45:02 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-07-21 21:45:02 +0000 |
commit | 7ad3cd8c9db6edfd9dbbd31fabe793c4032e5f31 (patch) | |
tree | acd86c1dc435b2ea91bd43aa578f36bd295e4b09 /llvm/lib | |
parent | 7ed03c4cdd58ef60896d3ce0cdc766185daff02b (diff) | |
download | bcm5719-llvm-7ad3cd8c9db6edfd9dbbd31fabe793c4032e5f31.tar.gz bcm5719-llvm-7ad3cd8c9db6edfd9dbbd31fabe793c4032e5f31.zip |
Fix a bug in LSR's dead-PHI cleanup. If a PHI has a def-use chain that
leads into a cycle involving a different PHI, LSR got stuck running
around that cycle looking for the original PHI. To avoid this, keep
track of visited PHIs and stop searching if we see one more than once.
This fixes PR2570.
llvm-svn: 53879
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 5bbc8322bc6..83bdb2cd176 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1823,6 +1823,7 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) { // FIXME: this needs to eliminate an induction variable even if it's being // compared against some value to decide loop termination. if (PN->hasOneUse()) { + SmallPtrSet<PHINode *, 2> PHIs; for (Instruction *J = dyn_cast<Instruction>(*PN->use_begin()); J && J->hasOneUse() && !J->mayWriteToMemory(); J = dyn_cast<Instruction>(*J->use_begin())) { @@ -1835,6 +1836,10 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) { Changed = true; break; } + // If we find a PHI more than once, we're on a cycle that + // won't prove fruitful. + if (isa<PHINode>(J) && !PHIs.insert(cast<PHINode>(J))) + break; } } } |