diff options
author | Michael Kuperstein <mkuper@google.com> | 2017-01-10 19:32:30 +0000 |
---|---|---|
committer | Michael Kuperstein <mkuper@google.com> | 2017-01-10 19:32:30 +0000 |
commit | ee31cbe35f03bb6440fee8cc750e85bf38bccd86 (patch) | |
tree | 844f664984990ec094ee75ab3d7d3c006ae043ed /llvm/lib/Transforms | |
parent | ef1adad9387f669feb9179df43a987187f74dbb9 (diff) | |
download | bcm5719-llvm-ee31cbe35f03bb6440fee8cc750e85bf38bccd86.tar.gz bcm5719-llvm-ee31cbe35f03bb6440fee8cc750e85bf38bccd86.zip |
[LV] Don't panic when encountering the IV of an outer loop.
Bail out instead of asserting when we encounter this situation,
which can actually happen.
The reason the test uses the new PM is that the "bad" phi, incidentally, gets
cleaned up by LoopSimplify. But LICM can create this kind of phi and preserve
loop simplify form, so the cleanup has no chance to run.
This fixes PR31190.
We may want to solve this in a less conservative manner, since this phi is
actually uniform within the inner loop (or we may want LICM to output a cleaner
promotion to begin with).
Differential Revision: https://reviews.llvm.org/D28490
llvm-svn: 291589
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 09e9f1ddc7f..c8efa9efc7f 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -869,8 +869,13 @@ bool InductionDescriptor::isInductionPHI(PHINode *Phi, const Loop *TheLoop, return false; } - assert(TheLoop->getHeader() == Phi->getParent() && - "PHI is an AddRec for a different loop?!"); + if (AR->getLoop() != TheLoop) { + // FIXME: We should treat this as a uniform. Unfortunately, we + // don't currently know how to handled uniform PHIs. + DEBUG(dbgs() << "LV: PHI is a recurrence with respect to an outer loop.\n"); + return false; + } + Value *StartValue = Phi->getIncomingValueForBlock(AR->getLoop()->getLoopPreheader()); const SCEV *Step = AR->getStepRecurrence(*SE); |