[llvm] [AMDGPU] Add `GCNRPTarget` to track register pressure against a target (PR #145765)

Lucas Ramirez via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 26 04:11:13 PDT 2025


================
@@ -1901,32 +1734,35 @@ bool PreRARematStage::canIncreaseOccupancyOrReduceSpill() {
     // the register allocator i.e., the scheduler will not be able to reason
     // about these savings and will not report an increase in the achievable
     // occupancy, triggering rollbacks.
-    ExcessRP Excess(ST, RP, MaxSGPRsNoSpill, MaxVGPRsNoSpill,
-                    /*CombineVGPRSavings=*/true);
-    if (Excess && IncreaseOccupancy) {
+    GCNRPTarget Target(MaxSGPRsNoSpill, MaxVGPRsNoSpill, MF, RP,
+                       /*CombineVGPRSavings=*/true);
+    if (!Target.satisfied() && IncreaseOccupancy) {
       // There is spilling in the region and we were so far trying to increase
       // occupancy. Strop trying that and focus on reducing spilling.
       IncreaseOccupancy = false;
       OptRegions.clear();
     } else if (IncreaseOccupancy) {
       // There is no spilling in the region, try to increase occupancy.
-      Excess = ExcessRP(ST, RP, MaxSGPRsIncOcc, MaxVGPRsIncOcc,
-                        /*CombineVGPRSavings=*/false);
+      Target = GCNRPTarget(MaxSGPRsIncOcc, MaxVGPRsIncOcc, MF, RP,
+                           /*CombineVGPRSavings=*/false);
     }
-    if (Excess)
-      OptRegions.insert({I, Excess});
+    if (!Target.satisfied())
+      OptRegions.insert({I, Target});
   }
   if (OptRegions.empty())
     return false;
 
 #ifndef NDEBUG
----------------
lucas-rami wrote:

Sounds good, will do this in my upcoming change to the stage which will touch this part of the code anyway.

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


More information about the llvm-commits mailing list