diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2017-10-25 08:23:33 +0000 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2017-10-25 08:23:33 +0000 |
commit | 238c14b6c7970b1d6f48ef2c5ad35c772f1dee3d (patch) | |
tree | fd0d0274e868ff656924367cdc63726e063b14dd /llvm/lib/CodeGen/MachineScheduler.cpp | |
parent | dd45ea16f3e4ed9aba5b5f70d35edaa15abcf354 (diff) | |
download | bcm5719-llvm-238c14b6c7970b1d6f48ef2c5ad35c772f1dee3d.tar.gz bcm5719-llvm-238c14b6c7970b1d6f48ef2c5ad35c772f1dee3d.zip |
[MachineScheduler] Minor refactoring.
Duplicated code found in three places put into a new static function:
/// Given a Count of resource usage and a Latency value, return true if a
/// SchedBoundary becomes resource limited.
static bool checkResourceLimit(unsigned LFactor, unsigned Count,
unsigned Latency) {
return (int)(Count - (Latency * LFactor)) > (int)LFactor;
}
Review: Florian Hahn, Matthias Braun
https://reviews.llvm.org/D39235
llvm-svn: 316560
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineScheduler.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 674e83cf808..3e12bdcd689 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -1831,6 +1831,13 @@ static const unsigned InvalidCycle = ~0U; SchedBoundary::~SchedBoundary() { delete HazardRec; } +/// Given a Count of resource usage and a Latency value, return true if a +/// SchedBoundary becomes resource limited. +static bool checkResourceLimit(unsigned LFactor, unsigned Count, + unsigned Latency) { + return (int)(Count - (Latency * LFactor)) > (int)LFactor; +} + void SchedBoundary::reset() { // A new HazardRec is created for each DAG and owned by SchedBoundary. // Destroying and reconstructing it is very expensive though. So keep @@ -2085,10 +2092,9 @@ void SchedBoundary::bumpCycle(unsigned NextCycle) { } } CheckPending = true; - unsigned LFactor = SchedModel->getLatencyFactor(); IsResourceLimited = - (int)(getCriticalCount() - (getScheduledLatency() * LFactor)) - > (int)LFactor; + checkResourceLimit(SchedModel->getLatencyFactor(), getCriticalCount(), + getScheduledLatency()); DEBUG(dbgs() << "Cycle: " << CurrCycle << ' ' << Available.getName() << '\n'); } @@ -2241,16 +2247,15 @@ void SchedBoundary::bumpNode(SUnit *SU) { << " BotLatency SU(" << SU->NodeNum << ") " << BotLatency << "c\n"); } // If we stall for any reason, bump the cycle. - if (NextCycle > CurrCycle) { + if (NextCycle > CurrCycle) bumpCycle(NextCycle); - } else { + else // After updating ZoneCritResIdx and ExpectedLatency, check if we're // resource limited. If a stall occurred, bumpCycle does this. - unsigned LFactor = SchedModel->getLatencyFactor(); IsResourceLimited = - (int)(getCriticalCount() - (getScheduledLatency() * LFactor)) - > (int)LFactor; - } + checkResourceLimit(SchedModel->getLatencyFactor(), getCriticalCount(), + getScheduledLatency()); + // Update CurrMOps after calling bumpCycle to handle stalls, since bumpCycle // resets CurrMOps. Loop to handle instructions with more MOps than issue in // one cycle. Since we commonly reach the max MOps here, opportunistically @@ -2435,10 +2440,10 @@ void GenericSchedulerBase::setPolicy(CandPolicy &Policy, bool IsPostRA, OtherZone ? OtherZone->getOtherResourceCount(OtherCritIdx) : 0; bool OtherResLimited = false; - if (SchedModel->hasInstrSchedModel()) { - unsigned LFactor = SchedModel->getLatencyFactor(); - OtherResLimited = (int)(OtherCount - (RemLatency * LFactor)) > (int)LFactor; - } + if (SchedModel->hasInstrSchedModel()) + OtherResLimited = checkResourceLimit(SchedModel->getLatencyFactor(), + OtherCount, RemLatency); + // Schedule aggressively for latency in PostRA mode. We don't check for // acyclic latency during PostRA, and highly out-of-order processors will // skip PostRA scheduling. |