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 | 7375fbcbf261527638a08d80c8152778558c29d8 (patch) | |
tree | adb9231d9bb1f71f4c8bb1a2f58de4700800d9a4 /lib/Transforms | |
parent | 358033102ffaef4d1afb1c0b7e96440906f0b48f (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53879 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 5bbc8322bc..83bdb2cd17 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/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; } } } |