mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Refactor loop condition check in a separate function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ea0fa97334
commit
dc52395353
@ -105,6 +105,13 @@ namespace {
|
|||||||
|
|
||||||
/// Find cost of spliting loop L.
|
/// Find cost of spliting loop L.
|
||||||
unsigned findSplitCost(Loop *L, SplitInfo &SD);
|
unsigned findSplitCost(Loop *L, SplitInfo &SD);
|
||||||
|
|
||||||
|
/// safeSplitCondition - Return true if it is possible to
|
||||||
|
/// split loop using given split condition.
|
||||||
|
bool safeSplitCondition(SplitInfo &SD);
|
||||||
|
|
||||||
|
/// splitLoop - Split current loop L in two loops using split information
|
||||||
|
/// SD. Update dominator information. Maintain LCSSA form.
|
||||||
bool splitLoop(SplitInfo &SD);
|
bool splitLoop(SplitInfo &SD);
|
||||||
|
|
||||||
void initialize() {
|
void initialize() {
|
||||||
@ -705,32 +712,28 @@ void LoopIndexSplit::removeBlocks(BasicBlock *DeadBB, Loop *LP,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// splitLoop - Split current loop L in two loops using split information
|
/// safeSplitCondition - Return true if it is possible to
|
||||||
/// SD. Update dominator information. Maintain LCSSA form.
|
/// split loop using given split condition.
|
||||||
bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
|
bool LoopIndexSplit::safeSplitCondition(SplitInfo &SD) {
|
||||||
|
|
||||||
// True loop is original loop. False loop is cloned loop.
|
BasicBlock *SplitCondBlock = SD.SplitCondition->getParent();
|
||||||
|
|
||||||
BasicBlock *TL_Preheader = L->getLoopPreheader();
|
// Unable to handle triange loops at the moment.
|
||||||
BasicBlock *TL_SplitCondBlock = SD.SplitCondition->getParent();
|
|
||||||
BasicBlock *TL_Latch = L->getLoopLatch();
|
|
||||||
BasicBlock *TL_Header = L->getHeader();
|
|
||||||
BranchInst *TL_SplitTerminator =
|
|
||||||
cast<BranchInst>(TL_SplitCondBlock->getTerminator());
|
|
||||||
|
|
||||||
// FIXME - Unable to handle triange loops at the moment.
|
|
||||||
// In triangle loop, split condition is in header and one of the
|
// In triangle loop, split condition is in header and one of the
|
||||||
// the split destination is loop latch. If split condition is EQ
|
// the split destination is loop latch. If split condition is EQ
|
||||||
// then such loops are already handle in processOneIterationLoop().
|
// then such loops are already handle in processOneIterationLoop().
|
||||||
BasicBlock *Succ0 = TL_SplitTerminator->getSuccessor(0);
|
BasicBlock *Latch = L->getLoopLatch();
|
||||||
BasicBlock *Succ1 = TL_SplitTerminator->getSuccessor(1);
|
BranchInst *SplitTerminator =
|
||||||
if (TL_Header == TL_SplitCondBlock
|
cast<BranchInst>(SplitCondBlock->getTerminator());
|
||||||
&& (TL_Latch == Succ0 || TL_Latch == Succ1))
|
BasicBlock *Succ0 = SplitTerminator->getSuccessor(0);
|
||||||
|
BasicBlock *Succ1 = SplitTerminator->getSuccessor(1);
|
||||||
|
if (L->getHeader() == SplitCondBlock
|
||||||
|
&& (Latch == Succ0 || Latch == Succ1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If one of the split condition branch is post dominating other then loop
|
// If one of the split condition branch is post dominating other then loop
|
||||||
// index split is not appropriate.
|
// index split is not appropriate.
|
||||||
if (DT->dominates(Succ0, TL_Latch) || DT->dominates(Succ1, TL_Latch))
|
if (DT->dominates(Succ0, Latch) || DT->dominates(Succ1, Latch))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If one of the split condition branch is a predecessor of the other
|
// If one of the split condition branch is a predecessor of the other
|
||||||
@ -744,6 +747,20 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
|
|||||||
if (Succ0 == *PI)
|
if (Succ0 == *PI)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// splitLoop - Split current loop L in two loops using split information
|
||||||
|
/// SD. Update dominator information. Maintain LCSSA form.
|
||||||
|
bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
|
||||||
|
|
||||||
|
if (!safeSplitCondition(SD))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// True loop is original loop. False loop is cloned loop.
|
||||||
|
BasicBlock *TL_SplitCondBlock = SD.SplitCondition->getParent();
|
||||||
|
BasicBlock *TL_Preheader = L->getLoopPreheader();
|
||||||
|
|
||||||
bool SignedPredicate = ExitCondition->isSignedPredicate();
|
bool SignedPredicate = ExitCondition->isSignedPredicate();
|
||||||
//[*] Calculate True loop's new Exit Value in loop preheader.
|
//[*] Calculate True loop's new Exit Value in loop preheader.
|
||||||
// TL_ExitValue = min(SplitValue, ExitValue)
|
// TL_ExitValue = min(SplitValue, ExitValue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user