Skip to content

Commit ba131b7

Browse files
authored
[AMDGPU] Do not generate s_set_inst_prefetch_distance for GFX12 (#78190)
GFX12 can still encode the s_set_inst_prefetch_distance instruction but it has no effect.
1 parent ed60cb8 commit ba131b7

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,11 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
846846
return getGeneration() < SEA_ISLANDS;
847847
}
848848

849-
bool hasInstPrefetch() const { return getGeneration() >= GFX10; }
849+
bool hasInstPrefetch() const {
850+
// GFX12 can still encode the s_set_inst_prefetch_distance instruction but
851+
// it has no effect.
852+
return getGeneration() == GFX10 || getGeneration() == GFX11;
853+
}
850854

851855
bool hasPrefetch() const { return GFX12Insts; }
852856

llvm/test/CodeGen/AMDGPU/loop-prefetch-data.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ define amdgpu_kernel void @copy_flat(ptr nocapture %d, ptr nocapture readonly %s
1212
; GCN-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
1313
; GCN-NEXT: s_waitcnt lgkmcnt(0)
1414
; GCN-NEXT: s_add_nc_u64 s[2:3], s[2:3], 0xb0
15-
; GCN-NEXT: .p2align 6
1615
; GCN-NEXT: .LBB0_2: ; %for.body
1716
; GCN-NEXT: ; =>This Inner Loop Header: Depth=1
1817
; GCN-NEXT: s_delay_alu instid0(SALU_CYCLE_1)

llvm/test/CodeGen/AMDGPU/no-dup-inst-prefetch.ll

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -march=amdgcn -mcpu=gfx1030 -verify-machineinstrs < %s | FileCheck --check-prefix=GFX10 %s
3+
; RUN: llc -march=amdgcn -mcpu=gfx1200 -verify-machineinstrs < %s | FileCheck --check-prefix=GFX12 %s
34

45
define amdgpu_cs void @_amdgpu_cs_main(float %0, i32 %1) {
56
; GFX10-LABEL: _amdgpu_cs_main:
@@ -50,6 +51,55 @@ define amdgpu_cs void @_amdgpu_cs_main(float %0, i32 %1) {
5051
; GFX10-NEXT: .LBB0_4: ; %loop0_merge
5152
; GFX10-NEXT: s_inst_prefetch 0x2
5253
; GFX10-NEXT: s_endpgm
54+
;
55+
; GFX12-LABEL: _amdgpu_cs_main:
56+
; GFX12: ; %bb.0: ; %branch1_true
57+
; GFX12-NEXT: v_mov_b32_e32 v2, 0
58+
; GFX12-NEXT: v_cmp_ne_u32_e32 vcc_lo, 0, v1
59+
; GFX12-NEXT: v_mov_b32_e32 v1, 0
60+
; GFX12-NEXT: s_mov_b32 s4, 0
61+
; GFX12-NEXT: s_mov_b32 s1, 0
62+
; GFX12-NEXT: ; implicit-def: $sgpr2
63+
; GFX12-NEXT: s_branch .LBB0_2
64+
; GFX12-NEXT: .LBB0_1: ; %Flow
65+
; GFX12-NEXT: ; in Loop: Header=BB0_2 Depth=1
66+
; GFX12-NEXT: s_or_b32 exec_lo, exec_lo, s3
67+
; GFX12-NEXT: v_mov_b32_e32 v1, v0
68+
; GFX12-NEXT: s_and_b32 s0, exec_lo, s2
69+
; GFX12-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
70+
; GFX12-NEXT: s_or_b32 s1, s0, s1
71+
; GFX12-NEXT: s_and_not1_b32 exec_lo, exec_lo, s1
72+
; GFX12-NEXT: s_cbranch_execz .LBB0_4
73+
; GFX12-NEXT: .LBB0_2: ; %bb
74+
; GFX12-NEXT: ; =>This Inner Loop Header: Depth=1
75+
; GFX12-NEXT: s_or_b32 s2, s2, exec_lo
76+
; GFX12-NEXT: s_and_saveexec_b32 s3, vcc_lo
77+
; GFX12-NEXT: s_cbranch_execz .LBB0_1
78+
; GFX12-NEXT: ; %bb.3: ; %branch2_merge
79+
; GFX12-NEXT: ; in Loop: Header=BB0_2 Depth=1
80+
; GFX12-NEXT: s_mov_b32 s5, s4
81+
; GFX12-NEXT: s_mov_b32 s6, s4
82+
; GFX12-NEXT: s_mov_b32 s7, s4
83+
; GFX12-NEXT: s_mov_b32 s8, s4
84+
; GFX12-NEXT: s_mov_b32 s9, s4
85+
; GFX12-NEXT: s_mov_b32 s10, s4
86+
; GFX12-NEXT: s_mov_b32 s11, s4
87+
; GFX12-NEXT: s_mov_b32 s12, s4
88+
; GFX12-NEXT: s_mov_b32 s13, s4
89+
; GFX12-NEXT: s_mov_b32 s14, s4
90+
; GFX12-NEXT: s_mov_b32 s15, s4
91+
; GFX12-NEXT: s_and_not1_b32 s2, s2, exec_lo
92+
; GFX12-NEXT: image_sample_lz v1, [v2, v2, v1], s[8:15], s[4:7] dmask:0x1 dim:SQ_RSRC_IMG_3D
93+
; GFX12-NEXT: s_waitcnt vmcnt(0)
94+
; GFX12-NEXT: v_fma_f32 v1, v1, v0, 0
95+
; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
96+
; GFX12-NEXT: v_cmp_le_f32_e64 s0, 0, v1
97+
; GFX12-NEXT: s_and_b32 s0, s0, exec_lo
98+
; GFX12-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
99+
; GFX12-NEXT: s_or_b32 s2, s2, s0
100+
; GFX12-NEXT: s_branch .LBB0_1
101+
; GFX12-NEXT: .LBB0_4: ; %loop0_merge
102+
; GFX12-NEXT: s_endpgm
53103
branch1_true:
54104
br label %bb
55105

0 commit comments

Comments
 (0)