[llvm-branch-commits] [llvm] [AMDGPU] Take the VGPR and AVGPR maximum pressure from one point (PR #236175)

Valery Pykhtin via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 29 09:08:05 PDT 2026


================
@@ -1095,41 +1096,42 @@ LLVM_DUMP_METHOD void llvm::dumpMaxRegPressure(MachineFunction &MF,
   auto &OS = dbgs();
   const char *RegName = GCNRegPressure::getName(Kind);
 
+  // Count only the registers of Kind, from the live sets. The maximum of a
+  // pressure tracker pairs the VGPR and AVGPR components, so its VGPR component
+  // alone can miss the VGPR peak. Max pressure can occur at either the
+  // early-clobber or register slot. This is slow but this is diagnostic code.
   unsigned MaxNumRegs = 0;
   const MachineInstr *MaxPressureMI = nullptr;
-  GCNUpwardRPTracker RPT(LIS);
+  SlotIndex MaxPressureSlot;
+  GCNRPTracker::LiveRegSet LiveSet;
   for (const MachineBasicBlock &MBB : MF) {
-    RPT.reset(MRI, LIS.getSlotIndexes()->getMBBEndIdx(&MBB).getPrevSlot());
     for (const MachineInstr &MI : reverse(MBB)) {
-      RPT.recede(MI);
-      unsigned NumRegs = RPT.getMaxPressure().getNumRegs(Kind);
-      if (NumRegs > MaxNumRegs) {
-        MaxNumRegs = NumRegs;
-        MaxPressureMI = &MI;
+      if (MI.isDebugInstr())
+        continue;
+      SlotIndex MISlot = LIS.getInstructionIndex(MI);
+      for (SlotIndex SI : {MISlot.getRegSlot(false), MISlot.getRegSlot(true)}) {
+        GCNRPTracker::LiveRegSet SILiveSet = getLiveRegs(SI, LIS, MRI, Kind);
+        unsigned NumRegs = getRegPressure(MRI, SILiveSet).getNumRegs(Kind);
+        if (NumRegs > MaxNumRegs) {
+          MaxNumRegs = NumRegs;
+          MaxPressureMI = &MI;
+          MaxPressureSlot = SI;
+          LiveSet = std::move(SILiveSet);
----------------
vpykhtin wrote:

One of the purpose of this dump function was the demonstration of how RP trackers work. You... khm... ruined it :) let alone how horribly inefficient this is. I cannot come up with a nice solution at the moment - basically we might want to customize calculation over register numbers at each point where the pressure changes.

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


More information about the llvm-branch-commits mailing list