[llvm] cb7561a - [Sched] Add MacroFusion mutation if fusions are not empty (#72227)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 23:38:06 PST 2024
Author: Wang Pengcheng
Date: 2024-02-07T15:38:02+08:00
New Revision: cb7561ac5a8445f5c526c949efd50f45f55bb089
URL: https://github.com/llvm/llvm-project/commit/cb7561ac5a8445f5c526c949efd50f45f55bb089
DIFF: https://github.com/llvm/llvm-project/commit/cb7561ac5a8445f5c526c949efd50f45f55bb089.diff
LOG: [Sched] Add MacroFusion mutation if fusions are not empty (#72227)
We can get the fusions list by `getMacroFusions` and if it is not
empty, then we will add the MacroFusion mutation automatically.
Added:
Modified:
llvm/lib/CodeGen/MachineScheduler.cpp
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index c4b6bf3372139e..750f739a559900 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -3804,6 +3804,12 @@ ScheduleDAGMILive *llvm::createGenericSchedLive(MachineSchedContext *C) {
// data and pass it to later mutations. Have a single mutation that gathers
// the interesting nodes in one pass.
DAG->addMutation(createCopyConstrainDAGMutation(DAG->TII, DAG->TRI));
+
+ const TargetSubtargetInfo &STI = C->MF->getSubtarget();
+ // Add MacroFusion mutation if fusions are not empty.
+ const auto &MacroFusions = STI.getMacroFusions();
+ if (!MacroFusions.empty())
+ DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
return DAG;
}
@@ -3953,8 +3959,15 @@ void PostGenericScheduler::schedNode(SUnit *SU, bool IsTopNode) {
}
ScheduleDAGMI *llvm::createGenericSchedPostRA(MachineSchedContext *C) {
- return new ScheduleDAGMI(C, std::make_unique<PostGenericScheduler>(C),
- /*RemoveKillFlags=*/true);
+ ScheduleDAGMI *DAG =
+ new ScheduleDAGMI(C, std::make_unique<PostGenericScheduler>(C),
+ /*RemoveKillFlags=*/true);
+ const TargetSubtargetInfo &STI = C->MF->getSubtarget();
+ // Add MacroFusion mutation if fusions are not empty.
+ const auto &MacroFusions = STI.getMacroFusions();
+ if (!MacroFusions.empty())
+ DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
+ return DAG;
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 2285c99d790100..4d062c0705dad1 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -362,26 +362,9 @@ class RISCVPassConfig : public TargetPassConfig {
DAG->addMutation(createLoadClusterDAGMutation(
DAG->TII, DAG->TRI, /*ReorderWhileClustering=*/true));
}
- const auto &MacroFusions = ST.getMacroFusions();
- if (!MacroFusions.empty()) {
- DAG = DAG ? DAG : createGenericSchedLive(C);
- DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
- }
return DAG;
}
- ScheduleDAGInstrs *
- createPostMachineScheduler(MachineSchedContext *C) const override {
- const RISCVSubtarget &ST = C->MF->getSubtarget<RISCVSubtarget>();
- const auto &MacroFusions = ST.getMacroFusions();
- if (!MacroFusions.empty()) {
- ScheduleDAGMI *DAG = createGenericSchedPostRA(C);
- DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
- return DAG;
- }
- return nullptr;
- }
-
void addIRPasses() override;
bool addPreISel() override;
bool addInstSelector() override;
More information about the llvm-commits
mailing list