Skip to content

Commit 6ad3d05

Browse files
committed
MachineScheduler: Fully compare top/bottom candidates
In bidirectional scheduling this gives more stable results than just comparing the "reason" fields of the top/bottom node because the reason field may be higher depending on what other nodes are in the queue. Differential Revision: http://reviews.llvm.org/D19401 llvm-svn: 273755
1 parent 62f19e7 commit 6ad3d05

22 files changed

+154
-150
lines changed

llvm/include/llvm/CodeGen/MachineScheduler.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ class GenericSchedulerBase : public MachineSchedStrategy {
763763
public:
764764
/// Represent the type of SchedCandidate found within a single queue.
765765
/// pickNodeBidirectional depends on these listed by decreasing priority.
766-
enum CandReason {
766+
enum CandReason : uint8_t {
767767
NoCand, Only1, PhysRegCopy, RegExcess, RegCritical, Stall, Cluster, Weak,
768768
RegMax, ResourceReduce, ResourceDemand, BotHeightReduce, BotPathReduce,
769769
TopDepthReduce, TopPathReduce, NextDefUse, NodeOrder};
@@ -811,8 +811,8 @@ class GenericSchedulerBase : public MachineSchedStrategy {
811811
// The reason for this candidate.
812812
CandReason Reason;
813813

814-
// Set of reasons that apply to multiple candidates.
815-
uint32_t RepeatReasonSet;
814+
// Whether this candidate should be scheduled at top/bottom.
815+
bool AtTop;
816816

817817
// Register pressure values for the best candidate.
818818
RegPressureDelta RPDelta;
@@ -821,7 +821,7 @@ class GenericSchedulerBase : public MachineSchedStrategy {
821821
SchedResourceDelta ResDelta;
822822

823823
SchedCandidate(const CandPolicy &policy)
824-
: Policy(policy), SU(nullptr), Reason(NoCand), RepeatReasonSet(0) {}
824+
: Policy(policy), SU(nullptr), Reason(NoCand), AtTop(false) {}
825825

826826
bool isValid() const { return SU; }
827827

@@ -830,13 +830,11 @@ class GenericSchedulerBase : public MachineSchedStrategy {
830830
assert(Best.Reason != NoCand && "uninitialized Sched candidate");
831831
SU = Best.SU;
832832
Reason = Best.Reason;
833+
AtTop = Best.AtTop;
833834
RPDelta = Best.RPDelta;
834835
ResDelta = Best.ResDelta;
835836
}
836837

837-
bool isRepeat(CandReason R) { return RepeatReasonSet & (1 << R); }
838-
void setRepeat(CandReason R) { RepeatReasonSet |= (1 << R); }
839-
840838
void initResourceDelta(const ScheduleDAGMI *DAG,
841839
const TargetSchedModel *SchedModel);
842840
};
@@ -913,11 +911,12 @@ class GenericScheduler : public GenericSchedulerBase {
913911

914912
void tryCandidate(SchedCandidate &Cand,
915913
SchedCandidate &TryCand,
916-
SchedBoundary &Zone);
914+
SchedBoundary *Zone);
917915

918916
SUnit *pickNodeBidirectional(bool &IsTopNode);
919917

920918
void pickNodeFromQueue(SchedBoundary &Zone,
919+
const CandPolicy &ZonePolicy,
921920
const RegPressureTracker &RPTracker,
922921
SchedCandidate &Candidate);
923922

0 commit comments

Comments
 (0)