[llvm] [AMDGPU] Efficient way to get NumArchVGPRs. (PR #182537)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 20 09:02:36 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Sirish Pande (srpande)
<details>
<summary>Changes</summary>
No functional change. Cleaning up to get number of VGPRs for different AMDGPU target based on features.
---
Full diff: https://github.com/llvm/llvm-project/pull/182537.diff
3 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.cpp (+1-1)
- (modified) llvm/lib/Target/AMDGPU/SIFrameLowering.cpp (+1-2)
- (modified) llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp (+1-1)
``````````diff
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/182537
More information about the llvm-commits
mailing list