Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sched] Add MacroFusion mutation if fusions are not empty #72227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading