[llvm] [AMDGPU] Prefer lower total register usage in regions with spilling (PR #71882)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 16:29:52 PST 2023


================
@@ -115,7 +119,19 @@ bool GCNRegPressure::less(const GCNSubtarget &ST,
     SGPRImportant = false;
   }
 
-  // compare large regs pressure
+  // In regions with spilling, we should give prefernce to the schedule with
+  // less general RP.
+  if (Occ <= MFI.getMinWavesPerEU()) {
+    unsigned GPRPressure =
+        SGPRImportant ? getSGPRNum() : getVGPRNum(ST.hasGFX90AInsts());
+    unsigned OtherGPRPressure =
+        SGPRImportant ? O.getSGPRNum() : O.getVGPRNum(ST.hasGFX90AInsts());
+
+    if (GPRPressure != OtherGPRPressure)
+      return GPRPressure < OtherGPRPressure;
+  }
----------------
jrbyrnes wrote:

Hi Valery,

Please see the new iteration of the work -- this has better `SGPRImportant` handling. It builds upon "Improve ExcessRP Flagging". As mentioned below, if this approach is agreed upon (at least at a high level), I'll create a separate PR for that patch.

> How about translating SGPR excess into a number of VGPRs used for SGPR spilling, add that number to the number of already used VGPRs and comparing only VGPRs?

I  think it is best to do this separately, but it does seem like an interesting feature.


https://github.com/llvm/llvm-project/pull/71882


More information about the llvm-commits mailing list