mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 19:48:37 +00:00
Review follow-up on the mask-word gather gate (#1397): `s_mov_b32 s4, exec_lo` under an unknown EXEC narrowing recorded nothing for s4, so the later `s_mov_b32 exec_lo, s4` restore minted a fresh ("n", id) tag in _exec_src_ex. mask_exec_sigs coverage then failed and the read kept this lane's 0 / ~0 bit, while the equivalent literal `s_mov_b32 exec_lo, -1` resolved to a constant half-state and gathered — register and literal restores of the same runtime value disagreed. _mov_sgpr_vals now returns an ("al", halves) alias for an EXEC source whose half-state is an unknown narrowing, the same scheme saveexec uses: exec_lo gives (state, None), exec_hi (None, state), exec gives each half in its own register for b64 moves. _exec_src_ex already resolves those aliases, so the restore reproduces the original tag and the gather stays exact; untracked SGPR sources still mint a fresh narrowing and stay conservative. Tests: two semantic cases (wave32 and wave64) assert the register round-trip gathers OpGroupNonUniformBitwiseOr identically to the literal -1 restore; cs_exec_copy.asm (+ fixture, check.py/run_gpu_tests.py dump entries) stores the mask word, exec_lo's own word and the literal-restore word side by side on real hardware — PASS on RTX 4070 and Radeon (64-wide), wave64 exec filters 9/9 on AMD. Co-Authored-By: Devin <noreply@cognition.ai>
41 lines
2.0 KiB
NASM
41 lines
2.0 KiB
NASM
; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm
|
|
; EXEC restored through an SGPR copy keeps the narrowing's identity (mask-regs EXEC tracking, #1397 review):
|
|
; s7 = 0xffffffff comes from v_readfirstlane_b32, so the translator can't fold it; s_mov_b32 exec_lo, s7 is an
|
|
; EXEC write the analysis can only name as an unknown narrowing. s8 = the odd-lane mask is written under it,
|
|
; s4 = exec_lo / exec_lo = s4 round-trips EXEC through an SGPR unchanged, and the mask-word read must still
|
|
; gather — lanes return the wave's mask word, not this lane's 0 / ~0 bit, exactly as s_mov_b32 exec_lo, -1 gives.
|
|
; Before the fix the copy lost the narrowing's tag, the restore minted a fresh one, mask_exec_sigs coverage
|
|
; failed and every lane stored its own bit (0 or ~0) instead of 0xAAAAAAAA.
|
|
; Per lane (stride 16 bytes): out[0] = s8's mask word after the SGPR round-trip (0xAAAAAAAA),
|
|
; out[1] = exec_lo's word (0xFFFFFFFF: EXEC really is all-ones), out[2] = the same mask word after the
|
|
; literal -1 restore, out[3] = the lane id.
|
|
; Lane 0 stores words 0..3, lane 1 words 4..7 (checked by the dump's first eight words).
|
|
; group: 32,1,1
|
|
; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_exec_copy.spv 1 dump -> out[0..7] = aaaaaaaa ffffffff aaaaaaaa 0 aaaaaaaa ffffffff aaaaaaaa 1
|
|
; mattr: +wavefrontsize32,-wavefrontsize64
|
|
v_mov_b32_e32 v7, -1
|
|
v_readfirstlane_b32 s7, v7
|
|
s_mov_b32 exec_lo, s7
|
|
v_and_b32 v1, 1, v0
|
|
v_cmp_ne_u32_e64 s8, v1, 0
|
|
s_mov_b32 s4, exec_lo
|
|
s_mov_b32 exec_lo, s4
|
|
v_mov_b32_e32 v2, s8
|
|
v_mov_b32_e32 v4, exec_lo
|
|
s_mov_b32 exec_lo, -1
|
|
v_mov_b32_e32 v5, s8
|
|
v_lshlrev_b32_e32 v3, 4, v0
|
|
v_mov_b32_e32 v20, v2
|
|
v_mov_b32_e32 v21, v3
|
|
buffer_store_dword v20, v21, s[0:3], 0 offen
|
|
v_mov_b32_e32 v20, v4
|
|
v_add_nc_u32_e32 v21, 4, v3
|
|
buffer_store_dword v20, v21, s[0:3], 0 offen
|
|
v_mov_b32_e32 v20, v5
|
|
v_add_nc_u32_e32 v21, 8, v3
|
|
buffer_store_dword v20, v21, s[0:3], 0 offen
|
|
v_mov_b32_e32 v20, v0
|
|
v_add_nc_u32_e32 v21, 12, v3
|
|
buffer_store_dword v20, v21, s[0:3], 0 offen
|
|
s_endpgm
|