aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-11-18 19:59:41 +0000
committerDuncan Sands <baldrick@free.fr>2010-11-18 19:59:41 +0000
commitd0c6f3dafd7c3e9137d4e6415014c94137fcd3fc (patch)
tree99b6f88540f7b3c4a552911c4020f9e8a42ab9eb /lib/Analysis/ScalarEvolution.cpp
parent707120047e0107cb15dd4bbb31613df129b13c7a (diff)
Factor code for testing whether replacing one value with another
preserves LCSSA form out of ScalarEvolution and into the LoopInfo class. Use it to check that SimplifyInstruction simplifications are not breaking LCSSA form. Fixes PR8622. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 04ec67f5b3..9db46a8639 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -2768,25 +2768,10 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
// PHI's incoming blocks are in a different loop, in which case doing so
// risks breaking LCSSA form. Instcombine would normally zap these, but
// it doesn't have DominatorTree information, so it may miss cases.
- if (Value *V = SimplifyInstruction(PN, TD, DT)) {
- Instruction *I = dyn_cast<Instruction>(V);
- // Only instructions are problematic for preserving LCSSA form.
- if (!I)
+ if (Value *V = SimplifyInstruction(PN, TD, DT))
+ if (LI->replacementPreservesLCSSAForm(PN, V))
return getSCEV(V);
- // If the instruction is not defined in a loop, then it can be used freely.
- Loop *ILoop = LI->getLoopFor(I->getParent());
- if (!ILoop)
- return getSCEV(I);
-
- // If the instruction is defined in the same loop as the phi node, or in a
- // loop that contains the phi node loop as an inner loop, then using it as
- // a replacement for the phi node will not break LCSSA form.
- Loop *PNLoop = LI->getLoopFor(PN->getParent());
- if (ILoop->contains(PNLoop))
- return getSCEV(I);
- }
-
// If it's not a loop phi, we can't handle it yet.
return getUnknown(PN);
}