Skip to content

Commit c5a068a

Browse files
authored
[AMDGPU] Remove s_cmpk_* for GFX12 (#75497)
No GFX12 encoding was added for these. This patch adds tests that they are not recognized by the assembler and defends against generating them in codegen.
1 parent c26174f commit c5a068a

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,9 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
830830

831831
bool hasInstPrefetch() const { return getGeneration() >= GFX10; }
832832

833+
// Has s_cmpk_* instructions.
834+
bool hasSCmpK() const { return getGeneration() < GFX12; }
835+
833836
// Scratch is allocated in 256 dword per wave blocks for the entire
834837
// wavefront. When viewed from the perspective of an arbitrary workitem, this
835838
// is 4-byte aligned.

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ void SIShrinkInstructions::copyExtraImplicitOps(MachineInstr &NewMI,
211211
}
212212

213213
void SIShrinkInstructions::shrinkScalarCompare(MachineInstr &MI) const {
214+
if (!ST->hasSCmpK())
215+
return;
216+
214217
// cmpk instructions do scc = dst <cc op> imm16, so commute the instruction to
215218
// get constants on the RHS.
216219
if (!MI.getOperand(0).isReg())

llvm/test/MC/AMDGPU/gfx12_unsupported.s

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,42 @@ ds_sub_gs_reg_rtn v[0:1], v2 gds
4343
ds_wrap_rtn_b32 v0, v1, v2, v3
4444
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
4545

46+
s_cmpk_eq_i32 s0, 0
47+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
48+
49+
s_cmpk_lg_i32 s0, 0
50+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
51+
52+
s_cmpk_gt_i32 s0, 0
53+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
54+
55+
s_cmpk_ge_i32 s0, 0
56+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
57+
58+
s_cmpk_lt_i32 s0, 0
59+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
60+
61+
s_cmpk_le_i32 s0, 0
62+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
63+
64+
s_cmpk_eq_u32 s0, 0
65+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
66+
67+
s_cmpk_lg_u32 s0, 0
68+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
69+
70+
s_cmpk_gt_u32 s0, 0
71+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
72+
73+
s_cmpk_ge_u32 s0, 0
74+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
75+
76+
s_cmpk_lt_u32 s0, 0
77+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
78+
79+
s_cmpk_le_u32 s0, 0
80+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
81+
4682
ds_gws_sema_release_all gds
4783
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
4884

0 commit comments

Comments
 (0)