Skip to content

rdna2spirv: a scalar instruction cannot name a VGPR (62 of 143 SALU ops took v8 as destination) - #9408

Closed
Vonsek wants to merge 3 commits into
ProjectLeonida:mainfrom
Vonsek:vonsek2/salu-dst-sgpr-check
Closed

Vonsek wants to merge 3 commits into
ProjectLeonida:mainfrom
Vonsek:vonsek2/salu-dst-sgpr-check

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

EGEN-SALU-DST-CHECK (Vonsek2), claim. Scalar twin of #9190 (independent: neither needs the other).

What and why

The scalar ALU and the scalar memory unit read and write SGPRs, constants and special registers only. No SOP1, SOP2, SOPK, SOPC, SOPP or SMEM operand is a VGPR, so s_add_u32 v8, s1, s2 and s_mov_b32 s8, v1 cannot be encoded. Gen._insn accepted a VGPR destination on 62 of the 143 SOP1/SOP2/SOPK ops in rdna2_isa_tables and wrote the result into the vector register file. It now raises Unsupported for any s_* instruction with a VGPR operand, in one place at the top of _insn. The check sits after the no-op handling, so s_waitcnt vmcnt(0) (a counter, not a register) is unaffected.

Commits

  1. The check (5 lines).
  2. tests/semantic/test_salu_no_vgpr.py.
  3. A docs/design.md contract row, since a new translator rule needs one, with the corpus count.

Test

python -I -m unittest discover -s tests/semantic -p test_salu_no_vgpr.py (4 tests, 0.05 s):

  • on main 867d922: 7 failures (the destination and source sweeps list the ops that were not refused; the pair/SMEM/branch lines are accepted);
  • on this branch: OK. It gives every SOP1/SOP2/SOPK/SOPC op op v8, s1, s2 and op s8, v1, s2 / op s8, s1, v2 to a fresh Gen, requires Unsupported mentioning VGPR, and checks that SGPR forms (s_mov_b32 s8, s1, s_mov_b64 s[8:9], s[2:3], a literal operand) still translate.

Whole tests/semantic through scripts/run_semantic_tests.py: the only failures are test_image_atomics_guard and test_image_store_d16, which fail on unmodified main too (stale after #4473 and #6805; #7284, #7608 and #7916 fix them).

Corpus, my own 1.0.2.1 copy, counts only: none of the 13,547,471 scalar instructions in the 26,503 listings names a VGPR in any operand, and --shard 11/64 (414 listings) translates and passes spirv-val 414 of 414.

python -I tests/test_docs_repo_paths.py: OK. tests/test_docs_design_rows.py fails on main already (repeated rows in docs/README.md), not on the new row. No GPU needed.

Notes

  • The ISA table also lists SDST as first operand for the SOPK compares (s_cmpk_*); they are covered by the same rule.
  • An immediate as a destination is not refused here: that needs the table's SDST knowledge per op and is a separate change.

AI-assisted.

@GonZiin

GonZiin commented Nov 23, 2026

Copy link
Copy Markdown

Tested 47a9eb8 on Linux x86_64 (WSL2), Python 3.14, no GPU: pass. Ran test_salu_no_vgpr (4 OK; 7 failures on main's rdna2spirv.py), the full semantic suite (448 files, 5961 tests; only the two known failures test_image_atomics_guard and test_image_store_d16), test_docs_repo_paths, compileall and check_no_game_data. Not checked: the 26,503-listing corpus count, spirv-val, GPU. AI-assisted (Claude Code).

@ddaikodaiko

Copy link
Copy Markdown

Windows check of 47a9eb8: Windows 10 Pro 10.0.19045, Python 3.14.3, LLVM_MC = llvm-mc 21.1.8 (AMDGPU), no game files.

python tests\semantic\test_salu_no_vgpr.py   -> Ran 4 tests ... OK

The file import support from tests/semantic, so it needs to be run without -I (or through unittest discover -s tests\semantic); with python -I the import fails before any test runs, which is a property of the invocation, not of this PR.

I did not run the rest of tests/semantic.

@RAINighty

Copy link
Copy Markdown

Tested 47a9eb8f4 merged with main 5d74c2723 (clean merge) on Windows 11 (10.0.26300), Python 3.13.15 in UTF-8 mode (PYTHONUTF8=1; venv with the pinned tests/requirements.txt), with llvm-mc 21.1.8 (AMDGPU) and SPIRV-Tools v2026.4 on PATH: pass.

  • python -I -m unittest discover -s tests/semantic -p test_salu_no_vgpr.py: the file is new, so main runs no tests (NO TESTS RAN); with this PR 4 tests OK.
  • Negative control: this PR's test with main's tools/rdna2spirv.py: FAILED (failures=7), so the new test does catch the problem.
  • Note: run directly as python -I tests/semantic/test_salu_no_vgpr.py the file stops at import support, as the other semantic files do; it has to go through unittest discover -s tests/semantic.
  • Code not reviewed beyond running it. No GPU or game files.

AI-assisted (Claude Code).

@pablo-biasco-411953

Copy link
Copy Markdown

checked: #940847a9eb8 | with: PR diff applied on main 5d74c27, python -m pytest -q tests/semantic/test_salu_no_vgpr.py | on: Windows 11, CPython 3.11.9, pytest 9.2.0, CPU only, no game files | result: pass, 4 passed, 10 subtests passed; no new failures against the same tests on main | agent: yes

@SpaghettiMaster545

Copy link
Copy Markdown

Tested 47a9eb8f4 merged onto main 5d74c2723 (clean merge) on Windows 11 IoT Enterprise LTSC 2024 (26100), Python 3.14.2, llvm-mc 23.1.6, Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 5070 Ti (621.24). Test programs come from main's runtime build; this PR doesn't touch runtime/. Synthetic tests only, no game files.

  • test_salu_no_vgpr.py: 4 OK. Against main's rdna2spirv.py: 7 failures, as described.
  • scripts/run_semantic_tests.py tests/semantic: main 447 files / 5957 tests, this branch 448 / 5961. Both fail only test_image_atomics_guard and test_image_store_d16.
  • scripts/run_gpu_tests.py on the 5070 Ti, two runs each: on both trees, 247 translated, 247 spirv-val and 192/241 passed (48 skipped), with only the known ms_wave_info_s3 failing. All 247 .spv files are byte-identical between main and this branch, so no fixture uses the refused form.

Pass. AI-assisted (Claude Code).

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.

7 participants