rdna2spirv: accept vcc (s[106:107]) as 64-bit base pointer in s_load_dword* (SHADER-SLOAD-VCC-BASE) #647
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!647
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/647/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TanmaySatyam on GitHub · 2026-11-24 10:52 UTC · original
TanmaySatyam:feat/sload-vcc-base→main· +175 −1 · 3 files · 1 commits · merged 2026-11-24 15:50 UTCClaimed in the coordination issue as: SHADER-SLOAD-VCC-BASE
AI-assisted.
What and why
In RDNA2 SMEM
s_load_dword*,SBASEencodes a 2-SGPR-aligned 64-bit pointer (sbase * 2). WhenVCCis dead, the compiler allocatessbase = 53(s[106:107]=vcc, i.e.{vcc_lo, vcc_hi}), emitting instructions such ass_load_dwordx4 s[12:15], vcc, 0x0.Gen.scalar_loadintools/rdna2spirv.pypreviously accepted onlysgprandslistbase operands, raisingUnsupported: s_load_dwordx4 operands sgpr vcc(ands_load_dwordx8 operands sgpr vcc,s_load_dwordx4 operands slist vcc) on 79 pipeline-library compute shaders.base["k"] == "special" and base["t"] == "vcc"as["vcc_lo", "vcc_hi"]inGen.scalar_load(load_slotalready loads%vcc/%vcc_hi).s_buffer_load*still requires a 4-dword V# (len(base_slots) != 4) and continues to reject 2-dwordvcc.OLD-10062, which recoversSGPR > 105tuple encodings): together with #596 / high-SGPR tuple decoding, this brings the 2,684-shader pipeline library compute corpus to 2,684 / 2,684 (100.0%) translated andspirv-val-valid under--wave64-emulate.Testing & Verification
python -m unittest discover -s tests/semantic -p test_sload_vcc_base.py -v(3/3 OK, includingspirv-as+spirv-valvalidation)python -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py(44/44 OK)python -I tests/test_text_write_line_endings.py(3/3 OK)--wave64-emulate+spirv-val): all 79 / 79 previously failingvcc-base library compute shaders (72s_load_dwordx4 sgpr, vcc, 6s_load_dwordx8 sgpr, vcc, 1s_load_dwordx4 slist, vcc) now translate and passspirv-val(bringing library CS from 2,605 → 2,684 / 2,684).python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_sload_vcc_base.py docs/design.mdexited 0.@GeorgiyDemo on GitHub · 2026-11-24 11:25 UTC · original
Checked
70a5945con Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmaind42773d07:tests/semantic/test_sload_vcc_base.py: 3 tests OK at this head; againstmain's translator it fails (1 failure, 7 errors), the first beingAssertionError: 's_buffer_load without V#' not found in 's_buffer_load_dword operands sgpr vcc', so the test does exercise the new path.cs_smem_sload_negstill passes (1/1) on MoltenVK 1.4.2 with binaries frommain. I cannot claim that fixture reaches the vcc-as-base path; it is a regression check only.llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.
@qhukz13 on GitHub · 2026-11-24 11:42 UTC · original · reviewed
Reviewed on head 70a5945c1 (Linux, no GPU: CPU interpreter and unit tests only).
Checked:
vccto the slots["vcc_lo", "vcc_hi"], whichload_slotalready reads as%vcc/%vcc_hi. Both base halves are loaded before any destination store, so[s104,s105,vcc_lo,vcc_hi], vccreads the old pointer.s_buffer_loadwithvccis still refused.test_sload_vcc_base.py(3),test_scalar_mem_smem.py.test_sload_vcc_base.py: readingvcc_lofor both halves is caught (6 failures), but swapping the halves (["vcc_hi", "vcc_lo"]) survives. The tests check thatOpLoad %uint %vccand%vcc_hiappear and that the module validates, not which half becomes the low address word.spirv_mini_interpalready runs PhysicalStorageBuffer loads (memory={address: word}), so a value check is short. On this head:with
support.mrt0_words(spv, memory={0x2004: 0xCAFEBABE})gives 0xCAFEBABE; with the halves swapped the load goes to 0x200000000004 instead. A case like that (and one for the aliasing form, where the loaded words land in vcc) would pin the address, not just the opcodes.Looks correct otherwise.
@Poussistar on GitHub · 2026-11-24 13:48 UTC · original
Independent check: the patch is correct, but the branch no longer merges cleanly.
Applied to a clean worktree at
main2d73c242f,git apply --checkfails ondocs/design.md:275(the hunk's context has moved), so the pull request isSTALEas it stands.At your own head
70a5945c(detached worktree, Linux, CPython 3.14.7, synthetic fixtures, no game files):So only a rebase onto current
mainis needed — nothing in the translator change or the new test needs to change. This is a second, independent data point next to the macOS check above.@TanmaySatyam on GitHub · 2026-11-24 14:29 UTC · original
Rebased onto current \main\ (\
d0da7dade, resolving the \docs/design.md\ hunk context drift noted by @Poussistar) and added two \spirv_mini_interp\ value-execution tests per @qhukz13's review:@qhukz13 on GitHub · 2026-11-24 14:54 UTC · original
Thanks — confirmed on
a4c00f4f4:test_sload_vcc_base.pypasses, and the half-swap mutation (["vcc_hi", "vcc_lo"]) that survived before now fails it (2 failures), as does readingvcc_lofor both halves (8). The address is pinned now.