diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-19 16:37:30 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-19 16:37:30 +0000 |
| commit | a225ed8d2b661a5ceb6f108930b3f889501d929f (patch) | |
| tree | 306f1ea72fc85f69106cf33df3fadaa1a32186e8 /llvm/lib/Analysis/ScalarEvolutionExpander.cpp | |
| parent | 2afd661685aea4ce232ab67554f0aa3110317619 (diff) | |
| download | bcm5719-llvm-a225ed8d2b661a5ceb6f108930b3f889501d929f.tar.gz bcm5719-llvm-a225ed8d2b661a5ceb6f108930b3f889501d929f.zip | |
SCEVExpander: Don't crash when trying to merge two constant phis.
Just constant fold them so they can't cause any trouble. Fixes PR12627.
llvm-svn: 166286
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 5c2a49e767f..f18c50e0709 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -1618,6 +1618,17 @@ unsigned SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT, PEnd = Phis.end(); PIter != PEnd; ++PIter) { PHINode *Phi = *PIter; + // Fold constant phis. They may be congruent to other constant phis and + // would confuse the logic below that expects proper IVs. + if (Value *V = Phi->hasConstantValue()) { + Phi->replaceAllUsesWith(V); + DeadInsts.push_back(Phi); + ++NumElim; + DEBUG_WITH_TYPE(DebugType, dbgs() + << "INDVARS: Eliminated constant iv: " << *Phi << '\n'); + continue; + } + if (!SE.isSCEVable(Phi->getType())) continue; |

