[llvm] AMDGPU: Delete FillMFMAShadowMutation (PR #123861)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 17:48:02 PST 2025
================
@@ -586,117 +586,6 @@ void GCNSubtarget::adjustSchedDependency(
}
}
-namespace {
-struct FillMFMAShadowMutation : ScheduleDAGMutation {
- const SIInstrInfo *TII;
-
- ScheduleDAGMI *DAG;
-
- FillMFMAShadowMutation(const SIInstrInfo *tii) : TII(tii) {}
-
- bool isSALU(const SUnit *SU) const {
- const MachineInstr *MI = SU->getInstr();
- return MI && TII->isSALU(*MI) && !MI->isTerminator();
- }
-
- bool isVALU(const SUnit *SU) const {
- const MachineInstr *MI = SU->getInstr();
- return MI && TII->isVALU(*MI);
- }
-
- // Link as many SALU instructions in chain as possible. Return the size
- // of the chain. Links up to MaxChain instructions.
- unsigned linkSALUChain(SUnit *From, SUnit *To, unsigned MaxChain,
- SmallPtrSetImpl<SUnit *> &Visited) const {
- SmallVector<SUnit *, 8> Worklist({To});
- unsigned Linked = 0;
-
- while (!Worklist.empty() && MaxChain-- > 0) {
- SUnit *SU = Worklist.pop_back_val();
- if (!Visited.insert(SU).second)
- continue;
-
- LLVM_DEBUG(dbgs() << "Inserting edge from\n"; DAG->dumpNode(*From);
- dbgs() << "to\n"; DAG->dumpNode(*SU); dbgs() << '\n');
-
- if (SU != From && From != &DAG->ExitSU && DAG->canAddEdge(SU, From))
- if (DAG->addEdge(SU, SDep(From, SDep::Artificial)))
- ++Linked;
-
- for (SDep &SI : From->Succs) {
- SUnit *SUv = SI.getSUnit();
- if (SUv != From && SU != &DAG->ExitSU && isVALU(SUv) &&
- DAG->canAddEdge(SUv, SU))
- DAG->addEdge(SUv, SDep(SU, SDep::Artificial));
- }
-
- for (SDep &SI : SU->Succs) {
- SUnit *Succ = SI.getSUnit();
- if (Succ != SU && isSALU(Succ))
- Worklist.push_back(Succ);
- }
- }
-
- return Linked;
- }
-
- void apply(ScheduleDAGInstrs *DAGInstrs) override {
- const GCNSubtarget &ST = DAGInstrs->MF.getSubtarget<GCNSubtarget>();
- if (!ST.hasMAIInsts())
- return;
- DAG = static_cast<ScheduleDAGMI *>(DAGInstrs);
- const TargetSchedModel *TSchedModel = DAGInstrs->getSchedModel();
- if (!TSchedModel || DAG->SUnits.empty())
- return;
-
- // Scan for MFMA long latency instructions and try to add a dependency
- // of available SALU instructions to give them a chance to fill MFMA
- // shadow. That is desirable to fill MFMA shadow with SALU instructions
- // rather than VALU to prevent power consumption bursts and throttle.
- auto LastSALU = DAG->SUnits.begin();
- auto E = DAG->SUnits.end();
- SmallPtrSet<SUnit *, 32> Visited;
- for (SUnit &SU : DAG->SUnits) {
- MachineInstr &MAI = *SU.getInstr();
- if (!TII->isMAI(MAI) ||
- MAI.getOpcode() == AMDGPU::V_ACCVGPR_WRITE_B32_e64 ||
- MAI.getOpcode() == AMDGPU::V_ACCVGPR_READ_B32_e64)
- continue;
-
- unsigned Lat = TSchedModel->computeInstrLatency(&MAI) - 1;
-
- LLVM_DEBUG(dbgs() << "Found MFMA: "; DAG->dumpNode(SU);
- dbgs() << "Need " << Lat
- << " instructions to cover latency.\n");
-
- // Find up to Lat independent scalar instructions as early as
- // possible such that they can be scheduled after this MFMA.
- for (; Lat && LastSALU != E; ++LastSALU) {
- if (Visited.count(&*LastSALU))
- continue;
-
- if (&SU == &DAG->ExitSU || &SU == &*LastSALU || !isSALU(&*LastSALU) ||
- !DAG->canAddEdge(&*LastSALU, &SU))
- continue;
-
- Lat -= linkSALUChain(&SU, &*LastSALU, Lat, Visited);
- }
- }
- }
-};
-} // namespace
-
-void GCNSubtarget::getPostRAMutations(
- std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
- Mutations.push_back(std::make_unique<FillMFMAShadowMutation>(&InstrInfo));
-}
-
-std::unique_ptr<ScheduleDAGMutation>
-GCNSubtarget::createFillMFMAShadowMutation(const TargetInstrInfo *TII) const {
- return EnablePowerSched ? std::make_unique<FillMFMAShadowMutation>(&InstrInfo)
----------------
jrbyrnes wrote:
Should also delete the flag corresponding with EnablePowerSched ?
https://github.com/llvm/llvm-project/pull/123861
More information about the llvm-commits
mailing list