mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +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:
parent
d30f168616
commit
c69908695a
@ -216,19 +216,24 @@ bool JumpThreading::runOnFunction(Function &F) {
|
||||
}
|
||||
|
||||
/// getJumpThreadDuplicationCost - Return the cost of duplicating this block to
|
||||
/// thread across it.
|
||||
static unsigned getJumpThreadDuplicationCost(const BasicBlock *BB) {
|
||||
/// thread across it. Stop scanning the block when passing the threshold.
|
||||
static unsigned getJumpThreadDuplicationCost(const BasicBlock *BB,
|
||||
unsigned Threshold) {
|
||||
/// Ignore PHI nodes, these will be flattened when duplication happens.
|
||||
BasicBlock::const_iterator I = BB->getFirstNonPHI();
|
||||
|
||||
// FIXME: THREADING will delete values that are just used to compute the
|
||||
// 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
|
||||
// include the terminator because the copy won't include it.
|
||||
unsigned Size = 0;
|
||||
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.
|
||||
if (isa<DbgInfoIntrinsic>(I)) continue;
|
||||
|
||||
@ -1337,7 +1342,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB,
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
|
||||
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB, Threshold);
|
||||
if (JumpThreadCost > Threshold) {
|
||||
DEBUG(dbgs() << " Not threading BB '" << BB->getName()
|
||||
<< "' - Cost is too high: " << JumpThreadCost << "\n");
|
||||
@ -1481,7 +1486,7 @@ bool JumpThreading::DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB,
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned DuplicationCost = getJumpThreadDuplicationCost(BB);
|
||||
unsigned DuplicationCost = getJumpThreadDuplicationCost(BB, Threshold);
|
||||
if (DuplicationCost > Threshold) {
|
||||
DEBUG(dbgs() << " Not duplicating BB '" << BB->getName()
|
||||
<< "' - Cost is too high: " << DuplicationCost << "\n");
|
||||
|
Loading…
Reference in New Issue
Block a user