summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopRotation.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-08-07 17:16:44 +0000
committerDevang Patel <dpatel@apple.com>2009-08-07 17:16:44 +0000
commitb7f40c1a2a74fe9bd98cfab3d0ff139a8510fdfe (patch)
tree2f2b4b2df440a0372a84dec9e01405eb2aef061f /lib/Transforms/Scalar/LoopRotation.cpp
parentbdab0e9695b8082a0d656c5e96a35561246bb906 (diff)
downloadllvm-b7f40c1a2a74fe9bd98cfab3d0ff139a8510fdfe.tar.gz
llvm-b7f40c1a2a74fe9bd98cfab3d0ff139a8510fdfe.tar.bz2
llvm-b7f40c1a2a74fe9bd98cfab3d0ff139a8510fdfe.tar.xz
Fix dom frontier update. This fixes PR4667.
Patch by Jakub Staszak. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78388 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopRotation.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopRotation.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp
index d2b20fa611..8c5de3e9ce 100644
--- a/lib/Transforms/Scalar/LoopRotation.cpp
+++ b/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);
+ }
}
}
}