Skip to content

Commit

Permalink
[Sched] Add MacroFusion mutation if fusions are not empty (#72227)
Browse files Browse the repository at this point in the history
We can get the fusions list by `getMacroFusions` and if it is not
empty, then we will add the MacroFusion mutation automatically.
  • Loading branch information
wangpc-pp authored Feb 7, 2024
1 parent 28b8207 commit cb7561a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
17 changes: 15 additions & 2 deletions llvm/lib/CodeGen/MachineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

//===----------------------------------------------------------------------===//
Expand Down
17 changes: 0 additions & 17 deletions llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cb7561a

Please sign in to comment.