Skip to content

Translator: v_movrelsd_2_b32 with separate M0 source/destination fields - #541

Merged
ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
esteban-dcp:translator-movrelsd-2
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
esteban-dcp:translator-movrelsd-2

Conversation

@esteban-dcp

Copy link
Copy Markdown

New SHADER item (claimed in #374), follow-up to #496, which notes that v_movrelsd_2_b32 is not handled by the translator yet.

What

v_movrelsd_2_b32 (VOP1 opcode 72): VGPR[D + M0[25:16]] = VGPR[S0 + M0[9:0]]. Unlike v_movrelsd_b32, each side has its own 10-bit M0 field and the other M0 bits are ignored. Source: the RDNA2 ISA opcode description (§12.8) and the RDNA3 ISA, which give the same fields. The RDNA2 §6.6 summary table prints M0[7:0] for the source; no test relies on a source offset above 255, so they hold either way.

  • tools/rdna2spirv.py: the existing movrel path masks M0 per side for this opcode (it raised Unsupported before).
  • tests/semantic/test_alu_movrelsd_2.py: 7 hand-computed cases through the translator and the mini interpreter: M0 = 0, source-only, destination-only, different offsets, v0 as the source, ignored M0 bits set (0xFC00FC00), and the ISA's example. Also the _e32 spelling and a check that the result differs from v_movrelsd_b32. Without the translator change these fail (Unsupported).
  • runtime/test/shaders/cs_movrelsd_2.asm: wave32 dump test with the ISA's example (v25 ← v17, M0 = (20 << 16) | 10) and a set-ignored-bits case; v15 would be written by a translator that used M0[9:0] on both sides. Registered in check.py and run_gpu_tests.py like cs_w32_lane_wrap.
  • docs/design.md: contract row for the v_movrel* forms, including what is not modelled (the hardware range check: out-of-range source reads VGPR0, out-of-range write is dropped; same as the other movrel forms today).

When #496 lands, its docstring line saying v_movrelsd_2_b32 raises Unsupported will be stale; it has no assertion on it, so nothing breaks.

Tested

Linux 7.3.5 (CachyOS), python -I scripts/run_gpu_tests.py --build runtime/build/linux, each GPU pinned with VK_LOADER_DRIVERS_SELECT (device line checked), VK_LOADER_LAYERS_DISABLE=~implicit~, on 91b36cf + this commit:

  • NVIDIA RTX 4050 Laptop (Ada), driver 620.73.04, subgroup 32: 75 translated, 75 pass spirv-val; 46/72 passed, 26 wave64 skipped; with LEONIDA_W64_EMULATE=1: 72/72
  • AMD Radeon 740M (RDNA3, RADV, Mesa 26.3.1), subgroup 32..64: 72/72
  • cs_movrelsd_2: 11 33 33 55 1717 77 1515 1717 on all three runs
  • CPU: unittest discover -s tests/semantic OK; pytest tests --ignore=tests/semantic and the plain tests/test_*.py: the only failures (test_make_game_dry_run, 2 in test_swizzle_search) fail identically on main on Linux

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

🤖 Generated with Claude Code

VGPR[D + M0[25:16]] = VGPR[S0 + M0[9:0]] (RDNA2 ISA VOP1 opcode 72; same
fields in the RDNA3 ISA). It raised Unsupported before (noted in ProjectLeonida#496).

- tools/rdna2spirv.py: masks M0 per side on the existing movrel path.
- tests/semantic/test_alu_movrelsd_2.py: 7 hand-computed cases through the
  translator and the interpreter, including ignored M0 bits set, the _e32
  spelling and a check that it differs from v_movrelsd_b32.
- runtime/test/shaders/cs_movrelsd_2.asm: GPU test (wave32 dump) with the
  ISA's own example; registered in check.py and run_gpu_tests.py.
- docs/design.md: contract row for the v_movrel* forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 00:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@ItsNotRexed
ItsNotRexed merged commit b3c2623 into ProjectLeonida:main Nov 22, 2026
@kacper-serewis

Copy link
Copy Markdown
Contributor

Tested 737735a on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200: pass.

Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 19.50, Python 3.13.

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.

4 participants