mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Teach the jump threading optimization to stop scanning the basic block when calculating the cost after passing the threshold.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169135 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -216,19 +216,24 @@ bool JumpThreading::runOnFunction(Function &F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// getJumpThreadDuplicationCost - Return the cost of duplicating this block to
|
/// getJumpThreadDuplicationCost - Return the cost of duplicating this block to
|
||||||
/// thread across it.
|
/// thread across it. Stop scanning the block when passing the threshold.
|
||||||
static unsigned getJumpThreadDuplicationCost(const BasicBlock *BB) {
|
static unsigned getJumpThreadDuplicationCost(const BasicBlock *BB,
|
||||||
|
unsigned Threshold) {
|
||||||
/// Ignore PHI nodes, these will be flattened when duplication happens.
|
/// Ignore PHI nodes, these will be flattened when duplication happens.
|
||||||
BasicBlock::const_iterator I = BB->getFirstNonPHI();
|
BasicBlock::const_iterator I = BB->getFirstNonPHI();
|
||||||
|
|
||||||
// FIXME: THREADING will delete values that are just used to compute the
|
// FIXME: THREADING will delete values that are just used to compute the
|
||||||
// branch, so they shouldn't count against the duplication cost.
|
// branch, so they shouldn't count against the duplication cost.
|
||||||
|
|
||||||
|
|
||||||
// Sum up the cost of each instruction until we get to the terminator. Don't
|
// Sum up the cost of each instruction until we get to the terminator. Don't
|
||||||
// include the terminator because the copy won't include it.
|
// include the terminator because the copy won't include it.
|
||||||
unsigned Size = 0;
|
unsigned Size = 0;
|
||||||
for (; !isa<TerminatorInst>(I); ++I) {
|
for (; !isa<TerminatorInst>(I); ++I) {
|
||||||
|
|
||||||
|
// Stop scanning the block if we've reached the threshold.
|
||||||
|
if (Size > Threshold)
|
||||||
|
return Size;
|
||||||
|
|
||||||
// Debugger intrinsics don't incur code size.
|
// Debugger intrinsics don't incur code size.
|
||||||
if (isa<DbgInfoIntrinsic>(I)) continue;
|
if (isa<DbgInfoIntrinsic>(I)) continue;
|
||||||
|
|
||||||
@ -1337,7 +1342,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
|
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB, Threshold);
|
||||||
if (JumpThreadCost > Threshold) {
|
if (JumpThreadCost > Threshold) {
|
||||||
DEBUG(dbgs() << " Not threading BB '" << BB->getName()
|
DEBUG(dbgs() << " Not threading BB '" << BB->getName()
|
||||||
<< "' - Cost is too high: " << JumpThreadCost << "\n");
|
<< "' - Cost is too high: " << JumpThreadCost << "\n");
|
||||||
@ -1481,7 +1486,7 @@ bool JumpThreading::DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DuplicationCost = getJumpThreadDuplicationCost(BB);
|
unsigned DuplicationCost = getJumpThreadDuplicationCost(BB, Threshold);
|
||||||
if (DuplicationCost > Threshold) {
|
if (DuplicationCost > Threshold) {
|
||||||
DEBUG(dbgs() << " Not duplicating BB '" << BB->getName()
|
DEBUG(dbgs() << " Not duplicating BB '" << BB->getName()
|
||||||
<< "' - Cost is too high: " << DuplicationCost << "\n");
|
<< "' - Cost is too high: " << DuplicationCost << "\n");
|
||||||
|
Reference in New Issue
Block a user