diff options
| author | Dan Gohman <gohman@apple.com> | 2010-09-04 02:42:48 +0000 | 
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-09-04 02:42:48 +0000 | 
| commit | 487e25010991791944833b35833f2b775b585edd (patch) | |
| tree | a1600fce7c73adc2dd36e8c44ba46bdbecd92ed0 /llvm/lib/Transforms/Utils | |
| parent | 20779ee157f510fb7adb2001e63e1d5ef1b64835 (diff) | |
| download | bcm5719-llvm-487e25010991791944833b35833f2b775b585edd.tar.gz bcm5719-llvm-487e25010991791944833b35833f2b775b585edd.zip  | |
Fix LoopSimplify to notify ScalarEvolution when splitting a loop backedge
into an inner loop, as the new loop iteration may differ substantially.
This fixes PR8078.
llvm-svn: 113057
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 11 | 
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 2f0a175d5cd..b3c4801a4f1 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -46,6 +46,7 @@  #include "llvm/LLVMContext.h"  #include "llvm/Type.h"  #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/ScalarEvolution.h"  #include "llvm/Analysis/Dominators.h"  #include "llvm/Analysis/LoopPass.h"  #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -71,6 +72,7 @@ namespace {      AliasAnalysis *AA;      LoopInfo *LI;      DominatorTree *DT; +    ScalarEvolution *SE;      Loop *L;      virtual bool runOnLoop(Loop *L, LPPassManager &LPM); @@ -83,7 +85,7 @@ namespace {        AU.addPreserved<LoopInfo>();        AU.addPreserved<AliasAnalysis>(); -      AU.addPreserved("scalar-evolution"); +      AU.addPreserved<ScalarEvolution>();        AU.addPreservedID(BreakCriticalEdgesID);  // No critical edges added.        AU.addPreserved<DominanceFrontier>();        AU.addPreservedID(LCSSAID); @@ -121,6 +123,7 @@ bool LoopSimplify::runOnLoop(Loop *l, LPPassManager &LPM) {    LI = &getAnalysis<LoopInfo>();    AA = getAnalysisIfAvailable<AliasAnalysis>();    DT = &getAnalysis<DominatorTree>(); +  SE = getAnalysisIfAvailable<ScalarEvolution>();    Changed |= ProcessLoop(L, LPM); @@ -532,6 +535,12 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L, LPPassManager &LPM) {    DEBUG(dbgs() << "LoopSimplify: Splitting out a new outer loop\n"); +  // If ScalarEvolution is around and knows anything about values in +  // this loop, tell it to forget them, because we're about to +  // substantially change it. +  if (SE) +    SE->forgetLoop(L); +    BasicBlock *Header = L->getHeader();    BasicBlock *NewBB = SplitBlockPredecessors(Header, &OuterLoopPreds[0],                                               OuterLoopPreds.size(),  | 

