[llvm] [AMDGPU][Scheduler] Refactor ArchVGPR rematerialization during scheduling (PR #125885)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 09:54:36 PDT 2025
================
@@ -1688,174 +1696,421 @@ bool PreRARematStage::allUsesAvailableAt(const MachineInstr *InstToRemat,
return true;
}
-void PreRARematStage::collectRematerializableInstructions() {
- const SIRegisterInfo *SRI = static_cast<const SIRegisterInfo *>(DAG.TRI);
- for (unsigned I = 0, E = DAG.MRI.getNumVirtRegs(); I != E; ++I) {
- Register Reg = Register::index2VirtReg(I);
- if (!DAG.LIS->hasInterval(Reg))
- continue;
+namespace {
+/// Models excess register pressure in a region and tracks our progress as we
+/// identify rematerialization opportunities.
+struct ExcessRP {
+ /// Number of excess ArchVGPRs.
+ unsigned ArchVGPRs = 0;
+ /// Number of excess AGPRs.
+ unsigned AGPRs = 0;
+ /// For unified register files, number of excess VGPRs.
+ unsigned VGPRs = 0;
+ /// For unified register files with AGPR usage, number of excess ArchVGPRs to
+ /// save before we are able to save a whole allocation granule.
+ unsigned ArchVGPRsToAlignment = 0;
+ /// Whether the region uses AGPRs.
+ bool HasAGPRs = false;
+ /// Whether the subtarget has a unified RF.
+ bool UnifiedRF;
+
+ /// ArchVGPR allocation granule for unified RFs with AGPR usage.
+ static const unsigned Granule = 4;
----------------
jrbyrnes wrote:
Can we use something in `AMDGPU::IsaInfo` (e.g. `getVGPRAllocGranule`) instead of hardcoding 4?
https://github.com/llvm/llvm-project/pull/125885
More information about the llvm-commits
mailing list