From 797f240dfa93f2555da14300806fbdabf46a477b Mon Sep 17 00:00:00 2001 From: Luiz Neves Date: Sun, 22 Nov 2026 21:53:58 -0300 Subject: [PATCH 1/3] GPU test cs_w32_movrels64: s_movrels_b64 #1598 merged s_movrels_b32/b64 with CPU-only checks, and #1850's fixture covers only the b32 form. Lane 0 checks the pair read at odd and even M0, M0 from v_readfirstlane (not foldable), the b32 form at a base register, a destination overlapping the source, and SCC kept. Registered in check.py, run_gpu_tests.py and regen_fixtures.py; tests/semantic/ test_movrels64_fixture.py runs it on the CPU against an SGPR-file model. --- runtime/test/shaders/check.py | 4 +- runtime/test/shaders/cs_w32_movrels64.asm | 59 ++++++++++++++ scripts/run_gpu_tests.py | 6 +- .../fixtures/disasm/cs_w32_movrels64.s | 49 ++++++++++++ tests/semantic/regen_fixtures.py | 2 +- tests/semantic/test_movrels64_fixture.py | 79 +++++++++++++++++++ 6 files changed, 195 insertions(+), 4 deletions(-) create mode 100644 runtime/test/shaders/cs_w32_movrels64.asm create mode 100644 tests/semantic/fixtures/disasm/cs_w32_movrels64.s create mode 100644 tests/semantic/test_movrels64_fixture.py diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 330af9f4f3..58a7f31c7c 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -85,7 +85,7 @@ def not_found_message(build, missing): "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_partial_scmp", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_sincos", "cs_lds_b64_cmpst", "cs_w32_andn2_exec", - "cs_mask_vgpr_exec") + "cs_mask_vgpr_exec", "cs_w32_movrels64") # Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is # narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with # 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may @@ -115,6 +115,8 @@ def not_found_message(build, missing): # 64-bit scalar data ops and v_mad_u64_u32 (derivations in cs_w32_salu64.asm) # more ops with CPU-only checks until now (derivations in cs_w32_misc_ext.asm) # ops merged on 2026-11-22 with CPU-only checks (derivations in cs_w32_new_ops.asm) + # s_movrels_b64 pairs, run-time M0, overlap, SCC kept (cs_w32_movrels64.asm) + ("cs_w32_movrels64", [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0222, 0x5EED0333, 1]), ("cs_w32_new_ops", [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234]), ("cs_w32_misc_ext", [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D]), ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]), diff --git a/runtime/test/shaders/cs_w32_movrels64.asm b/runtime/test/shaders/cs_w32_movrels64.asm new file mode 100644 index 0000000000..017f736df9 --- /dev/null +++ b/runtime/test/shaders/cs_w32_movrels64.asm @@ -0,0 +1,59 @@ +; s_movrels_b64 (#1598, merged with CPU-only checks; #1850's cs_w32_pk_rel_ext covers s_movrels_b32 only): D = the +; SGPR pair at S0 + M0 (RDNA2 ISA SOP1). s20..s27 hold W[k] = 0x5EED0000 + 0x111 * k. Lane 0 stores eight dwords: +; out[0], out[1] = s_movrels_b64 s[10:11], s[20:21] with M0 = 1 (an odd pair): W[1], W[2] = 0x5EED0111 0x5EED0222 +; out[2], out[3] = the same with M0 = 4 set from v_readfirstlane (not foldable): W[4], W[5] = 0x5EED0444 0x5EED0555 +; out[4] = s_movrels_b32 s12, s22 with M0 = 3 from v_readfirstlane: s25 = W[5] = 0x5EED0555 +; out[5], out[6] = s_movrels_b64 s[21:22], s[21:22] with M0 = 1, the destination overlapping the source: +; it reads s[22:23] before writing: W[2], W[3] = 0x5EED0222 0x5EED0333 +; out[7] = SCC set by s_cmp before an s_movrels and read after it (SCC is not written) = 1 +; group: 32,1,1 +; Run: vk_compute_test cs_w32_movrels64.spv 1 dump -> out[0..7] = 1592590609 1592590882 1592591428 1592591701 1592591701 1592590882 1592591155 1 +; mattr: +wavefrontsize32,-wavefrontsize64 +s_mov_b32 s20, 0x5eed0000 +s_mov_b32 s21, 0x5eed0111 +s_mov_b32 s22, 0x5eed0222 +s_mov_b32 s23, 0x5eed0333 +s_mov_b32 s24, 0x5eed0444 +s_mov_b32 s25, 0x5eed0555 +s_mov_b32 s26, 0x5eed0666 +s_mov_b32 s27, 0x5eed0777 +s_mov_b32 m0, 1 +s_movrels_b64 s[10:11], s[20:21] +v_mov_b32_e32 v1, 4 +v_readfirstlane_b32 s5, v1 +s_mov_b32 m0, s5 +s_movrels_b64 s[14:15], s[20:21] +v_mov_b32_e32 v1, 3 +v_readfirstlane_b32 s5, v1 +s_mov_b32 m0, s5 +s_cmp_eq_u32 s5, 3 +s_movrels_b32 s12, s22 +s_cselect_b32 s13, 1, 0 +s_mov_b32 m0, 1 +s_movrels_b64 s[21:22], s[21:22] +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v20, 0 +v_mov_b32_e32 v21, s10 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 4 +v_mov_b32_e32 v21, s11 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 8 +v_mov_b32_e32 v21, s14 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 12 +v_mov_b32_e32 v21, s15 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 16 +v_mov_b32_e32 v21, s12 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 20 +v_mov_b32_e32 v21, s21 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 24 +v_mov_b32_e32 v21, s22 +buffer_store_dword v21, v20, s[0:3], 0 offen +v_mov_b32_e32 v20, 28 +v_mov_b32_e32 v21, s13 +buffer_store_dword v21, v20, s[0:3], 0 offen +s_endpgm diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 94de20f26f..c3f927a219 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -944,7 +944,7 @@ def run_suite(a, work: str) -> int: # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) - elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", + elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_w32_movrels64", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_bound", "cs_dpp_w64", "cs_w64_mask_detect", @@ -971,6 +971,8 @@ def run_suite(a, work: str) -> int: # 64-bit scalar data ops and v_mad_u64_u32 (cs_w32_salu64.asm) # more ops with CPU-only checks until now (cs_w32_misc_ext.asm) # ops merged on 2026-11-22 with CPU-only checks (cs_w32_new_ops.asm) + # s_movrels_b64 pairs, run-time M0, overlap, SCC kept (cs_w32_movrels64.asm) + "cs_w32_movrels64": [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0222, 0x5EED0333, 1], "cs_w32_new_ops": [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234], "cs_w32_misc_ext": [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D], "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE], @@ -1058,7 +1060,7 @@ def run_suite(a, work: str) -> int: "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_lds_subdword", "cs_w32_lds_wide", - "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", + "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", "cs_w32_movrels64", "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial diff --git a/tests/semantic/fixtures/disasm/cs_w32_movrels64.s b/tests/semantic/fixtures/disasm/cs_w32_movrels64.s new file mode 100644 index 0000000000..0c44b5a283 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_movrels64.s @@ -0,0 +1,49 @@ +; cs_w32_movrels64 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_movrels64.asm + s_mov_b32 s20, 0x5eed0000 + s_mov_b32 s21, 0x5eed0111 + s_mov_b32 s22, 0x5eed0222 + s_mov_b32 s23, 0x5eed0333 + s_mov_b32 s24, 0x5eed0444 + s_mov_b32 s25, 0x5eed0555 + s_mov_b32 s26, 0x5eed0666 + s_mov_b32 s27, 0x5eed0777 + s_mov_b32 m0, 1 + s_movrels_b64 s[10:11], s[20:21] + v_mov_b32_e32 v1, 4 + v_readfirstlane_b32 s5, v1 + s_mov_b32 m0, s5 + s_movrels_b64 s[14:15], s[20:21] + v_mov_b32_e32 v1, 3 + v_readfirstlane_b32 s5, v1 + s_mov_b32 m0, s5 + s_cmp_eq_u32 s5, 3 + s_movrels_b32 s12, s22 + s_cselect_b32 s13, 1, 0 + s_mov_b32 m0, 1 + s_movrels_b64 s[21:22], s[21:22] + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v20, 0 + v_mov_b32_e32 v21, s10 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 4 + v_mov_b32_e32 v21, s11 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 8 + v_mov_b32_e32 v21, s14 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 12 + v_mov_b32_e32 v21, s15 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 16 + v_mov_b32_e32 v21, s12 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 20 + v_mov_b32_e32 v21, s21 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 24 + v_mov_b32_e32 v21, s22 + buffer_store_dword v21, v20, s[0:3], 0 offen + v_mov_b32_e32 v20, 28 + v_mov_b32_e32 v21, s13 + buffer_store_dword v21, v20, s[0:3], 0 offen + s_endpgm diff --git a/tests/semantic/regen_fixtures.py b/tests/semantic/regen_fixtures.py index d633f563cd..7e7005e81a 100644 --- a/tests/semantic/regen_fixtures.py +++ b/tests/semantic/regen_fixtures.py @@ -21,7 +21,7 @@ "ps_sdwa_dword_hi", # 16-bit SDWA results with dst_sel:DWORD zero the high half "ps_sdwa", "ps_ops", "ps_ops2", "ps_ops3", "ps_ops4", "ps_ops5", "ps_ops6", "ps_ops7", "ps_ops8", "ps_legacy_mul", "ps_vcc_x2", "ps_vcmpx_forms", "ps_flat", "cs_bounds", "cs_fmt_1010102", "cs_fmt_sint32", "cs_fmt_int_narrow", "cs_fmt_d16_xyz", "cs_w64x_readlane", - "cs_w64x_writelane", "cs_w64x_bpermute", "cs_w32_permute", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w64x_permute", "cs_w64x_ballot", "cs_w64x_readfirstlane", + "cs_w64x_writelane", "cs_w64x_bpermute", "cs_w32_permute", "cs_w32_movrels64", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w64x_permute", "cs_w64x_ballot", "cs_w64x_readfirstlane", "cs_w64x_load_ballot_load", "cs_w64x_partial", "cs_wave64_ballot", "cs_wm_bfm64", "cs_wm_half_cmp", "cs_wavemask", "cs_cvt_f32_sat", "ps_scc_minmax", "ps_fma_literal", "ps_f16_vop2", "ps_outmods_f16", "ps_f32_mods", "ps_f64_mods", "ps_sff_imm", "cs_w32_lds_u8_d16", "cs_w32_lane_wrap", "ps_bary", diff --git a/tests/semantic/test_movrels64_fixture.py b/tests/semantic/test_movrels64_fixture.py new file mode 100644 index 0000000000..3ef9dd5155 --- /dev/null +++ b/tests/semantic/test_movrels64_fixture.py @@ -0,0 +1,79 @@ +"""cs_w32_movrels64: the GPU test of s_movrels_b64 (and s_movrels_b32 at a base register), run here on the CPU too. + +Standard library only; no GPU, no LLVM, no game files. + +runtime/test/shaders/cs_w32_movrels64.asm (derivations in its header) stores eight words from lane 0. This runs its +fixture as one wave32 group through spirv_mini_interp with the buffer vk_compute_test gives it (every byte 0xEE, a V# +with num_records 0xFFFFFFFF), checks the words against a model of the SGPR file (D = SGPR[S0 + M0], the b64 form the +pair, the source read before the destination is written), and that check.py and scripts/run_gpu_tests.py expect the +same words. +""" +import os +import re +import struct +import unittest + +import support +import spirv_mini_interp as si + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(os.path.dirname(HERE)) + +FSSM = bytearray(0x148) +struct.pack_into("<4I", FSSM, 0x138, 0x88, 32, 1, 1) # 4 user SGPRs, wg id in s4, no LDS, 32x1x1 +FSSM = bytes(FSSM) +VSHARP = [0, 0, 0xFFFFFFFF, 0x31016FAC] # vk_compute_test's V#: base 0, num_records max, raw +FILL = 0xEEEEEEEE + + +def model(): + s = {20 + k: 0x5EED0000 + 0x111 * k for k in range(8)} + + def rels(src, m0, n): + return [s[src + m0 + i] for i in range(n)] + + s[10], s[11] = rels(20, 1, 2) + s[14], s[15] = rels(20, 4, 2) + s[12], = rels(22, 3, 1) + scc = 1 # s_cmp_eq_u32 s5, 3 with s5 = 3; s_movrels keeps it + s[21], s[22] = rels(21, 1, 2) # read before the write + return [s[10], s[11], s[14], s[15], s[12], s[21], s[22], scc] + + +EXPECTED = model() + + +class Movrels64Fixture(unittest.TestCase): + def test_reference(self): + self.assertEqual(EXPECTED, [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0222, + 0x5EED0333, 1]) + + def test_translated_shader(self): + spv = support.translate_fixture("cs_w32_movrels64", fssm=FSSM) + mem = {4 * k: FILL for k in range(64)} + si.run_workgroup(spv, 32, 32, inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0), + "%sg_lane": i}, + push_constants=VSHARP + [0] * 28, memory=mem) + for k, want in enumerate(EXPECTED): + with self.subTest(word=k): + self.assertEqual(mem[4 * k], want) + + def test_gpu_runners_expect_the_same_words(self): + for rel in (("runtime", "test", "shaders", "check.py"), ("scripts", "run_gpu_tests.py")): + with open(os.path.join(ROOT, *rel), encoding="utf-8") as f: + text = f.read() + m = re.search(r'"cs_w32_movrels64"\)?[,:]\s*\[([^\]]*)\]', text) + with self.subTest(file="/".join(rel)): + self.assertIsNotNone(m) + self.assertEqual([int(v, 0) for v in m.group(1).split(",")], EXPECTED) + + def test_m0_reaches_the_dynamic_path(self): + # two of the reads take M0 from v_readfirstlane, which the translator can't fold to a constant + with open(os.path.join(ROOT, "runtime", "test", "shaders", "cs_w32_movrels64.asm"), encoding="utf-8") as f: + lines = [ln.strip() for ln in f if ln.strip() and not ln.startswith(";")] + self.assertEqual(sum(ln.startswith("v_readfirstlane_b32 s5") for ln in lines), 2) + self.assertEqual(sum(ln == "s_mov_b32 m0, s5" for ln in lines), 2) + + +if __name__ == "__main__": + unittest.main() From 922b5aac15aeb44092597fcff8e01e5c662f49e4 Mon Sep 17 00:00:00 2001 From: Luiz Neves Date: Sun, 22 Nov 2026 22:19:02 -0300 Subject: [PATCH 2/3] cs_w32_movrels64: an even-aligned overlap pair (LLVM 22+ rejects s[21:22]) llvm-mc 23 rejects the odd-based 64-bit SGPR pair s[21:22] (invalid register alignment), and one fixture it can't assemble stops the whole GPU run (MKmajster's finding, TEST-961). The overlap case is now s_movrels_b64 s[22:23], s[20:21] with M0 = 1: it reads s21, s22, which overlaps the destination s22, so W[1], W[2] only if the source is read first. The fixture test checks that every SGPR range starts at an even register. --- runtime/test/shaders/check.py | 2 +- runtime/test/shaders/cs_w32_movrels64.asm | 13 +++++++------ scripts/run_gpu_tests.py | 2 +- .../semantic/fixtures/disasm/cs_w32_movrels64.s | 6 +++--- tests/semantic/test_movrels64_fixture.py | 17 +++++++++++++---- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 58a7f31c7c..d6d02f130e 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -116,7 +116,7 @@ def not_found_message(build, missing): # more ops with CPU-only checks until now (derivations in cs_w32_misc_ext.asm) # ops merged on 2026-11-22 with CPU-only checks (derivations in cs_w32_new_ops.asm) # s_movrels_b64 pairs, run-time M0, overlap, SCC kept (cs_w32_movrels64.asm) - ("cs_w32_movrels64", [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0222, 0x5EED0333, 1]), + ("cs_w32_movrels64", [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0111, 0x5EED0222, 1]), ("cs_w32_new_ops", [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234]), ("cs_w32_misc_ext", [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D]), ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]), diff --git a/runtime/test/shaders/cs_w32_movrels64.asm b/runtime/test/shaders/cs_w32_movrels64.asm index 017f736df9..4a98301eb3 100644 --- a/runtime/test/shaders/cs_w32_movrels64.asm +++ b/runtime/test/shaders/cs_w32_movrels64.asm @@ -3,11 +3,12 @@ ; out[0], out[1] = s_movrels_b64 s[10:11], s[20:21] with M0 = 1 (an odd pair): W[1], W[2] = 0x5EED0111 0x5EED0222 ; out[2], out[3] = the same with M0 = 4 set from v_readfirstlane (not foldable): W[4], W[5] = 0x5EED0444 0x5EED0555 ; out[4] = s_movrels_b32 s12, s22 with M0 = 3 from v_readfirstlane: s25 = W[5] = 0x5EED0555 -; out[5], out[6] = s_movrels_b64 s[21:22], s[21:22] with M0 = 1, the destination overlapping the source: -; it reads s[22:23] before writing: W[2], W[3] = 0x5EED0222 0x5EED0333 +; out[5], out[6] = s_movrels_b64 s[22:23], s[20:21] with M0 = 1: it reads the pair s21, s22, which overlaps the +; destination s22 (an aligned pair, as LLVM 22+ requires), before writing: W[1], W[2] +; = 0x5EED0111 0x5EED0222 ; out[7] = SCC set by s_cmp before an s_movrels and read after it (SCC is not written) = 1 ; group: 32,1,1 -; Run: vk_compute_test cs_w32_movrels64.spv 1 dump -> out[0..7] = 1592590609 1592590882 1592591428 1592591701 1592591701 1592590882 1592591155 1 +; Run: vk_compute_test cs_w32_movrels64.spv 1 dump -> out[0..7] = 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1 ; mattr: +wavefrontsize32,-wavefrontsize64 s_mov_b32 s20, 0x5eed0000 s_mov_b32 s21, 0x5eed0111 @@ -30,7 +31,7 @@ s_cmp_eq_u32 s5, 3 s_movrels_b32 s12, s22 s_cselect_b32 s13, 1, 0 s_mov_b32 m0, 1 -s_movrels_b64 s[21:22], s[21:22] +s_movrels_b64 s[22:23], s[20:21] v_cmpx_eq_u32_e32 0, v0 v_mov_b32_e32 v20, 0 v_mov_b32_e32 v21, s10 @@ -48,10 +49,10 @@ v_mov_b32_e32 v20, 16 v_mov_b32_e32 v21, s12 buffer_store_dword v21, v20, s[0:3], 0 offen v_mov_b32_e32 v20, 20 -v_mov_b32_e32 v21, s21 +v_mov_b32_e32 v21, s22 buffer_store_dword v21, v20, s[0:3], 0 offen v_mov_b32_e32 v20, 24 -v_mov_b32_e32 v21, s22 +v_mov_b32_e32 v21, s23 buffer_store_dword v21, v20, s[0:3], 0 offen v_mov_b32_e32 v20, 28 v_mov_b32_e32 v21, s13 diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index c3f927a219..eb209bc699 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -972,7 +972,7 @@ def run_suite(a, work: str) -> int: # more ops with CPU-only checks until now (cs_w32_misc_ext.asm) # ops merged on 2026-11-22 with CPU-only checks (cs_w32_new_ops.asm) # s_movrels_b64 pairs, run-time M0, overlap, SCC kept (cs_w32_movrels64.asm) - "cs_w32_movrels64": [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0222, 0x5EED0333, 1], + "cs_w32_movrels64": [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0111, 0x5EED0222, 1], "cs_w32_new_ops": [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234], "cs_w32_misc_ext": [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D], "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE], diff --git a/tests/semantic/fixtures/disasm/cs_w32_movrels64.s b/tests/semantic/fixtures/disasm/cs_w32_movrels64.s index 0c44b5a283..3ace0d52ff 100644 --- a/tests/semantic/fixtures/disasm/cs_w32_movrels64.s +++ b/tests/semantic/fixtures/disasm/cs_w32_movrels64.s @@ -20,7 +20,7 @@ s_movrels_b32 s12, s22 s_cselect_b32 s13, 1, 0 s_mov_b32 m0, 1 - s_movrels_b64 s[21:22], s[21:22] + s_movrels_b64 s[22:23], s[20:21] v_cmpx_eq_u32_e32 0, v0 v_mov_b32_e32 v20, 0 v_mov_b32_e32 v21, s10 @@ -38,10 +38,10 @@ v_mov_b32_e32 v21, s12 buffer_store_dword v21, v20, s[0:3], 0 offen v_mov_b32_e32 v20, 20 - v_mov_b32_e32 v21, s21 + v_mov_b32_e32 v21, s22 buffer_store_dword v21, v20, s[0:3], 0 offen v_mov_b32_e32 v20, 24 - v_mov_b32_e32 v21, s22 + v_mov_b32_e32 v21, s23 buffer_store_dword v21, v20, s[0:3], 0 offen v_mov_b32_e32 v20, 28 v_mov_b32_e32 v21, s13 diff --git a/tests/semantic/test_movrels64_fixture.py b/tests/semantic/test_movrels64_fixture.py index 3ef9dd5155..65b48ac513 100644 --- a/tests/semantic/test_movrels64_fixture.py +++ b/tests/semantic/test_movrels64_fixture.py @@ -36,8 +36,8 @@ def rels(src, m0, n): s[14], s[15] = rels(20, 4, 2) s[12], = rels(22, 3, 1) scc = 1 # s_cmp_eq_u32 s5, 3 with s5 = 3; s_movrels keeps it - s[21], s[22] = rels(21, 1, 2) # read before the write - return [s[10], s[11], s[14], s[15], s[12], s[21], s[22], scc] + s[22], s[23] = rels(20, 1, 2) # reads s21, s22 before writing s22 + return [s[10], s[11], s[14], s[15], s[12], s[22], s[23], scc] EXPECTED = model() @@ -45,8 +45,8 @@ def rels(src, m0, n): class Movrels64Fixture(unittest.TestCase): def test_reference(self): - self.assertEqual(EXPECTED, [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0222, - 0x5EED0333, 1]) + self.assertEqual(EXPECTED, [0x5EED0111, 0x5EED0222, 0x5EED0444, 0x5EED0555, 0x5EED0555, 0x5EED0111, + 0x5EED0222, 1]) def test_translated_shader(self): spv = support.translate_fixture("cs_w32_movrels64", fssm=FSSM) @@ -67,6 +67,15 @@ def test_gpu_runners_expect_the_same_words(self): self.assertIsNotNone(m) self.assertEqual([int(v, 0) for v in m.group(1).split(",")], EXPECTED) + def test_sgpr_pairs_are_even_aligned(self): + # LLVM 22+ rejects a 64-bit SGPR pair with an odd base ("invalid register alignment"), and one fixture + # llvm-mc can't assemble stops the whole GPU run (TEST-961), so no SGPR range here may start at an odd SGPR + with open(os.path.join(ROOT, "runtime", "test", "shaders", "cs_w32_movrels64.asm"), encoding="utf-8") as f: + body = "".join(ln for ln in f if not ln.startswith(";")) + pairs = [(int(a), int(b)) for a, b in re.findall(r"s\[(\d+):(\d+)\]", body)] + self.assertTrue(pairs) + self.assertEqual([p for p in pairs if p[0] % 2], []) # any SGPR range: an even base + def test_m0_reaches_the_dynamic_path(self): # two of the reads take M0 from v_readfirstlane, which the translator can't fold to a constant with open(os.path.join(ROOT, "runtime", "test", "shaders", "cs_w32_movrels64.asm"), encoding="utf-8") as f: From ed47f5f276207be879ce9586c2e39aa7256ac5ff Mon Sep 17 00:00:00 2001 From: Luiz Neves Date: Sun, 22 Nov 2026 22:33:13 -0300 Subject: [PATCH 3/3] test_movrels64_fixture: runs under python -I python -I on the file failed with ModuleNotFoundError: support, as the folder was not on sys.path (found by @justr4mzi on #4323, the same template). It is now inserted, as test_cs_shared_memory_limit does. --- tests/semantic/test_movrels64_fixture.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/semantic/test_movrels64_fixture.py b/tests/semantic/test_movrels64_fixture.py index 65b48ac513..4b3c0539eb 100644 --- a/tests/semantic/test_movrels64_fixture.py +++ b/tests/semantic/test_movrels64_fixture.py @@ -11,12 +11,16 @@ import os import re import struct +import sys import unittest -import support -import spirv_mini_interp as si - HERE = os.path.dirname(os.path.abspath(__file__)) +if HERE not in sys.path: + sys.path.insert(0, HERE) # python -I leaves the script's folder off sys.path + +import support # noqa: E402 (support puts tools/ on sys.path, honouring LEONIDA_TOOLS_DIR) +import spirv_mini_interp as si # noqa: E402 + ROOT = os.path.dirname(os.path.dirname(HERE)) FSSM = bytearray(0x148)