Repository navigation
wave64_halves: an SGPR-pair mask with one half overwritten is mask-half - #4624
paratustra wants to merge 1 commit into
Conversation
lane_masks keeps a 64-bit mask in an SGPR pair as MASK_LO / MASK_HI per register. A 32-bit write to one of them (s_mov_b32 s25, 0 after v_cmp_eq_u32_e64 s[24:25], ...) leaves the pair holding part of a mask, and wave64_halves raised mask-half only for halves of EXEC and VCC. A v_cndmask or saveexec on that pair was tier A, although one 64-lane wave and two 32-lane waves give different words: in wave64 the high register is lanes 32..63, and a 32-wide half has no such word. A source SGPR pair that holds a mask kind in either register, but not MASK_LO and MASK_HI in place, now raises mask-half. The check is on the read, so reusing a mask register as data afterwards stays tier A.
|
Tested What I ran:
Code review:
|
|
Tested
No game files. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 1c194524 on Windows 11: tests/semantic/test_wave64_halves.py -> 74 tests, OK; tests/semantic/test_wave64_halves_soundness.py -> 30 tests, OK; git diff --check clean.
A two-register SGPR source whose halves are both present but not (MASK_LO, MASK_HI) — one half overwritten by s_mov_b32, or the halves swapped — now raises mask-half and tier C. The new cases cover hi, lo, saveexec and the intact pair that must stay tier A. Merge check: git merge-tree with #4619 and with #4620 is clean (exit 0) for both, so this can land in any order with those two.
No blocking issue.
|
Tested 1c19452 merged with main d0835dd on WSL2 Ubuntu (Python 3.12.16) and native Windows 11 (Python 3.13.1): pass.
|
|
Tested head
AI-assisted (Devin). |
Claimed in the coordination issue as: new SHADER item (claim, point 2, in #4571; point 1 was released to SHADER-819)
What and why
lane_maskskeeps a 64-bit lane mask in an SGPR pair asMASK_LO/MASK_HI, one per register. A 32-bit write to one of those registers leaves the pair holding part of a mask:s_mov_b32 s25, 0afterv_cmp_eq_u32_e64 s[24:25], …, or the low register overwritten, or the halves swapped.wave64_halvesraisesmask-halfonly for halves of EXEC and VCC (_half), so av_cndmaskorsaveexecon such a pair came out tier A, although it isn't exact on 32-wide subgroups:On the wave interpreter (
test_wave64_halves.Execution.run_both), lane 40 gives 0 with one 64-lane wave and 7 with two 32-lane waves. In wave64 the high register is lanes 32..63, and a 32-wide half has no such word.Found with a differential search: about 18,000 random synthetic wave64 listings, each run as 64 lanes and as 2×32 lanes, keeping those classified tier A/B whose outputs differ. Then reproduced by hand.
Change (
tools/wave64_halves.py, 10 lines): a source SGPR pair that holds a mask kind in either register, but notMASK_LOandMASK_HIin place, raisesmask-half. The check is on the read, not the write. So a mask register reused as data afterwards (s_mov_b32 s25, 9with no later mask read of the pair) stays tier A, and ordinary register reuse is not refused.Related, not overlapping:
wave64_emulate_opt.py) about mixed mask/constant pairs, which the generator already emits exactly with a cross-half exchange. This PR is about the tier classification of VS/PS/GS that run without emulation. There, the same pair is not exact on 32-wide subgroups, so tier C is right for it.wave64_halvesPRs changes this. With thewave64_halves.pydiffs of SHADER-747: wave64_halves refuses a vote whose run side widens EXEC before the join #4541, wave64_halves: handle slist scalar register lists in _regs and VOP3b operands #4423, wave64_halves: preserve destination taint on partial writes and reject asymmetric DPP row_mask #4373, wave64: scalar side effects in a voted branch refuse tier A (SHADER-742) #4156, wave64_halves: a vote on a wave-uniform compare is not a lane vote (new SHADER item) #4138 and wave64_halves: count v_cmpx as an EXEC write #4585 applied, the listing is still tier A.Tested
macOS, Python 3.15.2, CPU only, synthetic listings, no game files.
New
test_c_half_of_an_sgpr_pair_maskintests/semantic/test_wave64_halves.py: high half cleared, low half set,s_and_saveexec_b64on the clobbered pair (all tier Cmask-half), and an intact pair whose register is then reused as data (tier A). It fails on main and passes here.Interpreter check of the same shapes, one 64-lane wave vs two 32-lane waves:
mask-halfmask-halfmask-halfs_mov_b64copy of the pairtest_wave64_halves.pyOK,test_wave64_halves_soundness.pyOK.Full semantic suite, per test, against main (d0835dd): the same 39 failures/errors on both sides (the known
test_alu_vop3_mods_hw,test_alu_sdwa_hw,test_cmp_class_f64,test_mutations,test_loop_ballot_barrier,test_vcmp16_opselones). Nothing new.The
*_w64_*fixtures: I ran the 23 that this machine can analyse without llvm-mc throughmeta_of, and all get identical tiers on main and on this branch. The other 6 (3 compute, 2 geometry, 1 more) error out the same way on both.Not tested
tests/test_wave64_halves_fixtures.pyitself: it needs pytest, llvm-mc and spirv-tools.Checklist
docs/design.md, with how it was confirmed. (No new rule: this extends the existingmask-halfrefusal from EXEC/VCC halves to SGPR-pair masks.)AI-assisted (Claude Code).