Skip to content

Commit cb7561a

Browse files
authored
[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.
1 parent 28b8207 commit cb7561a

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,6 +3804,12 @@ ScheduleDAGMILive *llvm::createGenericSchedLive(MachineSchedContext *C) {
38043804
// data and pass it to later mutations. Have a single mutation that gathers
38053805
// the interesting nodes in one pass.
38063806
DAG->addMutation(createCopyConstrainDAGMutation(DAG->TII, DAG->TRI));
3807+
3808+
const TargetSubtargetInfo &STI = C->MF->getSubtarget();
3809+
// Add MacroFusion mutation if fusions are not empty.
3810+
const auto &MacroFusions = STI.getMacroFusions();
3811+
if (!MacroFusions.empty())
3812+
DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
38073813
return DAG;
38083814
}
38093815

@@ -3953,8 +3959,15 @@ void PostGenericScheduler::schedNode(SUnit *SU, bool IsTopNode) {
39533959
}
39543960

39553961
ScheduleDAGMI *llvm::createGenericSchedPostRA(MachineSchedContext *C) {
3956-
return new ScheduleDAGMI(C, std::make_unique<PostGenericScheduler>(C),
3957-
/*RemoveKillFlags=*/true);
3962+
ScheduleDAGMI *DAG =
3963+
new ScheduleDAGMI(C, std::make_unique<PostGenericScheduler>(C),
3964+
/*RemoveKillFlags=*/true);
3965+
const TargetSubtargetInfo &STI = C->MF->getSubtarget();
3966+
// Add MacroFusion mutation if fusions are not empty.
3967+
const auto &MacroFusions = STI.getMacroFusions();
3968+
if (!MacroFusions.empty())
3969+
DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
3970+
return DAG;
39583971
}
39593972

39603973
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -362,26 +362,9 @@ class RISCVPassConfig : public TargetPassConfig {
362362
DAG->addMutation(createLoadClusterDAGMutation(
363363
DAG->TII, DAG->TRI, /*ReorderWhileClustering=*/true));
364364
}
365-
const auto &MacroFusions = ST.getMacroFusions();
366-
if (!MacroFusions.empty()) {
367-
DAG = DAG ? DAG : createGenericSchedLive(C);
368-
DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
369-
}
370365
return DAG;
371366
}
372367

373-
ScheduleDAGInstrs *
374-
createPostMachineScheduler(MachineSchedContext *C) const override {
375-
const RISCVSubtarget &ST = C->MF->getSubtarget<RISCVSubtarget>();
376-
const auto &MacroFusions = ST.getMacroFusions();
377-
if (!MacroFusions.empty()) {
378-
ScheduleDAGMI *DAG = createGenericSchedPostRA(C);
379-
DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
380-
return DAG;
381-
}
382-
return nullptr;
383-
}
384-
385368
void addIRPasses() override;
386369
bool addPreISel() override;
387370
bool addInstSelector() override;

0 commit comments

Comments
 (0)