diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-12 01:27:58 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-12 01:27:58 +0000 |
commit | efb9fbfdab6cab88146792a5db79315313270c7f (patch) | |
tree | c876f192e8aa148006478913ebf98fcf056976d4 /lib/Analysis/ScalarEvolution.cpp | |
parent | 42a5875e107a5dea72745574b0215d9bcdf6deb4 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71533 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 5cd9739e22..a71db865cb 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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(); |