[llvm-branch-commits] [llvm] [AMDGPU] Physical register tracking in GCN trackers. (PR #184275)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 3 02:19:09 PST 2026


================
@@ -601,6 +712,45 @@ void GCNUpwardRPTracker::recede(const MachineInstr &MI) {
                         ? max(CurVirtPressure + ECDefPressure, MaxVirtPressure)
                         : max(CurVirtPressure, MaxVirtPressure);
 
+  // Track physical register defs and uses (only if enabled).
+  if (TrackPhysRegs) {
+    // Kill physical register defs (moving backward in upward tracking).
+    for (const MachineOperand &MO : MI.all_defs()) {
+      if (!MO.getReg().isPhysical())
+        continue;
+      Register Reg = MO.getReg();
+      if (!MRI->isAllocatable(Reg))
+        continue;
+
+      // Check if any unit of this register was live before and erase them.
+      bool WasLive = eraseAllLiveUnits(Reg);
+
+      // Update pressure once per register if it was live.
+      if (WasLive)
+        CurPhysPressure.inc(Reg, LaneBitmask::getAll(), LaneBitmask::getNone(),
+                            *MRI);
+    }
+
+    // Make physical register uses alive (moving backward in upward tracking).
+    for (const MachineOperand &MO : MI.uses()) {
----------------
arsenm wrote:

all_uses 

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


More information about the llvm-branch-commits mailing list