[llvm] [CodeGen][MISched] Add misched post-regalloc bottom-up scheduling (PR #76186)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 06:53:59 PST 2024
https://github.com/michaelmaitland updated https://github.com/llvm/llvm-project/pull/76186
>From d540b514d2c99c92ecd89286e112feba90d2b89e Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 21 Dec 2023 13:17:34 -0800
Subject: [PATCH 1/3] [CodeGen][MISched] dumpSched direction depends on field
in DAG.
This is a precommit to supporting post reg-alloc bottom up scheduling.
We'd like to have post-ra scheduling direction that can be different from
pre-ra direction. The current dumpSchedule function is changed in this
patch to support the fact that the post-ra and pre-ra directions will
depend on different command line options.
---
llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h | 12 ++++++++++
llvm/lib/CodeGen/MachineScheduler.cpp | 24 ++++++++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
index ef7662a8e7a26a..85de18f5169e5e 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
@@ -191,7 +191,19 @@ namespace llvm {
/// applicable).
using SUList = std::list<SUnit *>;
+ /// The direction that should be used to dump the scheduled Sequence.
+ enum DumpDirection {
+ TopDown,
+ BottomUp,
+ Bidirectional,
+ NotSet,
+ };
+
+ void setDumpDirection(DumpDirection D) { DumpDir = D; }
+
protected:
+ DumpDirection DumpDir = NotSet;
+
/// A map from ValueType to SUList, used during DAG construction, as
/// a means of remembering which SUs depend on which memory locations.
class Value2SUsMap;
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 750f739a559900..265d3ac59f7c86 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -440,6 +440,14 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
// Instantiate the selected scheduler for this target, function, and
// optimization level.
std::unique_ptr<ScheduleDAGInstrs> Scheduler(createMachineScheduler());
+ ScheduleDAGMI::DumpDirection Dir;
+ if (ForceTopDown)
+ Dir = ScheduleDAGMI::DumpDirection::TopDown;
+ else if (ForceBottomUp)
+ Dir = ScheduleDAGMI::DumpDirection::BottomUp;
+ else
+ Dir = ScheduleDAGMI::DumpDirection::Bidirectional;
+ Scheduler->setDumpDirection(Dir);
scheduleRegions(*Scheduler, false);
LLVM_DEBUG(LIS->dump());
@@ -473,6 +481,9 @@ bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) {
// Instantiate the selected scheduler for this target, function, and
// optimization level.
std::unique_ptr<ScheduleDAGInstrs> Scheduler(createPostMachineScheduler());
+ Scheduler->setDumpDirection(PostRADirection == MISchedPostRASched::TopDown
+ ? ScheduleDAGMI::DumpDirection::TopDown
+ : ScheduleDAGMI::DumpDirection::BottomUp);
scheduleRegions(*Scheduler, true);
if (VerifyScheduling)
@@ -1125,12 +1136,14 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceBottomUp() const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ScheduleDAGMI::dumpSchedule() const {
if (MISchedDumpScheduleTrace) {
- if (ForceTopDown)
+ if (DumpDir == TopDown)
dumpScheduleTraceTopDown();
- else if (ForceBottomUp)
+ else if (DumpDir == BottomUp)
dumpScheduleTraceBottomUp();
- else {
+ else if (DumpDir == BottomUp) {
dbgs() << "* Schedule table (Bidirectional): not implemented\n";
+ } else {
+ dbgs() << "* Schedule table: DumpDirection not set.\n";
}
}
@@ -3842,6 +3855,11 @@ void PostGenericScheduler::initialize(ScheduleDAGMI *Dag) {
DAG->MF.getSubtarget().getInstrInfo()->CreateTargetMIHazardRecognizer(
Itin, DAG);
}
+ if (!Bot.HazardRec) {
+ Bot.HazardRec =
+ DAG->MF.getSubtarget().getInstrInfo()->CreateTargetMIHazardRecognizer(
+ Itin, DAG);
+ }
}
void PostGenericScheduler::registerRoots() {
>From 1eaafcb25a0b1f8b709eaaa1224f6308b00cd83e Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 21 Dec 2023 11:36:15 -0800
Subject: [PATCH 2/3] [CodeGen][MISched] Add misched post-regalloc bottom-up
scheduling
The main justification for this patch is that I'd like to add a
HazardRecognizer that does not work in the top-down direction. This creates a
need for bottom-up scheduling in the PostGenericScheduler. I found that the
PostGenericScheduler would undo the scheduling which was influenced by the
HazardRecognition that happend in the pre-regalloc GenericScheduler.
There is also the possibility that the bottom-up direction will lead to
performance improvements on certain targets, as this is certainly the case for
the pre-regalloc GenericScheduler. This patch will give people the
opportunity to experiment for their sub-targets. However, this patch
keeps the top-down approach as the default for the PostGenericScheduler
since that is what subtargets expect today.
---
llvm/include/llvm/CodeGen/MachineScheduler.h | 19 +--
llvm/lib/CodeGen/MachineScheduler.cpp | 128 +++++++++++++-----
.../RISCV/misched-postra-direction.mir | 72 ++++++++++
3 files changed, 177 insertions(+), 42 deletions(-)
create mode 100644 llvm/test/CodeGen/RISCV/misched-postra-direction.mir
diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h
index 47127a6c29603b..25703dd6b61f0d 100644
--- a/llvm/include/llvm/CodeGen/MachineScheduler.h
+++ b/llvm/include/llvm/CodeGen/MachineScheduler.h
@@ -1293,19 +1293,19 @@ class PostGenericScheduler : public GenericSchedulerBase {
protected:
ScheduleDAGMI *DAG = nullptr;
SchedBoundary Top;
- SmallVector<SUnit*, 8> BotRoots;
+ SchedBoundary Bot;
+ MachineSchedPolicy RegionPolicy;
public:
- PostGenericScheduler(const MachineSchedContext *C):
- GenericSchedulerBase(C), Top(SchedBoundary::TopQID, "TopQ") {}
+ PostGenericScheduler(const MachineSchedContext *C)
+ : GenericSchedulerBase(C), Top(SchedBoundary::TopQID, "TopQ"),
+ Bot(SchedBoundary::BotQID, "BotQ") {}
~PostGenericScheduler() override = default;
void initPolicy(MachineBasicBlock::iterator Begin,
MachineBasicBlock::iterator End,
- unsigned NumRegionInstrs) override {
- /* no configurable policy */
- }
+ unsigned NumRegionInstrs) override;
/// PostRA scheduling does not track pressure.
bool shouldTrackPressure() const override { return false; }
@@ -1328,15 +1328,16 @@ class PostGenericScheduler : public GenericSchedulerBase {
Top.releaseNode(SU, SU->TopReadyCycle, false);
}
- // Only called for roots.
void releaseBottomNode(SUnit *SU) override {
- BotRoots.push_back(SU);
+ if (SU->isScheduled)
+ return;
+ Bot.releaseNode(SU, SU->BotReadyCycle, false);
}
protected:
virtual bool tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand);
- void pickNodeFromQueue(SchedCandidate &Cand);
+ void pickNodeFromQueue(SchedBoundary &Zone, SchedCandidate &Cand);
};
/// Create the standard converging machine scheduler. This will be used as the
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 265d3ac59f7c86..c9b748563a462d 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -81,6 +81,22 @@ cl::opt<bool> ForceTopDown("misched-topdown", cl::Hidden,
cl::desc("Force top-down list scheduling"));
cl::opt<bool> ForceBottomUp("misched-bottomup", cl::Hidden,
cl::desc("Force bottom-up list scheduling"));
+namespace MISchedPostRASched {
+enum Direction {
+ TopDown,
+ BottomUp,
+};
+} // end namespace MISchedPostRASched
+cl::opt<MISchedPostRASched::Direction> PostRADirection(
+ "misched-postra-direction", cl::Hidden,
+ cl::desc("Post reg-alloc list scheduling direction"),
+ // Default to top-down because it was implemented first and existing targets
+ // expect that behavior by default.
+ cl::init(MISchedPostRASched::TopDown),
+ cl::values(clEnumValN(MISchedPostRASched::TopDown, "topdown",
+ "Force top-down post reg-alloc list scheduling"),
+ clEnumValN(MISchedPostRASched::BottomUp, "bottomup",
+ "Force bottom-up post reg-alloc list scheduling")));
cl::opt<bool>
DumpCriticalPathLength("misched-dcpl", cl::Hidden,
cl::desc("Print critical path length to stdout"));
@@ -440,14 +456,14 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
// Instantiate the selected scheduler for this target, function, and
// optimization level.
std::unique_ptr<ScheduleDAGInstrs> Scheduler(createMachineScheduler());
- ScheduleDAGMI::DumpDirection Dir;
+ ScheduleDAGMI::DumpDirection D;
if (ForceTopDown)
- Dir = ScheduleDAGMI::DumpDirection::TopDown;
+ D = ScheduleDAGMI::DumpDirection::TopDown;
else if (ForceBottomUp)
- Dir = ScheduleDAGMI::DumpDirection::BottomUp;
+ D = ScheduleDAGMI::DumpDirection::BottomUp;
else
- Dir = ScheduleDAGMI::DumpDirection::Bidirectional;
- Scheduler->setDumpDirection(Dir);
+ D = ScheduleDAGMI::DumpDirection::Bidirectional;
+ Scheduler->setDumpDirection(D);
scheduleRegions(*Scheduler, false);
LLVM_DEBUG(LIS->dump());
@@ -481,9 +497,12 @@ bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) {
// Instantiate the selected scheduler for this target, function, and
// optimization level.
std::unique_ptr<ScheduleDAGInstrs> Scheduler(createPostMachineScheduler());
- Scheduler->setDumpDirection(PostRADirection == MISchedPostRASched::TopDown
- ? ScheduleDAGMI::DumpDirection::TopDown
- : ScheduleDAGMI::DumpDirection::BottomUp);
+ ScheduleDAGMI::DumpDirection D;
+ if (PostRADirection == MISchedPostRASched::TopDown)
+ D = ScheduleDAGMI::DumpDirection::TopDown;
+ else
+ D = ScheduleDAGMI::DumpDirection::BottomUp;
+ Scheduler->setDumpDirection(D);
scheduleRegions(*Scheduler, true);
if (VerifyScheduling)
@@ -1136,11 +1155,11 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceBottomUp() const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ScheduleDAGMI::dumpSchedule() const {
if (MISchedDumpScheduleTrace) {
- if (DumpDir == TopDown)
+ if (DumpDir == DumpDirection::TopDown)
dumpScheduleTraceTopDown();
- else if (DumpDir == BottomUp)
+ else if (DumpDir == DumpDirection::BottomUp)
dumpScheduleTraceBottomUp();
- else if (DumpDir == BottomUp) {
+ else if (DumpDir == DumpDirection::Bidirectional) {
dbgs() << "* Schedule table (Bidirectional): not implemented\n";
} else {
dbgs() << "* Schedule table: DumpDirection not set.\n";
@@ -3845,7 +3864,7 @@ void PostGenericScheduler::initialize(ScheduleDAGMI *Dag) {
Rem.init(DAG, SchedModel);
Top.init(DAG, SchedModel, &Rem);
- BotRoots.clear();
+ Bot.init(DAG, SchedModel, &Rem);
// Initialize the HazardRecognizers. If itineraries don't exist, are empty,
// or are disabled, then these HazardRecs will be disabled.
@@ -3862,11 +3881,23 @@ void PostGenericScheduler::initialize(ScheduleDAGMI *Dag) {
}
}
+void PostGenericScheduler::initPolicy(MachineBasicBlock::iterator Begin,
+ MachineBasicBlock::iterator End,
+ unsigned NumRegionInstrs) {
+ if (PostRADirection == MISchedPostRASched::TopDown) {
+ RegionPolicy.OnlyTopDown = true;
+ RegionPolicy.OnlyBottomUp = false;
+ } else if (PostRADirection == MISchedPostRASched::BottomUp) {
+ RegionPolicy.OnlyTopDown = false;
+ RegionPolicy.OnlyBottomUp = true;
+ }
+}
+
void PostGenericScheduler::registerRoots() {
Rem.CriticalPath = DAG->ExitSU.getDepth();
// Some roots may not feed into ExitSU. Check all of them in case.
- for (const SUnit *SU : BotRoots) {
+ for (const SUnit *SU : Bot.Available) {
if (SU->getDepth() > Rem.CriticalPath)
Rem.CriticalPath = SU->getDepth();
}
@@ -3923,12 +3954,13 @@ bool PostGenericScheduler::tryCandidate(SchedCandidate &Cand,
return false;
}
-void PostGenericScheduler::pickNodeFromQueue(SchedCandidate &Cand) {
- ReadyQueue &Q = Top.Available;
+void PostGenericScheduler::pickNodeFromQueue(SchedBoundary &Zone,
+ SchedCandidate &Cand) {
+ ReadyQueue &Q = Zone.Available;
for (SUnit *SU : Q) {
SchedCandidate TryCand(Cand.Policy);
TryCand.SU = SU;
- TryCand.AtTop = true;
+ TryCand.AtTop = Zone.isTop();
TryCand.initResourceDelta(DAG, SchedModel);
if (tryCandidate(Cand, TryCand)) {
Cand.setBest(TryCand);
@@ -3940,29 +3972,54 @@ void PostGenericScheduler::pickNodeFromQueue(SchedCandidate &Cand) {
/// Pick the next node to schedule.
SUnit *PostGenericScheduler::pickNode(bool &IsTopNode) {
if (DAG->top() == DAG->bottom()) {
- assert(Top.Available.empty() && Top.Pending.empty() && "ReadyQ garbage");
+ assert(Top.Available.empty() && Top.Pending.empty() &&
+ Bot.Available.empty() && Bot.Pending.empty() && "ReadyQ garbage");
return nullptr;
}
SUnit *SU;
do {
- SU = Top.pickOnlyChoice();
- if (SU) {
- tracePick(Only1, true);
+ if (RegionPolicy.OnlyBottomUp) {
+ assert(!RegionPolicy.OnlyTopDown);
+ SU = Bot.pickOnlyChoice();
+ if (SU) {
+ tracePick(Only1, true);
+ } else {
+ CandPolicy NoPolicy;
+ SchedCandidate BotCand(NoPolicy);
+ // Set the top-down policy based on the state of the current top zone
+ // and the instructions outside the zone, including the bottom zone.
+ setPolicy(BotCand.Policy, /*IsPostRA=*/true, Bot, nullptr);
+ pickNodeFromQueue(Bot, BotCand);
+ assert(BotCand.Reason != NoCand && "failed to find a candidate");
+ tracePick(BotCand);
+ SU = BotCand.SU;
+ }
+ IsTopNode = false;
} else {
- CandPolicy NoPolicy;
- SchedCandidate TopCand(NoPolicy);
- // Set the top-down policy based on the state of the current top zone and
- // the instructions outside the zone, including the bottom zone.
- setPolicy(TopCand.Policy, /*IsPostRA=*/true, Top, nullptr);
- pickNodeFromQueue(TopCand);
- assert(TopCand.Reason != NoCand && "failed to find a candidate");
- tracePick(TopCand);
- SU = TopCand.SU;
+
+ assert(RegionPolicy.OnlyTopDown);
+ SU = Top.pickOnlyChoice();
+ if (SU) {
+ tracePick(Only1, true);
+ } else {
+ CandPolicy NoPolicy;
+ SchedCandidate TopCand(NoPolicy);
+ // Set the top-down policy based on the state of the current top zone
+ // and the instructions outside the zone, including the bottom zone.
+ setPolicy(TopCand.Policy, /*IsPostRA=*/true, Top, nullptr);
+ pickNodeFromQueue(Top, TopCand);
+ assert(TopCand.Reason != NoCand && "failed to find a candidate");
+ tracePick(TopCand);
+ SU = TopCand.SU;
+ }
+ IsTopNode = true;
}
} while (SU->isScheduled);
- IsTopNode = true;
- Top.removeReady(SU);
+ if (SU->isTopReady())
+ Top.removeReady(SU);
+ if (SU->isBottomReady())
+ Bot.removeReady(SU);
LLVM_DEBUG(dbgs() << "Scheduling SU(" << SU->NodeNum << ") "
<< *SU->getInstr());
@@ -3972,8 +4029,13 @@ SUnit *PostGenericScheduler::pickNode(bool &IsTopNode) {
/// Called after ScheduleDAGMI has scheduled an instruction and updated
/// scheduled/remaining flags in the DAG nodes.
void PostGenericScheduler::schedNode(SUnit *SU, bool IsTopNode) {
- SU->TopReadyCycle = std::max(SU->TopReadyCycle, Top.getCurrCycle());
- Top.bumpNode(SU);
+ if (IsTopNode) {
+ SU->TopReadyCycle = std::max(SU->TopReadyCycle, Top.getCurrCycle());
+ Top.bumpNode(SU);
+ } else {
+ SU->BotReadyCycle = std::max(SU->BotReadyCycle, Bot.getCurrCycle());
+ Bot.bumpNode(SU);
+ }
}
ScheduleDAGMI *llvm::createGenericSchedPostRA(MachineSchedContext *C) {
diff --git a/llvm/test/CodeGen/RISCV/misched-postra-direction.mir b/llvm/test/CodeGen/RISCV/misched-postra-direction.mir
new file mode 100644
index 00000000000000..55dea63c29275d
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/misched-postra-direction.mir
@@ -0,0 +1,72 @@
+# RUN: llc -mtriple=riscv64 -mcpu=sifive-x280 -run-pass=postmisched -enable-post-misched -debug-only=machine-scheduler -misched-dump-schedule-trace -misched-postra-direction=topdown -o - %s 2>&1 | FileCheck --check-prefix=TOPDOWN %s
+# RUN: llc -mtriple=riscv64 -mcpu=sifive-x280 -run-pass=postmisched -enable-post-misched -debug-only=machine-scheduler -misched-dump-schedule-trace -misched-postra-direction=bottomup -o - %s 2>&1 | FileCheck --check-prefix=BOTTOMUP %s
+
+# REQUIRES: asserts
+
+---
+name: add_m2
+tracksRegLiveness: true
+body: |
+ bb.0.entry:
+ liveins: $x10, $x11
+
+ %1:gpr = COPY $x11
+ %0:gpr = COPY $x10
+ %4:gpr = MUL %1, %0
+ %3:gpr = ADD %1, %0
+ %5:gpr = DIVW %3, %4
+ $x10 = COPY %5
+ PseudoRET implicit $x10
+...
+
+# TOPDOWN: * Schedule table (TopDown):
+# TOPDOWN-NEXT: i: issue
+# TOPDOWN-NEXT: x: resource booked
+# TOPDOWN-NEXT:Cycle | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
+# TOPDOWN-NEXT:SU(0) | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeAB | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT:SU(1) | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeAB | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT:SU(3) | | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeAB | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT:SU(2) | | | | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeAB | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeB | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT:SU(4) | | | | | | | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeAB | | | | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7PipeB | | | | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# TOPDOWN-NEXT: SiFive7IDiv | | | | | | | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | |
+# TOPDOWN-NEXT:SU(5) | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | i |
+# TOPDOWN-NEXT: SiFive7PipeAB | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | x |
+# TOPDOWN-NEXT:SU(0): %0:gpr = COPY $x11
+# TOPDOWN-NEXT:SU(1): %1:gpr = COPY $x10
+# TOPDOWN-NEXT:SU(3): %3:gpr = ADD %0:gpr, %1:gpr
+# TOPDOWN-NEXT:SU(2): %2:gpr = MUL %0:gpr, %1:gpr
+# TOPDOWN-NEXT:SU(4): %4:gpr = DIVW %3:gpr, %2:gpr
+# TOPDOWN-NEXT:SU(5): $x10 = COPY %4:gpr
+
+# BOTTOMUP: * Schedule table (BottomUp):
+# BOTTOMUP-NEXT: i: issue
+# BOTTOMUP-NEXT: x: resource booked
+# BOTTOMUP-NEXT:Cycle | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 |
+# BOTTOMUP-NEXT:SU(0) | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeAB | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT:SU(1) | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeAB | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT:SU(2) | | | | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeAB | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeB | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT:SU(3) | | | | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeAB | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT:SU(4) | | | | | | | i | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeAB | | | | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7PipeB | | | | | | | x | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+# BOTTOMUP-NEXT: SiFive7IDiv | | | | | | | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | |
+# BOTTOMUP-NEXT:SU(5) | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | i |
+# BOTTOMUP-NEXT: SiFive7PipeAB | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | x |
+# BOTTOMUP-NEXT:SU(0): %0:gpr = COPY $x11
+# BOTTOMUP-NEXT:SU(1): %1:gpr = COPY $x10
+# BOTTOMUP-NEXT:SU(2): %2:gpr = MUL %0:gpr, %1:gpr
+# BOTTOMUP-NEXT:SU(3): %3:gpr = ADD %0:gpr, %1:gpr
+# BOTTOMUP-NEXT:SU(4): %4:gpr = DIVW %3:gpr, %2:gpr
+# BOTTOMUP-NEXT:SU(5): $x10 = COPY %4:gpr
>From 5592cd70c656428df9ece3f2eda7e263106a28a2 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Fri, 23 Feb 2024 06:53:07 -0800
Subject: [PATCH 3/3] fixup! fix comment
---
llvm/lib/CodeGen/MachineScheduler.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index c9b748563a462d..21f463724c7634 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -3986,8 +3986,8 @@ SUnit *PostGenericScheduler::pickNode(bool &IsTopNode) {
} else {
CandPolicy NoPolicy;
SchedCandidate BotCand(NoPolicy);
- // Set the top-down policy based on the state of the current top zone
- // and the instructions outside the zone, including the bottom zone.
+ // Set the bottom-up policy based on the state of the current bottom zone and
+ // the instructions outside the zone, including the top zone.
setPolicy(BotCand.Policy, /*IsPostRA=*/true, Bot, nullptr);
pickNodeFromQueue(Bot, BotCand);
assert(BotCand.Reason != NoCand && "failed to find a candidate");
More information about the llvm-commits
mailing list