summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-07-25 07:26:35 +0000
committerAndrew Trick <atrick@apple.com>2013-07-25 07:26:35 +0000
commit13372886a6d387c8847143744f26790a250f4360 (patch)
tree16c5a3c88ce07ad23791a765f15637f189822383 /lib/CodeGen/MachineScheduler.cpp
parent4b43ed53b6b4aec95d7c7003e70cb74ac58886e7 (diff)
downloadexternal_llvm-13372886a6d387c8847143744f26790a250f4360.zip
external_llvm-13372886a6d387c8847143744f26790a250f4360.tar.gz
external_llvm-13372886a6d387c8847143744f26790a250f4360.tar.bz2
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
Diffstat (limited to 'lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--lib/CodeGen/MachineScheduler.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp
index 19e86d7..4e3cc3c 100644
--- a/lib/CodeGen/MachineScheduler.cpp
+++ b/lib/CodeGen/MachineScheduler.cpp
@@ -2024,6 +2024,30 @@ static bool tryGreater(int TryVal, int CandVal,
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) {
return (isTop) ? SU->WeakPredsLeft : SU->WeakSuccsLeft;
}
@@ -2089,15 +2113,15 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
TryCand, Cand, PhysRegCopy))
return;
- // Avoid exceeding the target's limit.
- if (tryLess(TryCand.RPDelta.Excess.UnitIncrease,
- Cand.RPDelta.Excess.UnitIncrease, TryCand, Cand, RegExcess))
+ // Avoid exceeding the target's limit. If signed PSetID is negative, it is
+ // invalid; convert it to INT_MAX to give it lowest priority.
+ if (tryPressure(TryCand.RPDelta.Excess, Cand.RPDelta.Excess, TryCand, Cand,
+ RegExcess))
return;
// Avoid increasing the max critical pressure in the scheduled region.
- if (tryLess(TryCand.RPDelta.CriticalMax.UnitIncrease,
- Cand.RPDelta.CriticalMax.UnitIncrease,
- TryCand, Cand, RegCritical))
+ if (tryPressure(TryCand.RPDelta.CriticalMax, Cand.RPDelta.CriticalMax,
+ TryCand, Cand, RegCritical))
return;
// Keep clustered nodes together to encourage downstream peephole
@@ -2119,8 +2143,8 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
return;
}
// Avoid increasing the max pressure of the entire region.
- if (tryLess(TryCand.RPDelta.CurrentMax.UnitIncrease,
- Cand.RPDelta.CurrentMax.UnitIncrease, TryCand, Cand, RegMax))
+ if (tryPressure(TryCand.RPDelta.CurrentMax, Cand.RPDelta.CurrentMax,
+ TryCand, Cand, RegMax))
return;
// Avoid critical resource consumption and balance the schedule.