[llvm] [SandboxVec][Scheduler] Cleanup: Use interval in loop and reset sched state (PR #205465)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 23 18:12:09 PDT 2026
https://github.com/vporpo created https://github.com/llvm/llvm-project/pull/205465
Replace the for loop that iterates between TopI and LowestI with a range loop over ResetIntvl and move the reset of the scheduling state to this loop.
Even though this is not an NFC as we iterate over the loop in the reverse order than before, the functionality should not change.
>From 5c6c14789b17b05cbfac03f0500e7d537f9a66f5 Mon Sep 17 00:00:00 2001
From: Vasileios Porpodas <vasileios.porpodas at amd.com>
Date: Tue, 23 Jun 2026 23:42:51 +0000
Subject: [PATCH] [SandboxVec][Scheduler] Cleanup: Use interval in loop and
reset sched state
Replace the for loop that iterates between TopI and LowestI with a range
loop over ResetIntvl and move the reset of the scheduling state to this loop.
Even though this is not an NFC as we iterate over the loop in the reverse order
than before, the functionality should not change.
---
.../Vectorize/SandboxVectorizer/Scheduler.cpp | 22 +++++++++----------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp
index 82a327719f29f..14614686c2d46 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp
@@ -297,26 +297,24 @@ void Scheduler::trimSchedule(ArrayRef<Instruction *> Instrs) {
Instruction *LowestI = Dir == SchedDirection::BottomUp
? VecUtils::getLowest(Instrs)
: &*ScheduleTopItOpt.value();
-
- // Destroy the singleton schedule bundles from LowestI all the way to the top.
- for (auto *I = LowestI, *E = TopI->getPrevNode(); I != E;
- I = I->getPrevNode()) {
- auto *N = DAG.getNode(I);
+ Interval<Instruction> ResetIntvl(TopI, LowestI);
+ // The DAG Nodes contain state like the number of UnscheduledSuccs and the
+ // Scheduled flag. We need to reset their state. We need to do this for all
+ // nodes in ResetIntvl. Also destroy the singleton schedule bundles from
+ // LowestI all the way to the top.
+ for (auto &I : ResetIntvl) {
+ auto *N = DAG.getNode(&I);
if (N == nullptr)
continue;
auto *SB = N->getSchedBundle();
if (SB->isSingleton())
eraseBundle(SB);
+ N->resetScheduleState();
}
- // The DAG Nodes contain state like the number of UnscheduledSuccs and the
- // Scheduled flag. We need to reset their state. We need to do this for all
- // nodes from LowestI to the top of the schedule. DAG Nodes that are above the
- // top of schedule that depend on nodes that got reset need to have their
- // UnscheduledSuccs adjusted.
- Interval<Instruction> ResetIntvl(TopI, LowestI);
+ // Nodes that depend on the nodes in ResetIntvl also need to have their
+ // UnscheduledSuccs/UnscheduledPreds adjusted.
for (Instruction &I : ResetIntvl) {
auto *N = DAG.getNode(&I);
- N->resetScheduleState();
if (Dir == SchedDirection::BottomUp) {
// Recompute UnscheduledSuccs for nodes not only in ResetIntvl but even
// for nodes above the top of schedule.
More information about the llvm-commits
mailing list