diff options
author | Jinsong Ji <jji@us.ibm.com> | 2019-06-07 14:54:47 +0000 |
---|---|---|
committer | Jinsong Ji <jji@us.ibm.com> | 2019-06-07 14:54:47 +0000 |
commit | 7aafdef62711c4da98a622658152aaed43d49696 (patch) | |
tree | def025953526fdee965133c90fa061833e9d2a62 /llvm/lib/CodeGen | |
parent | 088410ffc6b82be18344e278f5136f501948bc3b (diff) | |
download | bcm5719-llvm-7aafdef62711c4da98a622658152aaed43d49696.tar.gz bcm5719-llvm-7aafdef62711c4da98a622658152aaed43d49696.zip |
[MachineScheduler] checkResourceLimit boundary condition update
When we call checkResourceLimit in bumpCycle or bumpNode, and we
know the resource count has just reached the limit (the equations
are equal). We should return true to mark that we are resource
limited for next schedule, or else we might continue to schedule
in favor of latency for 1 more schedule and create a schedule that
actually overbook the resource.
When we call checkResourceLimit to estimate the resource limite before
scheduling, we don't need to return true even if the equations are
equal, as it shouldn't limit the schedule for it .
Differential Revision: https://reviews.llvm.org/D62345
llvm-svn: 362805
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MachineScheduler.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 92c051d5c46..ae1170ad1be 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -1837,9 +1837,15 @@ SchedBoundary::~SchedBoundary() { delete HazardRec; } /// Given a Count of resource usage and a Latency value, return true if a /// SchedBoundary becomes resource limited. +/// If we are checking after scheduling a node, we should return true when +/// we just reach the resource limit. static bool checkResourceLimit(unsigned LFactor, unsigned Count, - unsigned Latency) { - return (int)(Count - (Latency * LFactor)) > (int)LFactor; + unsigned Latency, bool AfterSchedNode) { + int ResCntFactor = (int)(Count - (Latency * LFactor)); + if (AfterSchedNode) + return ResCntFactor >= (int)LFactor; + else + return ResCntFactor > (int)LFactor; } void SchedBoundary::reset() { @@ -2134,7 +2140,7 @@ void SchedBoundary::bumpCycle(unsigned NextCycle) { CheckPending = true; IsResourceLimited = checkResourceLimit(SchedModel->getLatencyFactor(), getCriticalCount(), - getScheduledLatency()); + getScheduledLatency(), true); LLVM_DEBUG(dbgs() << "Cycle: " << CurrCycle << ' ' << Available.getName() << '\n'); @@ -2302,7 +2308,7 @@ void SchedBoundary::bumpNode(SUnit *SU) { // resource limited. If a stall occurred, bumpCycle does this. IsResourceLimited = checkResourceLimit(SchedModel->getLatencyFactor(), getCriticalCount(), - getScheduledLatency()); + getScheduledLatency(), true); // Update CurrMOps after calling bumpCycle to handle stalls, since bumpCycle // resets CurrMOps. Loop to handle instructions with more MOps than issue in @@ -2521,7 +2527,7 @@ void GenericSchedulerBase::setPolicy(CandPolicy &Policy, bool IsPostRA, RemLatency = computeRemLatency(CurrZone); RemLatencyComputed = true; OtherResLimited = checkResourceLimit(SchedModel->getLatencyFactor(), - OtherCount, RemLatency); + OtherCount, RemLatency, false); } // Schedule aggressively for latency in PostRA mode. We don't check for |