@@ -689,10 +689,9 @@ bool AIEPostRASchedStrategy::isAvailableNode(SUnit &SU, SchedBoundary &Zone,
689689 return false ;
690690 if (Zone.isTop ()) {
691691 return CurrCycle == TopReadyCycle;
692- } else {
693- const int DeltaCycles = CurrCycle - BotReadyCycle;
694- return DeltaCycles >= MinDelta;
695692 }
693+ const int DeltaCycles = CurrCycle - BotReadyCycle;
694+ return DeltaCycles >= MinDelta;
696695 }
697696
698697 if (doesNotProgressInZone (Zone, SU ))
@@ -704,17 +703,29 @@ bool AIEPostRASchedStrategy::isAvailableNode(SUnit &SU, SchedBoundary &Zone,
704703 // This SU should be scheduled after CurrCycle.
705704 if (TopReadyCycle > CurrCycle)
706705 return false ;
707- for (int DeltaCycles = TopReadyCycle - CurrCycle; DeltaCycles <= 0 ;
708- ++DeltaCycles) {
709- // TopReadyCycle is always lesser or equal to the current cycle here,
706+ // Clamp the search start to the scoreboard's valid backward range.
707+ // On large basic blocks TopReadyCycle can be much smaller than
708+ // CurrCycle - MaxLookAhead. Cycles before the scoreboard window are
709+ // guaranteed empty: resources are always inserted forward in time, so
710+ // once the scoreboard has advanced past a cycle its entries have been
711+ // cleared. Attempting to access those out-of-window cycles would
712+ // assert in checkConflict/enterResources. When no slot is found within
713+ // the valid window the callers' bump mechanism rotates the scoreboard
714+ // forward to open fresh slots, mirroring the !isTop path.
715+ const int MaxLookAhead =
716+ int (getAIEHazardRecognizer (Zone)->getMaxLookAhead ());
717+ const int Start = std::max (TopReadyCycle - CurrCycle, -MaxLookAhead);
718+ for (int DeltaCycles = Start; DeltaCycles <= 0 ; ++DeltaCycles) {
719+ // TopReadyCycle is always less or equal to the current cycle here,
710720 // (if not, we could violate dependencies) so DeltaCycles will
711721 // always be less or equal to 0.
712722 if (Zone.checkHazard (&SU , DeltaCycles))
713723 continue ;
714724 SU .TopReadyCycle = CurrCycle + DeltaCycles;
715725 return true ;
716726 }
717- // We know that we can't schedule in any cycle <= CurrCycle.
727+ // No slot found in the scoreboard window. The callers' bump loop will
728+ // advance the scoreboard by one cycle so the next call sees a fresh slot.
718729 SU .TopReadyCycle = CurrCycle + 1 ;
719730 return false ;
720731 }
0 commit comments