Skip to content

rdna2spirv: s_movreld_b32, s_movreld_b64 and s_movrelsd_2_b32 (relative SGPR writes), measured on RDNA2 - #2796

Open
Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:feat/s-movreld
Open

Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:feat/s-movreld

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-SALU-MOVRELD, #2516 (comment)

What and why

s_movreld_b32, s_movreld_b64 and s_movrelsd_2_b32 (relative SGPR writes through M0) raised Unsupported; the reads, s_movrels_*, are done. They are the form LLVM uses to write a uniform array element at a run-time index. A probe of several hundred RDNA2 forms through the translator showed these as the ALU forms left that no open PR or claim covers.

  • s_movreld_b32: SGPR[D + M0] = S0 (SGPR, inline constant or literal source); s_movreld_b64: the pair at D + M0, both halves read first; s_movrelsd_2_b32: SGPR[D + M0[25:16]] = SGPR[S0 + M0[9:0]], other M0 bits ignored. SCC and M0 are not written.
  • A dynamic store into the %sgpr array (index wraps to the 128 slots, as s_movrels). Because the target is known only at run time, the translator drops every translate-time belief about SGPR contents (sgpr_imm, descriptor lookups, value tokens). It refuses (Unsupported) when an SGPR holds a lane mask at that point, since the store could land on it. A wave64 graphics shader that uses the ops is tier C (unmodelled-op) in wave64_halves.py.
  • Semantics measured on RDNA2: tools/int_hw_probe.py gets a salu_movreld group (7 cases: M0 = 0, 2, 3, the literal source, the b64 pair, movrelsd_2 with M0[25:16] and M0[9:0], and with the ignored M0 bits set, SCC 0 and 1). On the Radeon (gfx1036, wave32 and wave64) the hardware gives the ISA text's values and --oracle both shows the translator matching on all 7.
  • ps_movreld.asm: a self-checking pixel test (each check is an s_cmp_eq_u32 on a register, one bit per check; the header derives the check counts and the four words by hand), registered in check.py and run_gpu_tests.py and as a semantic fixture, with tests/semantic/test_salu_movreld.py (plain-Python ISA model, the exported SGPRs after each op, an index past 127, the stale-literal case, operand forms that stay refused) and a design.md row.

Tested

  • Hardware: python -I tools/int_hw_probe.py --oracle both --group salu_movreld on AMD Radeon (gfx1036): 7 cases, 7 match, 0 divergence, 0 wave32/64 diff.
  • run_gpu_tests.py --filter ps_movreld: 4096/4096 pixels exact on NVIDIA GeForce RTX 5080 (driver 616.92) and AMD Radeon RDNA2 iGPU (driver 26.10.1); device line confirmed for both. On main the shader does not translate.
  • Negative controls (each reverted): ignoring M0 in the index makes ps_movreld fail on both GPUs (got 0x402e7e79, 0x400c8861, 0x4fffffff, 0x40000006) and five semantic tests; not clearing sgpr_imm fails test_literal_knowledge_is_dropped (v_lshlrev_b32 shifts by the stale 4 instead of 8).
  • python -m unittest discover -s tests/semantic, regen_fixtures.py --check, tests/test_shader_checks.py, pytest tests/test_wave64_halves_fixtures.py tests/test_int_hw_probe.py: OK. tests/test_docs_design_rows.py fails the same way on main (duplicate rows already there).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

AI-assisted.

…ve SGPR writes)

The three raised Unsupported; s_movrels_* was done. They are dynamic stores into
the SGPR array at D + M0 (movrelsd_2: D + M0[25:16], source S0 + M0[9:0]); the
translator forgets its translate-time SGPR knowledge there, refuses when an SGPR
holds a lane mask, and a wave64 graphics shader using them is tier C. Measured
on RDNA2 with int_hw_probe (salu_movreld, 7 cases, translator and GPU agree).
GPU fixture ps_movreld, semantic test and design.md row.

AI-assisted.
@dac0129

dac0129 commented Nov 22, 2026

Copy link
Copy Markdown

Hardware Verification: PASS with a minor test-runner finding.

AI-assisted review. Validated against:

  • CPU: AMD Ryzen 7 7800X3D (8 Cores, 16 Threads)
  • GPU 1: NVIDIA GeForce RTX 4080 (Driver 617.42 / Vulkan 1.4.351)
  • GPU 2: AMD Radeon(TM) Graphics (Raphael RDNA2 iGPU, Driver 26.11.2 / Vulkan 1.4.315)
  • OS: Windows 11 Build 26200

Results:

  1. tools/int_hw_probe.py --group salu_movreld: 7/7 match (0 unexpected mismatch, 0 divergence).
  2. scripts/run_gpu_tests.py --filter ps_movreld:
    • NVIDIA GeForce RTX 4080: PASS (4096/4096 pixels exact)
    • AMD Radeon(TM) Graphics: PASS (4096/4096 pixels exact)

Minor Finding:

python -I tests/semantic/test_salu_movreld.py fails on direct invocation with ModuleNotFoundError: No module named 'support'. Please add the standard tests/semantic directory to sys.path at the top of test_salu_movreld.py as in test_salu_movrels.py so direct standalone execution works alongside unittest discovery.

Zero game data used.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested 3b1d188 on Apple M2 (Mac14,3), macOS 26.4 (25E246), MoltenVK 1.4.2 (direct), subgroup 4..32, llvm-mc 23.1.6, Python 3.13.18: pass.

python -I scripts/run_gpu_tests.py --filter ps_movreld --build runtime/build/linux: 1 shader translated, 1 pass spirv-val; 1/1 passed — ps_movreld 4096/4096 pixels exact.

Build note: the full build fails on AppleClang 17 at vk_pipeline_check.cpp (known from_chars Mac build break reported on the live coordination board); all GPU binaries built, so the run above is valid. Head fetched unchanged into a separate worktree; no rebase/edit/push. Synthetic shaders, counts only; no game files.

AI-assisted.

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rechecked in real wave64 with the hw_oracle fix in #2961: same words.

AI-assisted.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 3b1d188d on CachyOS Linux, Python 3.14. tests/semantic/test_salu_movreld.py, tests/semantic/test_salu_movrels.py: 11 passed, 21 subtests passed.

The two scalar-relative semantic suites passed on Linux, including the distinctions between a selected destination and untouched registers.

AI-assisted, synthetic inputs only.

@crastinator

Copy link
Copy Markdown
Contributor

Tested 3b1d188 merged into main 16282101 (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • New test passes natively: ps_movreld (4096/4096 pixels exact).
  • Whole run_gpu_tests.py: 176/190 native, 176/190 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37.
  • tests/semantic/test_salu_movreld.py, tests/semantic/test_salu_movrels.py: 11 passed, 21 subtests passed.

No game files. AI-assisted (Claude Code).

@bvtterbroot

Copy link
Copy Markdown

Tested 3b1d188 on AMD Radeon RX 7900 XTX (RDNA3, Navi 31; native wave32 and wave64), AMD driver 26.11.2, Vulkan 1.4.359, Windows 11: pass.

  • run_gpu_tests.py: 176/190 passed, 14 skipped; the new ps_movreld passes.
  • python -I -m unittest discover -s tests/semantic -p test_salu_movreld.py: 5 tests OK.
  • python -I -m unittest discover -s tests/semantic -p test_salu_movrels.py: 6 tests OK.
  • python -I tests/semantic/regen_fixtures.py --check: clean.

Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 14.44.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested on the merge with current main on Windows 11 / Python 3.13.0: semantic suite 4147 OK (4142 on main), test_shader_checks 71, test_int_hw_probe 7, regen_fixtures --check clean, merge clean.

The rule is right: the SOP1 forms and index fields match the ISA row and the v_movrelsd_2 precedent (rdna2spirv.py:6081-6128); b64 reads both halves before writing; SCC/M0 are untouched; the writes go into %sgpr (so no uniform-constant aliasing), and sgpr_imm/desc_cache/x_tok are dropped (:6119-6122). Negative control: reverting the 48-line hunk fails all 5 with Unsupported, and disabling only sgpr_imm.clear() fails test_literal_knowledge_is_dropped.

Non-blocking gaps: the desc_cache.clear()/x_tok purge at :6120-6122 is untested; wave64_halves.py:408's tier-C classification has no fixture; the b64 wrap-at-127 and the sd_2 source mask (:6104) are untested, and the row's "index wrapping" reads as destination-only.

Also, the PR text says test_docs_design_rows.py fails on main; it passes on current main (2 OK).

Approve. AI-assisted review, no game files, no GPU.

runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py

AI-assisted.
@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested 3974100 (a re-test at the new head) on AMD Radeon RX 9070 XT (RADV GFX1201, wave32/64) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

No game files. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants