[llvm] [AMDGPU] Add scheduling stage to rewrite MFMA from VGPR to AGPR (PR #149367)
Lucas Ramirez via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 09:18:29 PDT 2025
================
@@ -401,6 +406,61 @@ class OccInitialScheduleStage : public GCNSchedStage {
: GCNSchedStage(StageID, DAG) {}
};
+class RewriteScheduleStage : public GCNSchedStage {
+private:
+ // Record regions with excess archvgpr register pressure over the physical
+ // register limit. Register pressure in these regions usually will result in
+ // spilling.
+ BitVector RegionsWithExcessArchVGPR;
+
+ MachineBranchProbabilityInfo MBPI;
+ MachineBlockFrequencyInfo MBFI;
+
+ const SIInstrInfo *TII;
+ const SIRegisterInfo *SRI;
+
+ /// Do a speculative rewrite and collect copy locations. The speculative
+ /// rewrite allows us to calulcate the RP of the code after the rewrite, and
+ /// the copy locations allow us to calculate the total cost of copies required
+ /// for the rewrite. Stores the rewritten instructions in \p RewriteCands ,
+ /// the copy locations for uses (of the MFMA result) in \p CopyForUse and the
+ /// copy locations for defs (of the MFMA operands) in \p CopyForDef
+ bool
+ initHeuristics(std::vector<std::pair<MachineInstr *, unsigned>> &RewriteCands,
+ DenseMap<MachineBasicBlock *, std::set<Register>> &CopyForUse,
+ SmallPtrSetImpl<MachineInstr *> &CopyForDef);
+
+ /// Calculate the rewrite cost and undo the state change (e.g. rewriting) done
+ /// in initHueristics. Uses \p CopyForUse and \p CopyForDef to calculate copy
----------------
lucas-rami wrote:
```suggestion
/// in initHeuristics. Uses \p CopyForUse and \p CopyForDef to calculate copy
```
https://github.com/llvm/llvm-project/pull/149367
More information about the llvm-commits
mailing list