mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Don't count PHI instructions toward the limit for tail duplicating a block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90326 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -129,20 +129,22 @@ bool TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB,
|
|||||||
|
|
||||||
// Check the instructions in the block to determine whether tail-duplication
|
// Check the instructions in the block to determine whether tail-duplication
|
||||||
// is invalid or unlikely to be profitable.
|
// is invalid or unlikely to be profitable.
|
||||||
unsigned i = 0;
|
unsigned InstrCount = 0;
|
||||||
bool HasCall = false;
|
bool HasCall = false;
|
||||||
for (MachineBasicBlock::iterator I = TailBB->begin();
|
for (MachineBasicBlock::iterator I = TailBB->begin();
|
||||||
I != TailBB->end(); ++I, ++i) {
|
I != TailBB->end(); ++I) {
|
||||||
// Non-duplicable things shouldn't be tail-duplicated.
|
// Non-duplicable things shouldn't be tail-duplicated.
|
||||||
if (I->getDesc().isNotDuplicable()) return false;
|
if (I->getDesc().isNotDuplicable()) return false;
|
||||||
// Don't duplicate more than the threshold.
|
// Don't duplicate more than the threshold.
|
||||||
if (i == MaxDuplicateCount) return false;
|
if (InstrCount == MaxDuplicateCount) return false;
|
||||||
// Remember if we saw a call.
|
// Remember if we saw a call.
|
||||||
if (I->getDesc().isCall()) HasCall = true;
|
if (I->getDesc().isCall()) HasCall = true;
|
||||||
|
if (I->getOpcode() != TargetInstrInfo::PHI)
|
||||||
|
InstrCount += 1;
|
||||||
}
|
}
|
||||||
// Heuristically, don't tail-duplicate calls if it would expand code size,
|
// Heuristically, don't tail-duplicate calls if it would expand code size,
|
||||||
// as it's less likely to be worth the extra cost.
|
// as it's less likely to be worth the extra cost.
|
||||||
if (i > 1 && HasCall)
|
if (InstrCount > 1 && HasCall)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Iterate through all the unique predecessors and tail-duplicate this
|
// Iterate through all the unique predecessors and tail-duplicate this
|
||||||
|
Reference in New Issue
Block a user