[llvm] [AMDGPU][NFC] Print the peak pressure across an instruction in downward RP mode (PR #228291)
Dhruva Chakrabarti via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 17:58:58 PDT 2026
https://github.com/dhruvachak created https://github.com/llvm/llvm-project/pull/228291
The register pressure printer reports two columns per instruction. In upward mode, the second one is the tracker's MaxPressure. In downward mode it was the pressure after the instruction.
Report MaxPressure in both modes. This is NFC today, because the downward tracker only updates MaxPressure once at the end of advanceToNext(), so the peak and the pressure after the instruction are the same value.
Assisted-by: Cursor/Claude Opus
>From 5a94c14bbe081961d1df3f2183b79a279b9f6f0e Mon Sep 17 00:00:00 2001
From: Dhruva Chakrabarti <Dhruva.Chakrabarti at amd.com>
Date: Thu, 24 Sep 2026 17:38:31 -0500
Subject: [PATCH] [AMDGPU][NFC] Print the peak pressure across an instruction
in downward RP mode
The register pressure printer reports two columns per instruction. In
upward mode, the second one is the tracker's MaxPressure. In downward mode
it was the pressure after the instruction.
Report MaxPressure in both modes. This is NFC today, because the downward
tracker only updates MaxPressure once at the end of advanceToNext(), so
the peak and the pressure after the instruction are the same value.
Assisted-by: Cursor/Claude Opus
---
llvm/lib/Target/AMDGPU/GCNRegPressure.cpp | 3 ++-
llvm/lib/Target/AMDGPU/GCNRegPressure.h | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
index 8f9362e19bf852a..2a4f0f2745401d7 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -1026,8 +1026,9 @@ bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
while (!RPT.advanceBeforeNext()) {
GCNRegPressure RPBeforeMI = RPT.getPressure();
+ RPT.resetMaxPressure();
RPT.advanceToNext();
- RP.emplace_back(RPBeforeMI, RPT.getPressure());
+ RP.emplace_back(RPBeforeMI, RPT.getMaxPressure());
}
LiveOut = RPT.getLiveRegs();
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.h b/llvm/lib/Target/AMDGPU/GCNRegPressure.h
index 307b22759f352a0..fc8ff6c9c7b18fa 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.h
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.h
@@ -353,6 +353,10 @@ class GCNRPTracker {
void clearMaxPressure() { MaxPressure.clear(); }
+ const GCNRegPressure &getMaxPressure() const { return MaxPressure; }
+
+ void resetMaxPressure() { MaxPressure = CurPressure; }
+
GCNRegPressure getPressure() const { return CurPressure; }
decltype(LiveRegs) moveLiveRegs() {
@@ -387,10 +391,6 @@ class GCNUpwardRPTracker : public GCNRPTracker {
/// to reported by LIS.
bool isValid() const;
- const GCNRegPressure &getMaxPressure() const { return MaxPressure; }
-
- void resetMaxPressure() { MaxPressure = CurPressure; }
-
GCNRegPressure getMaxPressureAndReset() {
GCNRegPressure RP = MaxPressure;
resetMaxPressure();
More information about the llvm-commits
mailing list