[llvm-commits] [llvm] r72244 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Eli Friedman
eli.friedman at gmail.com
Thu May 21 20:22:50 PDT 2009
Author: efriedma
Date: Thu May 21 22:22:46 2009
New Revision: 72244
URL: http://llvm.org/viewvc/llvm-project?rev=72244&view=rev
Log:
Fix loop-index-split to correctly preserve dominance frontiers. Part of
PR4238.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=72244&r1=72243&r2=72244&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Thu May 21 22:22:46 2009
@@ -349,11 +349,8 @@
// If BR operands are not IV or not loop invariants then skip this loop.
Value *OPV = SplitCondition->getOperand(0);
Value *SplitValue = SplitCondition->getOperand(1);
- if (!L->isLoopInvariant(SplitValue)) {
- Value *T = SplitValue;
- SplitValue = OPV;
- OPV = T;
- }
+ if (!L->isLoopInvariant(SplitValue))
+ std::swap(OPV, SplitValue);
if (!L->isLoopInvariant(SplitValue))
return false;
Instruction *OPI = dyn_cast<Instruction>(OPV);
@@ -783,25 +780,23 @@
// ExitBB is now dominated by CondBB
DT->changeImmediateDominator(ExitBB, CondBB);
DF->changeImmediateDominator(ExitBB, CondBB, DT);
-
- // Basicblocks dominated by ActiveBB may have ExitingBB or
- // a basic block outside the loop in their DF list. If so,
- // replace it with CondBB.
- DomTreeNode *Node = DT->getNode(ActiveBB);
- for (df_iterator<DomTreeNode *> DI = df_begin(Node), DE = df_end(Node);
- DI != DE; ++DI) {
- BasicBlock *BB = DI->getBlock();
- DominanceFrontier::iterator BBDF = DF->find(BB);
+
+ // Blocks outside the loop may have been in the dominance frontier of blocks
+ // inside the condition; this is now impossible because the blocks inside the
+ // condition no loger dominate the exit. Remove the relevant blocks from
+ // the dominance frontiers.
+ for (Loop::block_iterator I = LP->block_begin(), E = LP->block_end();
+ I != E; ++I) {
+ if (*I == CondBB || !DT->dominates(CondBB, *I)) continue;
+ DominanceFrontier::iterator BBDF = DF->find(*I);
DominanceFrontier::DomSetType::iterator DomSetI = BBDF->second.begin();
DominanceFrontier::DomSetType::iterator DomSetE = BBDF->second.end();
while (DomSetI != DomSetE) {
DominanceFrontier::DomSetType::iterator CurrentItr = DomSetI;
++DomSetI;
BasicBlock *DFBB = *CurrentItr;
- if (DFBB == ExitingBB || !L->contains(DFBB)) {
+ if (!LP->contains(DFBB))
BBDF->second.erase(DFBB);
- BBDF->second.insert(CondBB);
- }
}
}
}
More information about the llvm-commits
mailing list