[llvm] [AMDGPU] Efficient way to get NumArchVGPRs. (PR #182537)
Sirish Pande via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 20 09:02:03 PST 2026
https://github.com/srpande created https://github.com/llvm/llvm-project/pull/182537
No functional change. Cleaning up to get number of VGPRs for different AMDGPU target based on features.
>From 85c383f7b39adc68de8d098d114dc4e42838cdba Mon Sep 17 00:00:00 2001
From: Sirish Pande <Sirish.Pande at amd.com>
Date: Fri, 20 Feb 2026 10:34:48 -0600
Subject: [PATCH] [AMDGPU] Efficient way to get NumArchVGPRs.
---
llvm/lib/Target/AMDGPU/GCNSubtarget.cpp | 2 +-
llvm/lib/Target/AMDGPU/SIFrameLowering.cpp | 3 +--
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
index da63628798776..6db0426d8a092 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
@@ -576,7 +576,7 @@ GCNSubtarget::getMaxNumVectorRegs(const Function &F) const {
unsigned MaxNumVGPRs = MaxVectorRegs;
unsigned MaxNumAGPRs = 0;
- unsigned NumArchVGPRs = has1024AddressableVGPRs() ? 1024 : 256;
+ unsigned NumArchVGPRs = getAddressableNumArchVGPRs();
// On GFX90A, the number of VGPRs and AGPRs need not be equal. Theoretically,
// a wave may have up to 512 total vector registers combining together both
diff --git a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
index a0952b3b566a7..4a62af56fd8e5 100644
--- a/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
@@ -1746,8 +1746,7 @@ void SIFrameLowering::determineCalleeSaves(MachineFunction &MF,
assert(!NeedExecCopyReservedReg &&
"Whole wave functions can use the reg mapped for their i1 argument");
- // FIXME: Be more efficient!
- unsigned NumArchVGPRs = ST.has1024AddressableVGPRs() ? 1024 : 256;
+ unsigned NumArchVGPRs = ST.getAddressableNumArchVGPRs();
for (MCRegister Reg :
AMDGPU::VGPR_32RegClass.getRegisters().take_front(NumArchVGPRs))
if (MF.getRegInfo().isPhysRegModified(Reg)) {
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index ee461575b509f..17c81186d5299 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -4071,7 +4071,7 @@ SIRegisterInfo::getSubRegAlignmentNumBits(const TargetRegisterClass *RC,
unsigned SIRegisterInfo::getNumUsedPhysRegs(const MachineRegisterInfo &MRI,
const TargetRegisterClass &RC,
bool IncludeCalls) const {
- unsigned NumArchVGPRs = ST.has1024AddressableVGPRs() ? 1024 : 256;
+ unsigned NumArchVGPRs = ST.getAddressableNumArchVGPRs();
ArrayRef<MCPhysReg> Registers =
(RC.getID() == AMDGPU::VGPR_32RegClassID)
? RC.getRegisters().take_front(NumArchVGPRs)
More information about the llvm-commits
mailing list