diff options
author | Devang Patel <dpatel@apple.com> | 2009-08-07 17:16:44 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-08-07 17:16:44 +0000 |
commit | b1106fbdbc1d1b9b9f76bc44c6290fc865e5dada (patch) | |
tree | 4e1a9d14613e4fd834494c115899354c65d60d54 | |
parent | f53fab87d80bb26cb76a4938dc48b69fc5cfc91b (diff) | |
download | bcm5719-llvm-b1106fbdbc1d1b9b9f76bc44c6290fc865e5dada.tar.gz bcm5719-llvm-b1106fbdbc1d1b9b9f76bc44c6290fc865e5dada.zip |
Fix dom frontier update. This fixes PR4667.
Patch by Jakub Staszak.
llvm-svn: 78388
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopRotation.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index d2b20fa611e..8c5de3e9cec 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -511,26 +511,30 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) { DF->addBasicBlock(L->getHeader(), LatchSet); } - // If a loop block dominates new loop latch then its frontier is - // new header and Exit. + // If a loop block dominates new loop latch then add to its frontiers + // new header and Exit and remove new latch (which is equal to original + // header). BasicBlock *NewLatch = L->getLoopLatch(); - DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>(); - for (Loop::block_iterator BI = L->block_begin(), BE = L->block_end(); - BI != BE; ++BI) { - BasicBlock *B = *BI; - if (DT->dominates(B, NewLatch)) { - DominanceFrontier::iterator BDFI = DF->find(B); - if (BDFI != DF->end()) { - DominanceFrontier::DomSetType &BSet = BDFI->second; - BSet = BDFI->second; - BSet.clear(); - BSet.insert(L->getHeader()); - BSet.insert(Exit); - } else { - DominanceFrontier::DomSetType BSet; - BSet.insert(L->getHeader()); - BSet.insert(Exit); - DF->addBasicBlock(B, BSet); + + assert(NewLatch == OrigHeader && "NewLatch is inequal to OrigHeader"); + + if (DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>()) { + for (Loop::block_iterator BI = L->block_begin(), BE = L->block_end(); + BI != BE; ++BI) { + BasicBlock *B = *BI; + if (DT->dominates(B, NewLatch)) { + DominanceFrontier::iterator BDFI = DF->find(B); + if (BDFI != DF->end()) { + DominanceFrontier::DomSetType &BSet = BDFI->second; + BSet.erase(NewLatch); + BSet.insert(L->getHeader()); + BSet.insert(Exit); + } else { + DominanceFrontier::DomSetType BSet; + BSet.insert(L->getHeader()); + BSet.insert(Exit); + DF->addBasicBlock(B, BSet); + } } } } |