diff options
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp')
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp index d1f00135097..2e7a46fe2d6 100644 --- a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp +++ b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp @@ -544,6 +544,7 @@ static SUnit *getSingleUnscheduledSucc(SUnit *SU) { // heuristic components for cost computation. static const unsigned PriorityOne = 200; static const unsigned PriorityTwo = 50; +static const unsigned PriorityThree = 75; static const unsigned ScaleTwo = 10; static const unsigned FactorOne = 2; @@ -609,6 +610,19 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, auto &QST = DAG->MF.getSubtarget<HexagonSubtarget>(); auto &QII = *QST.getInstrInfo(); + // Give a little extra priority to a .cur instruction if there is a resource + // available for it. + if (SU->isInstr() && QII.mayBeCurLoad(SU->getInstr())) { + if (Q.getID() == TopQID && Top.ResourceModel->isResourceAvailable(SU)) { + ResCount += PriorityTwo; + DEBUG(if (verbose) dbgs() << "C|"); + } else if (Q.getID() == BotQID && + Bot.ResourceModel->isResourceAvailable(SU)) { + ResCount += PriorityTwo; + DEBUG(if (verbose) dbgs() << "C|"); + } + } + // Give preference to a zero latency instruction if the dependent // instruction is in the current packet. if (Q.getID() == TopQID) { @@ -616,7 +630,7 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (!PI.getSUnit()->getInstr()->isPseudo() && PI.isAssignedRegDep() && PI.getLatency() == 0 && Top.ResourceModel->isInPacket(PI.getSUnit())) { - ResCount += PriorityTwo; + ResCount += PriorityThree; DEBUG(if (verbose) dbgs() << "Z|"); } } @@ -625,7 +639,7 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (!SI.getSUnit()->getInstr()->isPseudo() && SI.isAssignedRegDep() && SI.getLatency() == 0 && Bot.ResourceModel->isInPacket(SI.getSUnit())) { - ResCount += PriorityTwo; + ResCount += PriorityThree; DEBUG(if (verbose) dbgs() << "Z|"); } } @@ -693,6 +707,20 @@ pickNodeFromQueue(ReadyQueue &Q, const RegPressureTracker &RPTracker, continue; } + if (CurrentCost == Candidate.SCost) { + if ((Q.getID() == TopQID && + (*I)->Succs.size() > Candidate.SU->Succs.size()) || + (Q.getID() == BotQID && + (*I)->Preds.size() < Candidate.SU->Preds.size())) { + DEBUG(traceCandidate("SPCAND", Q, *I, CurrentCost)); + Candidate.SU = *I; + Candidate.RPDelta = RPDelta; + Candidate.SCost = CurrentCost; + FoundCandidate = BestCost; + continue; + } + } + // Fall through to original instruction order. // Only consider node order if Candidate was chosen from this Q. if (FoundCandidate == NoCand) |