@@ -3676,8 +3676,8 @@ void GenericScheduler::initialize(ScheduleDAGMI *dag) {
36763676 TopCand.SU = nullptr ;
36773677 BotCand.SU = nullptr ;
36783678
3679- TopCluster = nullptr ;
3680- BotCluster = nullptr ;
3679+ TopClusterID = InvalidClusterId ;
3680+ BotClusterID = InvalidClusterId ;
36813681}
36823682
36833683// / Initialize the per-region scheduling policy.
@@ -3988,10 +3988,14 @@ bool GenericScheduler::tryCandidate(SchedCandidate &Cand,
39883988 // This is a best effort to set things up for a post-RA pass. Optimizations
39893989 // like generating loads of multiple registers should ideally be done within
39903990 // the scheduler pass by combining the loads during DAG postprocessing.
3991- const ClusterInfo *CandCluster = Cand.AtTop ? TopCluster : BotCluster;
3992- const ClusterInfo *TryCandCluster = TryCand.AtTop ? TopCluster : BotCluster;
3993- if (tryGreater (TryCandCluster && TryCandCluster->contains (TryCand.SU ),
3994- CandCluster && CandCluster->contains (Cand.SU ), TryCand, Cand,
3991+ unsigned CandZoneCluster = Cand.AtTop ? TopClusterID : BotClusterID;
3992+ unsigned TryCandZoneCluster = TryCand.AtTop ? TopClusterID : BotClusterID;
3993+ bool CandIsClusterSucc =
3994+ isTheSameCluster (CandZoneCluster, Cand.SU ->ParentClusterIdx );
3995+ bool TryCandIsClusterSucc =
3996+ isTheSameCluster (TryCandZoneCluster, TryCand.SU ->ParentClusterIdx );
3997+
3998+ if (tryGreater (TryCandIsClusterSucc, CandIsClusterSucc, TryCand, Cand,
39953999 Cluster))
39964000 return TryCand.Reason != NoCand;
39974001
@@ -4251,8 +4255,9 @@ void GenericScheduler::reschedulePhysReg(SUnit *SU, bool isTop) {
42514255void GenericScheduler::schedNode (SUnit *SU, bool IsTopNode) {
42524256 if (IsTopNode) {
42534257 SU->TopReadyCycle = std::max (SU->TopReadyCycle , Top.getCurrCycle ());
4254- TopCluster = DAG->getCluster (SU->ParentClusterIdx );
4255- LLVM_DEBUG (if (TopCluster) {
4258+ TopClusterID = SU->ParentClusterIdx ;
4259+ LLVM_DEBUG (if (TopClusterID != InvalidClusterId) {
4260+ ClusterInfo *TopCluster = DAG->getCluster (TopClusterID);
42564261 dbgs () << " Top Cluster: " ;
42574262 for (auto *N : *TopCluster)
42584263 dbgs () << N->NodeNum << ' \t ' ;
@@ -4263,8 +4268,9 @@ void GenericScheduler::schedNode(SUnit *SU, bool IsTopNode) {
42634268 reschedulePhysReg (SU, true );
42644269 } else {
42654270 SU->BotReadyCycle = std::max (SU->BotReadyCycle , Bot.getCurrCycle ());
4266- BotCluster = DAG->getCluster (SU->ParentClusterIdx );
4267- LLVM_DEBUG (if (BotCluster) {
4271+ BotClusterID = SU->ParentClusterIdx ;
4272+ LLVM_DEBUG (if (BotClusterID != InvalidClusterId) {
4273+ ClusterInfo *BotCluster = DAG->getCluster (BotClusterID);
42684274 dbgs () << " Bot Cluster: " ;
42694275 for (auto *N : *BotCluster)
42704276 dbgs () << N->NodeNum << ' \t ' ;
@@ -4306,8 +4312,8 @@ void PostGenericScheduler::initialize(ScheduleDAGMI *Dag) {
43064312 if (!Bot.HazardRec ) {
43074313 Bot.HazardRec = DAG->TII ->CreateTargetMIHazardRecognizer (Itin, DAG);
43084314 }
4309- TopCluster = nullptr ;
4310- BotCluster = nullptr ;
4315+ TopClusterID = InvalidClusterId ;
4316+ BotClusterID = InvalidClusterId ;
43114317}
43124318
43134319void PostGenericScheduler::initPolicy (MachineBasicBlock::iterator Begin,
@@ -4373,10 +4379,14 @@ bool PostGenericScheduler::tryCandidate(SchedCandidate &Cand,
43734379 return TryCand.Reason != NoCand;
43744380
43754381 // Keep clustered nodes together.
4376- const ClusterInfo *CandCluster = Cand.AtTop ? TopCluster : BotCluster;
4377- const ClusterInfo *TryCandCluster = TryCand.AtTop ? TopCluster : BotCluster;
4378- if (tryGreater (TryCandCluster && TryCandCluster->contains (TryCand.SU ),
4379- CandCluster && CandCluster->contains (Cand.SU ), TryCand, Cand,
4382+ unsigned CandZoneCluster = Cand.AtTop ? TopClusterID : BotClusterID;
4383+ unsigned TryCandZoneCluster = TryCand.AtTop ? TopClusterID : BotClusterID;
4384+ bool CandIsClusterSucc =
4385+ isTheSameCluster (CandZoneCluster, Cand.SU ->ParentClusterIdx );
4386+ bool TryCandIsClusterSucc =
4387+ isTheSameCluster (TryCandZoneCluster, TryCand.SU ->ParentClusterIdx );
4388+
4389+ if (tryGreater (TryCandIsClusterSucc, CandIsClusterSucc, TryCand, Cand,
43804390 Cluster))
43814391 return TryCand.Reason != NoCand;
43824392 // Avoid critical resource consumption and balance the schedule.
@@ -4575,11 +4585,11 @@ SUnit *PostGenericScheduler::pickNode(bool &IsTopNode) {
45754585void PostGenericScheduler::schedNode (SUnit *SU, bool IsTopNode) {
45764586 if (IsTopNode) {
45774587 SU->TopReadyCycle = std::max (SU->TopReadyCycle , Top.getCurrCycle ());
4578- TopCluster = DAG-> getCluster ( SU->ParentClusterIdx ) ;
4588+ TopClusterID = SU->ParentClusterIdx ;
45794589 Top.bumpNode (SU);
45804590 } else {
45814591 SU->BotReadyCycle = std::max (SU->BotReadyCycle , Bot.getCurrCycle ());
4582- BotCluster = DAG-> getCluster ( SU->ParentClusterIdx ) ;
4592+ BotClusterID = SU->ParentClusterIdx ;
45834593 Bot.bumpNode (SU);
45844594 }
45854595}
0 commit comments