summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-05-12 01:27:58 +0000
committerDan Gohman <gohman@apple.com>2009-05-12 01:27:58 +0000
commitae451600fac14c8eb782c2f86ea8c921a4b41ba1 (patch)
tree31671df8ecbaa67384dcd26e457d7d6a10ee23c9 /llvm/lib/Analysis
parentd6c04461a437ca1a2164159b9885c98d6e1fd76d (diff)
downloadbcm5719-llvm-ae451600fac14c8eb782c2f86ea8c921a4b41ba1.tar.gz
bcm5719-llvm-ae451600fac14c8eb782c2f86ea8c921a4b41ba1.zip
When forgetting SCEVs for loop PHIs, don't forget SCEVUnknown values.
These values aren't analyzable, so they don't care if more information about the loop trip count can be had. Also, SCEVUnknown is used for a PHI while the PHI itself is being analyzed, so it needs to be left in the Scalars map. This fixes a variety of subtle issues. llvm-svn: 71533
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 5cd9739e223..a71db865cbf 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2309,10 +2309,20 @@ void ScalarEvolution::forgetLoopBackedgeTakenCount(const Loop *L) {
void ScalarEvolution::forgetLoopPHIs(const Loop *L) {
BasicBlock *Header = L->getHeader();
+ // Push all Loop-header PHIs onto the Worklist stack, except those
+ // that are presently represented via a SCEVUnknown. SCEVUnknown for
+ // a PHI either means that it has an unrecognized structure, or it's
+ // a PHI that's in the progress of being computed by createNodeForPHI.
+ // In the former case, additional loop trip count information isn't
+ // going to change anything. In the later case, createNodeForPHI will
+ // perform the necessary updates on its own when it gets to that point.
SmallVector<Instruction *, 16> Worklist;
for (BasicBlock::iterator I = Header->begin();
- PHINode *PN = dyn_cast<PHINode>(I); ++I)
- Worklist.push_back(PN);
+ PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+ std::map<SCEVCallbackVH, SCEVHandle>::iterator It = Scalars.find((Value*)I);
+ if (It != Scalars.end() && !isa<SCEVUnknown>(It->second))
+ Worklist.push_back(PN);
+ }
while (!Worklist.empty()) {
Instruction *I = Worklist.pop_back_val();
OpenPOWER on IntegriCloud