mi-sched: Force bottom up scheduling for generic targets.
Fast register pressure tracking currently only takes effect during
bottom up scheduling. Forcing this is a bit faster and simpler for
targets that don't have many scheduling constraints and don't need
top-down scheduling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190014 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp
index d9850d3..9600cb6 100644
--- a/lib/CodeGen/MachineScheduler.cpp
+++ b/lib/CodeGen/MachineScheduler.cpp
@@ -1594,6 +1594,12 @@
SchedBoundary Top;
SchedBoundary Bot;
+ // Allow the driver to force top-down or bottom-up scheduling. If neither is
+ // true, the scheduler runs in both directions and converges. For generic
+ // targets, we default to bottom-up, because it's simpler and more
+ // compile-time optimizations have been implemented in that direction.
+ bool OnlyBottomUp;
+ bool OnlyTopDown;
public:
/// SUnit::NodeQueueId: 0 (none), 1 (top), 2 (bot), 3 (both)
enum {
@@ -1604,7 +1610,8 @@
ConvergingScheduler(const MachineSchedContext *C):
Context(C), DAG(0), SchedModel(0), TRI(0),
- Top(TopQID, "TopQ"), Bot(BotQID, "BotQ") {}
+ Top(TopQID, "TopQ"), Bot(BotQID, "BotQ"),
+ OnlyBottomUp(true), OnlyTopDown(false) {}
virtual bool shouldTrackPressure(unsigned NumRegionInstrs);
@@ -1709,6 +1716,19 @@
}
assert((!ForceTopDown || !ForceBottomUp) &&
"-misched-topdown incompatible with -misched-bottomup");
+
+ // Check -misched-topdown/bottomup can force or unforce scheduling direction.
+ // e.g. -misched-bottomup=false allows scheduling in both directions.
+ if (ForceBottomUp.getNumOccurrences() > 0) {
+ OnlyBottomUp = ForceBottomUp;
+ if (OnlyBottomUp)
+ OnlyTopDown = false;
+ }
+ if (ForceTopDown.getNumOccurrences() > 0) {
+ OnlyTopDown = ForceTopDown;
+ if (OnlyTopDown)
+ OnlyBottomUp = false;
+ }
}
void ConvergingScheduler::releaseTopNode(SUnit *SU) {
@@ -2674,7 +2694,7 @@
}
SUnit *SU;
do {
- if (ForceTopDown) {
+ if (OnlyTopDown) {
SU = Top.pickOnlyChoice();
if (!SU) {
CandPolicy NoPolicy;
@@ -2686,7 +2706,7 @@
}
IsTopNode = true;
}
- else if (ForceBottomUp) {
+ else if (OnlyBottomUp) {
SU = Bot.pickOnlyChoice();
if (!SU) {
CandPolicy NoPolicy;