diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp @@ -344,7 +344,8 @@ } unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI) { - return 8; + // 16 for GFX9, 8 for GFX6-8 + return isGFX9(*STI) ? 16 : 8; } unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI) { @@ -433,7 +434,8 @@ unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs) { NumSGPRs = alignTo(std::max(1u, NumSGPRs), getSGPREncodingGranule(STI)); // SGPRBlocks is actual number of SGPR blocks minus 1. - return NumSGPRs / getSGPREncodingGranule(STI) - 1; + unsigned NumSGPRBlocks = NumSGPRs / getSGPREncodingGranule(STI) - 1; + return isGFX9(*STI) ? NumSGPRBlocks * 2 : NumSGPRBlocks; } unsigned getVGPRAllocGranule(const MCSubtargetInfo *STI,