mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-18 10:24:45 +00:00
Fix loop-index-split to correctly preserve dominance frontiers. Part of
PR4238. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72244 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -349,11 +349,8 @@ bool LoopIndexSplit::processOneIterationLoop() {
|
|||||||
// If BR operands are not IV or not loop invariants then skip this loop.
|
// If BR operands are not IV or not loop invariants then skip this loop.
|
||||||
Value *OPV = SplitCondition->getOperand(0);
|
Value *OPV = SplitCondition->getOperand(0);
|
||||||
Value *SplitValue = SplitCondition->getOperand(1);
|
Value *SplitValue = SplitCondition->getOperand(1);
|
||||||
if (!L->isLoopInvariant(SplitValue)) {
|
if (!L->isLoopInvariant(SplitValue))
|
||||||
Value *T = SplitValue;
|
std::swap(OPV, SplitValue);
|
||||||
SplitValue = OPV;
|
|
||||||
OPV = T;
|
|
||||||
}
|
|
||||||
if (!L->isLoopInvariant(SplitValue))
|
if (!L->isLoopInvariant(SplitValue))
|
||||||
return false;
|
return false;
|
||||||
Instruction *OPI = dyn_cast<Instruction>(OPV);
|
Instruction *OPI = dyn_cast<Instruction>(OPV);
|
||||||
@@ -784,24 +781,22 @@ void LoopIndexSplit::moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
|
|||||||
DT->changeImmediateDominator(ExitBB, CondBB);
|
DT->changeImmediateDominator(ExitBB, CondBB);
|
||||||
DF->changeImmediateDominator(ExitBB, CondBB, DT);
|
DF->changeImmediateDominator(ExitBB, CondBB, DT);
|
||||||
|
|
||||||
// Basicblocks dominated by ActiveBB may have ExitingBB or
|
// Blocks outside the loop may have been in the dominance frontier of blocks
|
||||||
// a basic block outside the loop in their DF list. If so,
|
// inside the condition; this is now impossible because the blocks inside the
|
||||||
// replace it with CondBB.
|
// condition no loger dominate the exit. Remove the relevant blocks from
|
||||||
DomTreeNode *Node = DT->getNode(ActiveBB);
|
// the dominance frontiers.
|
||||||
for (df_iterator<DomTreeNode *> DI = df_begin(Node), DE = df_end(Node);
|
for (Loop::block_iterator I = LP->block_begin(), E = LP->block_end();
|
||||||
DI != DE; ++DI) {
|
I != E; ++I) {
|
||||||
BasicBlock *BB = DI->getBlock();
|
if (*I == CondBB || !DT->dominates(CondBB, *I)) continue;
|
||||||
DominanceFrontier::iterator BBDF = DF->find(BB);
|
DominanceFrontier::iterator BBDF = DF->find(*I);
|
||||||
DominanceFrontier::DomSetType::iterator DomSetI = BBDF->second.begin();
|
DominanceFrontier::DomSetType::iterator DomSetI = BBDF->second.begin();
|
||||||
DominanceFrontier::DomSetType::iterator DomSetE = BBDF->second.end();
|
DominanceFrontier::DomSetType::iterator DomSetE = BBDF->second.end();
|
||||||
while (DomSetI != DomSetE) {
|
while (DomSetI != DomSetE) {
|
||||||
DominanceFrontier::DomSetType::iterator CurrentItr = DomSetI;
|
DominanceFrontier::DomSetType::iterator CurrentItr = DomSetI;
|
||||||
++DomSetI;
|
++DomSetI;
|
||||||
BasicBlock *DFBB = *CurrentItr;
|
BasicBlock *DFBB = *CurrentItr;
|
||||||
if (DFBB == ExitingBB || !L->contains(DFBB)) {
|
if (!LP->contains(DFBB))
|
||||||
BBDF->second.erase(DFBB);
|
BBDF->second.erase(DFBB);
|
||||||
BBDF->second.insert(CondBB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user