Repository navigation
wave64_halves: count v_cmpx as an EXEC write - #4585
paratustra wants to merge 1 commit into
Conversation
operands() sends every op with a NO_DEST prefix to its first branch,
except s_cmp and s_bitcmp. NO_DEST includes v_cmpx, so the later
`elif op.startswith("v_cmpx"): defs.append("exec")` was unreachable:
EXEC was taken as unchanged and the tainted-exec check never ran.
A wave64 VS that narrowed EXEC with a lane-dependent v_cmpx and then
wrote an output was tier A, although one 64-lane wave and two 32-lane
waves give different words for lanes 32..63. The same shader written
as v_cmp plus s_and_b64 exec was already tier C, tainted-exec.
v_cmpx now leaves the first branch, so it reaches the branch that adds
the EXEC def. A v_cmpx on a wave-uniform value stays tier A.
|
Tested What I ran:
Code review:
|
|
Tested 50241a1 merged with main d0835dd (already up to date) on Linux (WSL2) Python 3.12.16 and native Windows 11 Python 3.13.1: pass.
|
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 50241a19 on Windows 11: tests/semantic/test_wave64_halves.py -> 75 tests, OK; git diff --check clean.
v_cmpx* now falls through to the destination-extracting branch instead of the NO_DEST list, so an EXEC write through a compare is counted as a def (and its operands as uses). The added 10-line case covers it and the 75-case suite passes. No blocking issue.
|
Tested
llvm-mc 20.1.2. No game files. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
VictorJulianiR
left a comment
There was a problem hiding this comment.
v_cmpx_* has no VGPR/SGPR destination but writes EXEC, so excluding it from the NO_DEST early return (like s_cmp/s_bitcmp) lets the EXEC taint be recorded. The tests pin both sides: lane-id compare (e32 and e64) goes to tier C tainted-exec, and a uniform-operand compare stays tier A. Code read only, nothing executed. AI-assisted (Claude).
Claimed in the coordination issue as: new SHADER item (claim in #4421, no ID yet)
What and why
tools/wave64_halves.pyoperands()sends every op that starts with aNO_DESTprefix to its first branch (no destinations, no implicit defs), excepts_cmp/s_bitcmp.NO_DESTincludesv_cmpx, so the later branch,elif op.startswith("v_cmpx"): defs.append("exec"), was unreachable.v_cmpxwas therefore never seen as an EXEC write:exec_write()/new_exec()didn't run, and neither did thetainted-execcheck.So a wave64 VS (or PS/GS) that narrows EXEC with a lane-dependent
v_cmpxcame out tier A, "exact as translated on any subgroup size", when it isn't:On the wave interpreter (
test_wave64_halves.Execution.run_both), one 64-lane wave gives2for lanes 0..31 and0for 32..63. Two 32-lane waves give2everywhere, because the upper half sees lane ids 0..31. The same shader written asv_cmp_gt_u32 vcc, 32, v10pluss_and_b64 exec, exec, vccwas already tier Ctainted-exec.Change:
v_cmpxis excluded from the first branch, so it reaches the existing branch that adds the EXEC def. One word intools/wave64_halves.py.None of the open
wave64_halvesPRs touches this line (#4541, #4423, #4373, #4156, #4138). With #4541's code the listing above is still tier A.Tested
macOS, Python 3.15.2, CPU only, synthetic listings, no game files.
tests/semantic/test_wave64_halves.py:test_c_vcmpx_on_the_lane_id(e32 and e64 forms): tier C,tainted-exec. It fails on main (tier A) and passes here.test_a_vcmpx_on_a_uniform_value: av_cmpxon a scalar stays tier A, so the fix doesn't refuse more than it should. It passes on both.test_wave64_halves.py75 OK,test_wave64_halves_soundness.pyOK.test_alu_vop3_mods_hw,test_alu_sdwa_hw,test_cmp_class_f64,test_mutations,test_loop_ballot_barrier,test_vcmp16_opselones). Nothing new.ps/vs/gs_w64_*fixtures thattests/test_wave64_halves_fixtures.pypins usesv_cmpx, so their expected tiers don't change. The 8 other fixtures withv_cmpxare wave32 and aren't analysed.Not tested
tests/test_wave64_halves_fixtures.pyitself: it needs pytest, llvm-mc and spirv-tools, which this machine doesn't have.v_cmpxmove from tier A to C. That affects the tier counts, any census in the docs, and the--wave64-graphics errorrefusals. I can't measure it without the game. A run of the wave64 census before and after would show how many move.Checklist
docs/design.md, with how it was confirmed. (No new rule: this makes the existing EXEC-write rule apply tov_cmpx.)AI-assisted (Claude Code).