Skip to content

Commit 7fff93d

Browse files
Shoreshenarsenm
andauthored
[AMDGPU] Set GRANULATED_WAVEFRONT_SGPR_COUNT of compute_pgm_rsrc1 to 0 for gfx10+ (llvm#154666)
According to `llvm-project/llvm/docs/AMDGPUUsage.rst::L5212` the `GRANULATED_WAVEFRONT_SGPR_COUNT`, which is `compute_pgm_rsrc1[6:9]` has to be 0 for gfx10+ arch --------- Co-authored-by: Matt Arsenault <[email protected]>
1 parent e3823a6 commit 7fff93d

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,13 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
11431143
const MCExpr *SubGPR = MCBinaryExpr::createSub(DivGPR, OneConst, Ctx);
11441144
return SubGPR;
11451145
};
1146-
1147-
ProgInfo.SGPRBlocks = GetNumGPRBlocks(ProgInfo.NumSGPRsForWavesPerEU,
1148-
IsaInfo::getSGPREncodingGranule(&STM));
1146+
// GFX10+ will always allocate 128 SGPRs and this field must be 0
1147+
if (STM.getGeneration() >= AMDGPUSubtarget::GFX10) {
1148+
ProgInfo.SGPRBlocks = CreateExpr(0ul);
1149+
} else {
1150+
ProgInfo.SGPRBlocks = GetNumGPRBlocks(
1151+
ProgInfo.NumSGPRsForWavesPerEU, IsaInfo::getSGPREncodingGranule(&STM));
1152+
}
11491153
ProgInfo.VGPRBlocks = GetNumGPRBlocks(ProgInfo.NumVGPRsForWavesPerEU,
11501154
IsaInfo::getVGPREncodingGranule(&STM));
11511155

llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,7 +3202,7 @@ define amdgpu_kernel void @dyn_extract_v5f64_s_s(ptr addrspace(1) %out, i32 %sel
32023202
; GFX10-NEXT: kernel_code_entry_byte_offset = 256
32033203
; GFX10-NEXT: kernel_code_prefetch_byte_size = 0
32043204
; GFX10-NEXT: granulated_workitem_vgpr_count = 0
3205-
; GFX10-NEXT: granulated_wavefront_sgpr_count = 1
3205+
; GFX10-NEXT: granulated_wavefront_sgpr_count = 0
32063206
; GFX10-NEXT: priority = 0
32073207
; GFX10-NEXT: float_mode = 240
32083208
; GFX10-NEXT: priv = 0
@@ -4206,7 +4206,7 @@ define amdgpu_kernel void @dyn_extract_v4f32_s_s_s(ptr addrspace(1) %out, i32 %s
42064206
; GFX10-NEXT: kernel_code_entry_byte_offset = 256
42074207
; GFX10-NEXT: kernel_code_prefetch_byte_size = 0
42084208
; GFX10-NEXT: granulated_workitem_vgpr_count = 0
4209-
; GFX10-NEXT: granulated_wavefront_sgpr_count = 1
4209+
; GFX10-NEXT: granulated_wavefront_sgpr_count = 0
42104210
; GFX10-NEXT: priority = 0
42114211
; GFX10-NEXT: float_mode = 240
42124212
; GFX10-NEXT: priv = 0
@@ -4560,7 +4560,7 @@ define amdgpu_kernel void @dyn_extract_v4f64_s_s_s(ptr addrspace(1) %out, i32 %s
45604560
; GFX10-NEXT: kernel_code_entry_byte_offset = 256
45614561
; GFX10-NEXT: kernel_code_prefetch_byte_size = 0
45624562
; GFX10-NEXT: granulated_workitem_vgpr_count = 0
4563-
; GFX10-NEXT: granulated_wavefront_sgpr_count = 1
4563+
; GFX10-NEXT: granulated_wavefront_sgpr_count = 0
45644564
; GFX10-NEXT: priority = 0
45654565
; GFX10-NEXT: float_mode = 240
45664566
; GFX10-NEXT: priv = 0
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1250 -filetype=obj < %s 2>&1 | llvm-objdump -d --section=.rodata - | FileCheck %s
2+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1200 -filetype=obj < %s 2>&1 | llvm-objdump -d --section=.rodata - | FileCheck %s
3+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -filetype=obj < %s 2>&1 | llvm-objdump -d --section=.rodata - | FileCheck %s
4+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -filetype=obj < %s 2>&1 | llvm-objdump -d --section=.rodata - | FileCheck %s
5+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 -filetype=obj < %s 2>&1 | llvm-objdump -d --section=.rodata - | FileCheck %s
6+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1031 -filetype=obj < %s 2>&1 | llvm-objdump -d --section=.rodata - | FileCheck %s
7+
8+
; CHECK-NOT: error
9+
define amdgpu_kernel void @test(i128 inreg) {
10+
ret void
11+
}

0 commit comments

Comments
 (0)