diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-10-31 23:21:40 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-10-31 23:21:40 +0000 |
commit | 337d4786e1532b3545f3e58b6844aaade713afbd (patch) | |
tree | ee38e7b35eea6006a0cd654f7e9b62dd24971178 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | f25d25a156ab3b7b4db2fe7daca314b85a98adcb (diff) | |
download | bcm5719-llvm-337d4786e1532b3545f3e58b6844aaade713afbd.tar.gz bcm5719-llvm-337d4786e1532b3545f3e58b6844aaade713afbd.zip |
[SCEV] Don't create SCEV expressions that break LCSSA
Prevent `createNodeFromSelectLikePHI` from creating SCEV expressions
that break LCSSA.
A better fix for the same issue is to teach SCEVExpander to not break
LCSSA by inserting PHI nodes at appropriate places. That's planned for
the future.
Fixes PR25360.
llvm-svn: 251756
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index a24b154ab96..e7380682d9f 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3943,6 +3943,11 @@ const SCEV *ScalarEvolution::createNodeFromSelectLikePHI(PHINode *PN) { if (PN->getNumIncomingValues() == 2) { const Loop *L = LI.getLoopFor(PN->getParent()); + // We don't want to break LCSSA, even in a SCEV expression tree. + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + if (LI.getLoopFor(PN->getIncomingBlock(i)) != L) + return nullptr; + // Try to match // // br %cond, label %left, label %right |