[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 24 07:47:23 PDT 2026
================
@@ -601,6 +706,46 @@ 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 if so,
+ // erase all of the regunits from PhysLiveRegs.
+ bool WasLive = eraseAllLiveUnits(Reg.asMCReg());
+
+ // Update pressure once per register if any unit of this register was live
+ // before.
+ if (WasLive)
+ CurPhysPressure.inc(Reg.asMCReg(), /*IsAdd=*/false, *MRI);
+ }
+
+ // Make physical register uses alive (moving backward in upward tracking).
+ for (const MachineOperand &MO : MI.all_uses()) {
+ if (!MO.isReg() || !MO.getReg().isPhysical() || !MO.readsReg())
+ continue;
+ Register Reg = MO.getReg();
+ if (!MRI->isAllocatable(Reg))
+ continue;
+ // Check if any unit of this register was not live before and if so,
+ // insert all of the regunits into PhysLiveRegs.
+ bool WasNotLive = insertAllNotLiveUnits(Reg.asMCReg());
----------------
arsenm wrote:
Can you uninvert the naming and logic here
https://github.com/llvm/llvm-project/pull/184275
More information about the llvm-branch-commits
mailing list