Repository navigation
rdna2spirv: accept vcc (s[106:107]) as 64-bit base pointer in s_load_dword* (SHADER-SLOAD-VCC-BASE) - #647
Conversation
|
Checked
llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted. |
qhukz13
left a comment
There was a problem hiding this comment.
Reviewed on head 70a5945 (Linux, no GPU: CPU interpreter and unit tests only).
Checked:
- The change maps
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. - Pass:
test_sload_vcc_base.py(3),test_scalar_mem_smem.py. - Two hand-written mutations of the new line, run against
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_interp already runs PhysicalStorageBuffer loads (memory={address: word}), so a value check is short. On this head:
s_mov_b32 vcc_hi, 0x0
s_mov_b32 vcc_lo, 0x2000
s_load_dword s10, vcc, 0x4
s_waitcnt lgkmcnt(0)
v_mov_b32 v4, s10
exp mrt0 v4, v4, v4, v4 done vm
s_endpgm
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.
|
Independent check: the patch is correct, but the branch no longer merges cleanly. Applied to a clean worktree at At your own head So only a rebase onto current |
70a5945 to
a4c00f4
Compare
|
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:
|
|
Thanks — confirmed on a4c00f4: |
Claimed 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 rdna2spirv: restrict restore_skipped_instructions to reachable offsets and protect branch targets (OLD-10062) #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.