mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 17:31:33 +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:
parent
7eaf057e54
commit
f7cca7b8f8
@ -349,11 +349,8 @@ bool LoopIndexSplit::processOneIterationLoop() {
|
||||
// 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 @@ void LoopIndexSplit::moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user