[PATCH] D67299: AMDGPU: Avoid repeating a little work in the scheduler

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 12:58:58 PDT 2019


arsenm created this revision.
arsenm added a reviewer: rampitec.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.

These getters are non-trivial, and should always return the same
result. Move them to avoid this, although this doesn't give a
noteworthy compile time improvement.


https://reviews.llvm.org/D67299

Files:
  lib/Target/AMDGPU/GCNSchedStrategy.cpp
  lib/Target/AMDGPU/GCNSchedStrategy.h


Index: lib/Target/AMDGPU/GCNSchedStrategy.h
===================================================================
--- lib/Target/AMDGPU/GCNSchedStrategy.h
+++ lib/Target/AMDGPU/GCNSchedStrategy.h
@@ -43,6 +43,9 @@
   std::vector<unsigned> Pressure;
   std::vector<unsigned> MaxPressure;
 
+  unsigned SGPRPressureSetID;
+  unsigned VGPRPressureSetID;
+
   unsigned SGPRExcessLimit;
   unsigned VGPRExcessLimit;
   unsigned SGPRCriticalLimit;
Index: lib/Target/AMDGPU/GCNSchedStrategy.cpp
===================================================================
--- lib/Target/AMDGPU/GCNSchedStrategy.cpp
+++ lib/Target/AMDGPU/GCNSchedStrategy.cpp
@@ -34,6 +34,9 @@
 
   MF = &DAG->MF;
 
+  SGPRPressureSetID = SRI->getSGPRPressureSet();
+  VGPRPressureSetID = SRI->getVGPRPressureSet();
+
   const GCNSubtarget &ST = MF->getSubtarget<GCNSubtarget>();
 
   // FIXME: This is also necessary, because some passes that run after
@@ -48,10 +51,8 @@
     SGPRCriticalLimit = ST.getMaxNumSGPRs(TargetOccupancy, true);
     VGPRCriticalLimit = ST.getMaxNumVGPRs(TargetOccupancy);
   } else {
-    SGPRCriticalLimit = SRI->getRegPressureSetLimit(DAG->MF,
-                                                    SRI->getSGPRPressureSet());
-    VGPRCriticalLimit = SRI->getRegPressureSetLimit(DAG->MF,
-                                                    SRI->getVGPRPressureSet());
+    SGPRCriticalLimit = SRI->getRegPressureSetLimit(DAG->MF, SGPRPressureSetID);
+    VGPRCriticalLimit = SRI->getRegPressureSetLimit(DAG->MF, VGPRPressureSetID);
   }
 
   SGPRCriticalLimit -= ErrorMargin;
@@ -82,8 +83,8 @@
     TempTracker.getUpwardPressure(SU->getInstr(), Pressure, MaxPressure);
   }
 
-  unsigned NewSGPRPressure = Pressure[SRI->getSGPRPressureSet()];
-  unsigned NewVGPRPressure = Pressure[SRI->getVGPRPressureSet()];
+  unsigned NewSGPRPressure = Pressure[SGPRPressureSetID];
+  unsigned NewVGPRPressure = Pressure[VGPRPressureSetID];
 
   // If two instructions increase the pressure of different register sets
   // by the same amount, the generic scheduler will prefer to schedule the
@@ -108,12 +109,12 @@
   // marked as RegExcess in tryCandidate() when they are compared with
   // instructions that increase the register pressure.
   if (ShouldTrackVGPRs && NewVGPRPressure >= VGPRExcessLimit) {
-    Cand.RPDelta.Excess = PressureChange(SRI->getVGPRPressureSet());
+    Cand.RPDelta.Excess = PressureChange(VGPRPressureSetID);
     Cand.RPDelta.Excess.setUnitInc(NewVGPRPressure - VGPRExcessLimit);
   }
 
   if (ShouldTrackSGPRs && NewSGPRPressure >= SGPRExcessLimit) {
-    Cand.RPDelta.Excess = PressureChange(SRI->getSGPRPressureSet());
+    Cand.RPDelta.Excess = PressureChange(SGPRPressureSetID);
     Cand.RPDelta.Excess.setUnitInc(NewSGPRPressure - SGPRExcessLimit);
   }
 
@@ -127,10 +128,10 @@
 
   if (SGPRDelta >= 0 || VGPRDelta >= 0) {
     if (SGPRDelta > VGPRDelta) {
-      Cand.RPDelta.CriticalMax = PressureChange(SRI->getSGPRPressureSet());
+      Cand.RPDelta.CriticalMax = PressureChange(SGPRPressureSetID);
       Cand.RPDelta.CriticalMax.setUnitInc(SGPRDelta);
     } else {
-      Cand.RPDelta.CriticalMax = PressureChange(SRI->getVGPRPressureSet());
+      Cand.RPDelta.CriticalMax = PressureChange(VGPRPressureSetID);
       Cand.RPDelta.CriticalMax.setUnitInc(VGPRDelta);
     }
   }
@@ -144,8 +145,8 @@
                                          SchedCandidate &Cand) {
   const SIRegisterInfo *SRI = static_cast<const SIRegisterInfo*>(TRI);
   ArrayRef<unsigned> Pressure = RPTracker.getRegSetPressureAtPos();
-  unsigned SGPRPressure = Pressure[SRI->getSGPRPressureSet()];
-  unsigned VGPRPressure = Pressure[SRI->getVGPRPressureSet()];
+  unsigned SGPRPressure = Pressure[SGPRPressureSetID];
+  unsigned VGPRPressure = Pressure[VGPRPressureSetID];
   ReadyQueue &Q = Zone.Available;
   for (SUnit *SU : Q) {
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67299.219157.patch
Type: text/x-patch
Size: 3836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190906/9e7f3a7a/attachment.bin>


More information about the llvm-commits mailing list