mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
MI Sched: Register pressure heuristics.
Consider which set is being increased or decreased before comparing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4b43ed53b6
commit
13372886a6
@ -99,6 +99,10 @@ struct PressureElement {
|
|||||||
PressureElement(unsigned id, int inc): PSetID(id), UnitIncrease(inc) {}
|
PressureElement(unsigned id, int inc): PSetID(id), UnitIncrease(inc) {}
|
||||||
|
|
||||||
bool isValid() const { return PSetID != ~0U; }
|
bool isValid() const { return PSetID != ~0U; }
|
||||||
|
|
||||||
|
// If signed PSetID is negative, it is invalid; convert it to INT_MAX to give
|
||||||
|
// it lowest priority.
|
||||||
|
int PSetRank() const { return PSetID & INT_MAX; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Store the effects of a change in pressure on things that MI scheduler cares
|
/// Store the effects of a change in pressure on things that MI scheduler cares
|
||||||
|
@ -2024,6 +2024,30 @@ static bool tryGreater(int TryVal, int CandVal,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool tryPressure(const PressureElement &TryP,
|
||||||
|
const PressureElement &CandP,
|
||||||
|
ConvergingScheduler::SchedCandidate &TryCand,
|
||||||
|
ConvergingScheduler::SchedCandidate &Cand,
|
||||||
|
ConvergingScheduler::CandReason Reason) {
|
||||||
|
// If both candidates affect the same set, go with the smallest increase.
|
||||||
|
if (TryP.PSetID == CandP.PSetID) {
|
||||||
|
return tryLess(TryP.UnitIncrease, CandP.UnitIncrease, TryCand, Cand,
|
||||||
|
Reason);
|
||||||
|
}
|
||||||
|
// If one candidate decreases and the other increases, go with it.
|
||||||
|
if (tryLess(TryP.UnitIncrease < 0, CandP.UnitIncrease < 0, TryCand, Cand,
|
||||||
|
Reason)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// If TryP has lower Rank, it has a higher priority.
|
||||||
|
int TryRank = TryP.PSetRank();
|
||||||
|
int CandRank = CandP.PSetRank();
|
||||||
|
// If the candidates are decreasing pressure, reverse priority.
|
||||||
|
if (TryP.UnitIncrease < 0)
|
||||||
|
std::swap(TryRank, CandRank);
|
||||||
|
return tryGreater(TryRank, CandRank, TryCand, Cand, Reason);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned getWeakLeft(const SUnit *SU, bool isTop) {
|
static unsigned getWeakLeft(const SUnit *SU, bool isTop) {
|
||||||
return (isTop) ? SU->WeakPredsLeft : SU->WeakSuccsLeft;
|
return (isTop) ? SU->WeakPredsLeft : SU->WeakSuccsLeft;
|
||||||
}
|
}
|
||||||
@ -2089,15 +2113,15 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
|
|||||||
TryCand, Cand, PhysRegCopy))
|
TryCand, Cand, PhysRegCopy))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Avoid exceeding the target's limit.
|
// Avoid exceeding the target's limit. If signed PSetID is negative, it is
|
||||||
if (tryLess(TryCand.RPDelta.Excess.UnitIncrease,
|
// invalid; convert it to INT_MAX to give it lowest priority.
|
||||||
Cand.RPDelta.Excess.UnitIncrease, TryCand, Cand, RegExcess))
|
if (tryPressure(TryCand.RPDelta.Excess, Cand.RPDelta.Excess, TryCand, Cand,
|
||||||
|
RegExcess))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Avoid increasing the max critical pressure in the scheduled region.
|
// Avoid increasing the max critical pressure in the scheduled region.
|
||||||
if (tryLess(TryCand.RPDelta.CriticalMax.UnitIncrease,
|
if (tryPressure(TryCand.RPDelta.CriticalMax, Cand.RPDelta.CriticalMax,
|
||||||
Cand.RPDelta.CriticalMax.UnitIncrease,
|
TryCand, Cand, RegCritical))
|
||||||
TryCand, Cand, RegCritical))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Keep clustered nodes together to encourage downstream peephole
|
// Keep clustered nodes together to encourage downstream peephole
|
||||||
@ -2119,8 +2143,8 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid increasing the max pressure of the entire region.
|
// Avoid increasing the max pressure of the entire region.
|
||||||
if (tryLess(TryCand.RPDelta.CurrentMax.UnitIncrease,
|
if (tryPressure(TryCand.RPDelta.CurrentMax, Cand.RPDelta.CurrentMax,
|
||||||
Cand.RPDelta.CurrentMax.UnitIncrease, TryCand, Cand, RegMax))
|
TryCand, Cand, RegMax))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Avoid critical resource consumption and balance the schedule.
|
// Avoid critical resource consumption and balance the schedule.
|
||||||
|
Loading…
Reference in New Issue
Block a user