diff options
author | Lorenzo Casalino <lorenzo.casalino93@gmail.com> | 2020-01-01 19:53:16 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2020-01-01 20:22:32 +0000 |
commit | f9f78cf6ac73d9148be9b626f418bf6770e512f6 (patch) | |
tree | 01fcbc5bb618193ef97ccf11252543e963d0b304 /llvm/lib/CodeGen/MachineScheduler.cpp | |
parent | 11552433ebfc7243c0b66367bdffaba52e74b354 (diff) | |
download | bcm5719-llvm-f9f78cf6ac73d9148be9b626f418bf6770e512f6.tar.gz bcm5719-llvm-f9f78cf6ac73d9148be9b626f418bf6770e512f6.zip |
[MachineScheduler] improve reuse of 'releaseNode'method
The 'SchedBoundary::releaseNode' is merely invoked for releasing the Top/Bottom root nodes.
However, 'SchedBoundary::releasePending' uses its same logic to check if the Pending queue
has any releasable SUnit.
It is possible to slightly modify the body of the two, allowing re-use of the former ('releaseNode')
in the latter.
Patch by Lorenzo Casalino <lorenzo.casalino93@gmail.com>
Reviewers: MatzeB, fhahn, atrick
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D65506
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineScheduler.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index a10096606b6..dca90b203c8 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -2088,7 +2088,8 @@ getOtherResourceCount(unsigned &OtherCritIdx) { return OtherCritCount; } -void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle) { +template <bool InPQueue> +void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, unsigned Idx) { assert(SU->getInstr() && "Scheduled SUnit must have instr"); #ifndef NDEBUG @@ -2105,11 +2106,19 @@ void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle) { // Check for interlocks first. For the purpose of other heuristics, an // instruction that cannot issue appears as if it's not in the ReadyQueue. bool IsBuffered = SchedModel->getMicroOpBufferSize() != 0; - if ((!IsBuffered && ReadyCycle > CurrCycle) || checkHazard(SU) || - Available.size() >= ReadyListLimit) - Pending.push(SU); - else + bool HazardDetected = (!IsBuffered && ReadyCycle > CurrCycle) || + checkHazard(SU) || (Available.size() >= ReadyListLimit); + + if (!HazardDetected) { Available.push(SU); + + if (InPQueue) + Pending.remove(Pending.begin() + Idx); + return; + } + + if (!InPQueue) + Pending.push(SU); } /// Move the boundary of scheduled code by one cycle. @@ -2349,26 +2358,21 @@ void SchedBoundary::releasePending() { // Check to see if any of the pending instructions are ready to issue. If // so, add them to the available queue. - bool IsBuffered = SchedModel->getMicroOpBufferSize() != 0; - for (unsigned i = 0, e = Pending.size(); i != e; ++i) { - SUnit *SU = *(Pending.begin()+i); + for (unsigned I = 0, E = Pending.size(); I < E; ++I) { + SUnit *SU = *(Pending.begin() + I); unsigned ReadyCycle = isTop() ? SU->TopReadyCycle : SU->BotReadyCycle; if (ReadyCycle < MinReadyCycle) MinReadyCycle = ReadyCycle; - if (!IsBuffered && ReadyCycle > CurrCycle) - continue; - - if (checkHazard(SU)) - continue; - if (Available.size() >= ReadyListLimit) break; - Available.push(SU); - Pending.remove(Pending.begin()+i); - --i; --e; + releaseNode<true>(SU, ReadyCycle, I); + if (E != Pending.size()) { + --I; + --E; + } } CheckPending = false; } |