@@ -3676,8 +3676,8 @@ void GenericScheduler::initialize(ScheduleDAGMI *dag) {
3676
3676
TopCand.SU = nullptr ;
3677
3677
BotCand.SU = nullptr ;
3678
3678
3679
- TopCluster = nullptr ;
3680
- BotCluster = nullptr ;
3679
+ TopClusterID = InvalidClusterId ;
3680
+ BotClusterID = InvalidClusterId ;
3681
3681
}
3682
3682
3683
3683
// / Initialize the per-region scheduling policy.
@@ -3988,10 +3988,14 @@ bool GenericScheduler::tryCandidate(SchedCandidate &Cand,
3988
3988
// This is a best effort to set things up for a post-RA pass. Optimizations
3989
3989
// like generating loads of multiple registers should ideally be done within
3990
3990
// 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,
3995
3999
Cluster))
3996
4000
return TryCand.Reason != NoCand;
3997
4001
@@ -4251,24 +4255,30 @@ void GenericScheduler::reschedulePhysReg(SUnit *SU, bool isTop) {
4251
4255
void GenericScheduler::schedNode (SUnit *SU, bool IsTopNode) {
4252
4256
if (IsTopNode) {
4253
4257
SU->TopReadyCycle = std::max (SU->TopReadyCycle , Top.getCurrCycle ());
4254
- TopCluster = DAG->getCluster (SU->ParentClusterIdx );
4255
- LLVM_DEBUG (if (TopCluster) {
4256
- dbgs () << " Top Cluster: " ;
4257
- for (auto *N : *TopCluster)
4258
- dbgs () << N->NodeNum << ' \t ' ;
4259
- dbgs () << ' \n ' ;
4258
+ TopClusterID = SU->ParentClusterIdx ;
4259
+ LLVM_DEBUG ({
4260
+ if (TopClusterID != InvalidClusterId) {
4261
+ ClusterInfo *TopCluster = DAG->getCluster (TopClusterID);
4262
+ dbgs () << " Top Cluster: " ;
4263
+ for (auto *N : *TopCluster)
4264
+ dbgs () << N->NodeNum << ' \t ' ;
4265
+ dbgs () << ' \n ' ;
4266
+ }
4260
4267
});
4261
4268
Top.bumpNode (SU);
4262
4269
if (SU->hasPhysRegUses )
4263
4270
reschedulePhysReg (SU, true );
4264
4271
} else {
4265
4272
SU->BotReadyCycle = std::max (SU->BotReadyCycle , Bot.getCurrCycle ());
4266
- BotCluster = DAG->getCluster (SU->ParentClusterIdx );
4267
- LLVM_DEBUG (if (BotCluster) {
4268
- dbgs () << " Bot Cluster: " ;
4269
- for (auto *N : *BotCluster)
4270
- dbgs () << N->NodeNum << ' \t ' ;
4271
- dbgs () << ' \n ' ;
4273
+ BotClusterID = SU->ParentClusterIdx ;
4274
+ LLVM_DEBUG ({
4275
+ if (BotClusterID != InvalidClusterId) {
4276
+ ClusterInfo *BotCluster = DAG->getCluster (BotClusterID);
4277
+ dbgs () << " Bot Cluster: " ;
4278
+ for (auto *N : *BotCluster)
4279
+ dbgs () << N->NodeNum << ' \t ' ;
4280
+ dbgs () << ' \n ' ;
4281
+ }
4272
4282
});
4273
4283
Bot.bumpNode (SU);
4274
4284
if (SU->hasPhysRegDefs )
@@ -4306,8 +4316,8 @@ void PostGenericScheduler::initialize(ScheduleDAGMI *Dag) {
4306
4316
if (!Bot.HazardRec ) {
4307
4317
Bot.HazardRec = DAG->TII ->CreateTargetMIHazardRecognizer (Itin, DAG);
4308
4318
}
4309
- TopCluster = nullptr ;
4310
- BotCluster = nullptr ;
4319
+ TopClusterID = InvalidClusterId ;
4320
+ BotClusterID = InvalidClusterId ;
4311
4321
}
4312
4322
4313
4323
void PostGenericScheduler::initPolicy (MachineBasicBlock::iterator Begin,
@@ -4373,10 +4383,14 @@ bool PostGenericScheduler::tryCandidate(SchedCandidate &Cand,
4373
4383
return TryCand.Reason != NoCand;
4374
4384
4375
4385
// 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,
4386
+ unsigned CandZoneCluster = Cand.AtTop ? TopClusterID : BotClusterID;
4387
+ unsigned TryCandZoneCluster = TryCand.AtTop ? TopClusterID : BotClusterID;
4388
+ bool CandIsClusterSucc =
4389
+ isTheSameCluster (CandZoneCluster, Cand.SU ->ParentClusterIdx );
4390
+ bool TryCandIsClusterSucc =
4391
+ isTheSameCluster (TryCandZoneCluster, TryCand.SU ->ParentClusterIdx );
4392
+
4393
+ if (tryGreater (TryCandIsClusterSucc, CandIsClusterSucc, TryCand, Cand,
4380
4394
Cluster))
4381
4395
return TryCand.Reason != NoCand;
4382
4396
// Avoid critical resource consumption and balance the schedule.
@@ -4575,11 +4589,11 @@ SUnit *PostGenericScheduler::pickNode(bool &IsTopNode) {
4575
4589
void PostGenericScheduler::schedNode (SUnit *SU, bool IsTopNode) {
4576
4590
if (IsTopNode) {
4577
4591
SU->TopReadyCycle = std::max (SU->TopReadyCycle , Top.getCurrCycle ());
4578
- TopCluster = DAG-> getCluster ( SU->ParentClusterIdx ) ;
4592
+ TopClusterID = SU->ParentClusterIdx ;
4579
4593
Top.bumpNode (SU);
4580
4594
} else {
4581
4595
SU->BotReadyCycle = std::max (SU->BotReadyCycle , Bot.getCurrCycle ());
4582
- BotCluster = DAG-> getCluster ( SU->ParentClusterIdx ) ;
4596
+ BotClusterID = SU->ParentClusterIdx ;
4583
4597
Bot.bumpNode (SU);
4584
4598
}
4585
4599
}
0 commit comments