startup: accept compute execz live definitions whose reads are proven #2549
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2557"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T20:52:52Z.
Refs #2274
Builds on #2509 (exec writes proven over every path of a compute
s_cbranch_execzblock) and sits beside #2505(the i1-phi lane mask) and #2535 (the exec-write dataflow speed-up). All three are merged; the branch has main
merged in, so the diff is this change only: two rules, a follow-up that refuses a second write of the narrowed
mask, and a commit that makes the read search cheap and narrows rule 1 to a straight run from the join.
What changes
The compute translator models one lane. A block that
s_cbranch_execzskips is run by the wave whenever any laneis active, while the model skips it for an inactive lane. Until now such a block was refused as soon as a scalar
it defines was live at the join. Two read shapes after the join are now proven instead:
startup: accept execz live definitions whose reads exec absorbs).at the join, in the wave and in the model.
branch targets the join or any instruction up to the read), and that no instruction in that run writes
exec before the read. Then
W & execandexec & W(
s_and) give that lane 0, and~(W & exec)(s_nand) andW | ~exec(s_orn2with exec second) give it1, whatever the block left in W. (
s_nandon a lane mask is still refused later by the lane-mask lowering,so no accept test uses it.)
definition.
v_cmp_* vccinside the block, withs_and_b32 S, vcc_lo, exec_loat the join.startup: accept execz live masks the block only narrows by clear lanes).s_andn2 W, W, X.wave half, and write it to that half's exec word or back to W. Typical shape:
s_andn2_b32 R, R, exec_lointhe block, then
s_mov_b32 exec_lo, Rat the join.Every other read keeps the refusal, and the reason now names the first read that is not proven
(
...: read by s_mov_b32 after the join). Still refused:vcczbranch;re-enters;
s_orn2with exec first, or exec of the other half;m0and SCC, which have implicit readers.The i1-phi rule from #2505 is unchanged. A live word is accepted when that rule holds or when every one of its
reads is proven. Its accepted reads (
v_cndmaskselect, carry-in,s_and_saveexec, ands_andwith exec afterthe exec restore) all come after exec has been restored. With the phi rule stubbed out, none of its eight accept
cases in the compute check is taken by the new rules, so the two do not overlap.
Tests (measured)
Measured at
12b6617d, before main was merged in. At the merged heade131e319the first and third rows were run again and pass. Python 3.13, pure Python, no GPU, no ctest.python -B tests/startup_gfx2hlsl_compute_check.py... execz and sample refusals pass)python -B tests/startup_gfx2hlsl_compute_check.py binary <llvm-mc 15>fixture words match llvm-mcpython -B tests/startup_translator_check.py0 failedtests/startup_gfx2hlsl_*_check.py(66 files)New in
tests/startup_gfx2hlsl_compute_check.py:vccfrom a compare, and the join ANDs it with exec before restoringexec.
vccis all ones before the branch, so lanes 6-7, which skip the block, carry a stalevcc. Expected:lanes
tid.x < 3store one word each and every other word keeps the sentinel. The exact HLSL is asserted.Control
n-unmaskeddrops the& exec.s_andn2_b32 s0, s0, exec_lo, and the join moves s0 into exec. Expected: lanes 3-7 store, and lanes 6-7 skipthe block and keep their bit. The exact HLSL is asserted. Control
o-mask-keptdrops the narrowing.s_andwith exec in both operand orders,s_orn2with exec second, and ans_andthatoverwrites
vccand is followed by avcczbranch. For rule 2, the narrowed restore.exec | ~vcc,exec_hiin a 32-bit op, avcczbranchafter an absorbed read, and a loop that branches back to the join;
andn2write, a second write after the narrowing, a copy and a data read after thejoin, and a block entered from outside.
exec_absorbs,kept_halvesandlane_read, including the 64-bit and cross-half forms.m-else-unswitched. Like M's, their firstmismatch is not pinned.
Translator mutations that turn the check red (run in-process at
fcc249bb, not committed; the only latercommit changes docs only):
s_orn2accepted in either operand order; exec writes after the join ignored; re-entry of thejoin ignored; every read accepted;
kept_halvesignoring the clear facts;lane_readaccepting any destination; the entered-block guarddropped; kept halves joined by union instead of intersection.
All eight fail the check. A sanity mutation that lets
s_orabsorb is caught only by the unit asserts.Cost: on the six largest local compute requests, the time spent in the execz check went from about 0.9 s on
the base to about 1.2 s per request (one machine, single run each). The search is memoized per live word and
stops at the first unproven read.
Rule 1 first proved "exec unchanged since the join" with a per-join dataflow map over every path. That was
the main cost, so
fcc249bbreplaced it with the straight-run check above. The narrower check accepts fewerreads: on the 359 requests below, 2,366 more
v_cmpsites stay refused than with the map (50,324 against47,958). First refusals are the same. The map version also passes every negative control in this PR,
including the loop that re-enters the join, so it was not shown to be wrong; it was dropped for cost and
for a simpler argument.
Effect on local compute requests (measured)
This was measured on the local compute requests whose recorded failure names a
v_cmp*ors_andn2*livedefinition at an execz join: 359 requests, 4 workers. The base is the merged branch before these commits, and
both runs used fresh copies.
First refusal:
operand 'src_scc' in s_mov_bN, on both base and head.s_andn2_bNlive definition (two words)s_cbranch_sccNinside the block: branch out of the blocks_andn2_bNlive definition (one word)s_cbranch_sccNinside the block: branch out of the blocks_lshr_bNlive definitionv_cmp_lt_uN_eNlive definition ofvccv_cmp_lt_fN_eNlive definition ofvccs_bcntN_iN_bNv_cmp_eq_fN_eNlive definitions_load through sN holding ('descnum',)v_cmp_class_fN_eNlive definitioncompute image_store requires dNRefusal sites inside these 359 requests (every execz block, not only the first refusal), at
12b6617d'stranslator, with rule 1 alone and with both rules:
v_cmp*s_andn2_bNMost of what remains is read by something the rules do not cover. Among
v_cmpsites, the most common firstunproven reads are
s_mov_bN(12,972, a copy) and ans_and_bNthat is not absorbed (6,192: exec changedsince the join, a branch target in between, or no exec operand).
No request translates fully because of this change alone. The next refusal for the narrowed-mask shape is the
whole-wave
s_cbranch_scc*exit that follows thes_andn2inside the block.Not checked (hypotheses)
from the ISA semantics; WARP and hardware runs have not observed them.
from the may-writes. This is pre-existing. An absorbed low-word
vccread could now let an uncheckedvcc_hiread through where the low-word refusal used to hide it.
s_andsets SCC. SCC is whole-wave on hardware and per-lane in the model; that is the existingSCC model, unchanged here.
from other forms (for example
s_lshr) when every read is absorbed.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:26:52Z.
Review: COMMENTED
Review of head
31f63dc5(comment only, no merge from this side).Code and fixtures read against main (5 files, +332/-23). The two new rules (absorbed read, narrowed mask) are scoped tightly and the refusal list in the body matches the code (
exec_absorbs,kept_halves,lane_readintools/startup/gfx2hlsl.py).Open item, not fixed in this head: the wave64 case that @R0Y00 asked to be resolved before merging. The body itself lists it under "Not checked": the decoder can print a 32-bit spelling for a wave64 VOPC destination, so a
vcc_hiwrite may be missing from the may-writes, and an absorbed low-halfvccread could let an uncheckedvcc_hiread through. No test or code change in this head covers it. Suggested fix, as @R0Y00 said: either prove the compare's high-half write is tracked, or refuse a high-half consumer when only the low-half rule would let it through. Add a source-built fixture with a high-half read after the join.Startup claim: this touches the startup translator path (#2274). I only reviewed code and fixture tests. Nothing here was run on the game, so any startup result stays with the maintainers. The merge is left to @R0Y00 or MasterDomino.
Commands run locally (Linux, Python, no GPU):
python3 -B tests/startup_gfx2hlsl_compute_check.py: passespython3 -B tests/startup_gfx2hlsl_join_symbols_check.py: passespython3 tests/docs_links_check.py: 19 files, 486 links okpython3 tests/bidi_controls_check.py: okgit diff --check origin/main...HEAD: cleanorinexec_absorbsand drop the exec check: the compute check fails (assertion on the join refusal). Reverted.Not run: Win2025 WARP dispatch of cases N and O (R0Y00 reports those passed on WARP and RTX 4060 for this head).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:22:56Z.
31f63dc5fixes the failing join fixture. The first guard can now prove lane absorption, but the joined descriptor/number is still refused at the numeric use. The fixture pins that refusal instead of the old diagnostic. The seven focused Release CTests passed on WARP and RTX 4060 Laptop, including the N/O dispatches and both mutation controls. Before merging, please resolve the wave64 case noted in the PR: prove the decoded compare's high-half write is tracked, or conservatively refuse a high-half consumer where the relaxed low-half rule would otherwise let it through. A source-built high-half read after the join should distinguish that from the accepted low-half case.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:41:17Z.
Review: COMMENTED
Review of head
4f9974da(comment only, no approval).Result: no blocking findings.
What I checked
execz_live_readand the helpers (exec_absorbs,kept_halves,lane_read,high_half_of_b32): the rule is conservative. A live definition is accepted only when every read after the join is proven, and the first unproven read is named in the refusal text.vcc_hi:scalar_effectsnow addsvcc_hias a may-write for v_cmp, v_add_co, v_sub_co, v_subrev_co and v_div_scale. A 32-bit read ofvcc_hiafter the join is refused and does not count as absorbed by exec (high_half_of_b32). Both are covered by the test around tests/startup_gfx2hlsl_compute_check.py:1507-1512.n-unmaskedando-mask-keptnext to the sibling controls. The refusal and acceptance matrix is checked in the Python test as well.Commands run (Linux)
git diff --check origin/main...HEAD: cleanpython3 -B tests/startup_gfx2hlsl_compute_check.py: passpython3 -B tests/startup_gfx2hlsl_join_symbols_check.py: passpython3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passvcc_himay-write inscalar_effects. The compute check fails.orto the operations accepted byexec_absorbs. The compute check fails.Not run here: Win2025 WARP (a separate run reported dev 21/21 and release 21/21 on this head) and nothing on the game. This is a gfx2hlsl lowering; any claim about startup progress stays with the maintainers.
Small note, not blocking: the join_symbols check does not fail under mutation 1 or 2; the compute check is the one that guards them, which is fine.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:39:56Z.
Pushed
4f9974daon top of31f63dc5(main merged, no force, no rebase). Three commits:CMakeLists.txt(control list) andtools/startup/gfx2hlsl.py(waterfall read pre-pass + the execz live-read search).Nclashed with main's waterfall caseN(the later dict entry silently replaced the first), so this PR's is nowNM.scalar_effectsnow countsvcc_hias a may-write of a compare / carry-out whose decoded text names onlyvcc_lo, andexec_absorbs/lane_readrefuse a 32-bit form that readsvcc_hi(its bit n is lane 32+n, not lane n ofexec_lo). New check intests/startup_gfx2hlsl_compute_check.py:s_and_b32 s23, vcc_hi, exec_loafter the join is refused ("definition of vcc_hi, live where the block joins"), while the low-half read stays accepted. Removing either change makes this check fail.Verification:
python3 -B tests/startup_gfx2hlsl_*_check.pyall pass,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main...HEADclean.--patchof the merged content,--targets offscreen_check,--regex 'startup_gfx2hlsl_(compute|join_symbols).*(_warp|_controls)$'): dev 21/21 and release 21/21 passed on WARP, including the N/NM and O dispatches and all mutation controls. The two python checks passed too.*_hardwaretests (the VM has WARP only).tests/startup_run_ps1_check.pyfails on Win2025 both times I ran it (launcher stub exit 7, unrelated to these files), so I left it out of the python-check list for this run.This touches the startup translator path; I reviewed code and fixtures only, nothing was run on the game. The merge stays with @R0Y00 or MasterDomino.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:48:12Z.
FYI, no overlap: Draft #2723 extends
phi_mask_okfor the compiler's i1-phi blend (s_andn2 M, M, exec_lo+ exec-masked compare +s_or), plus av_cmpinto a zeroed M ands_orn2into an all-ones M, each with a partial-wave readback. It does not touch the two rules in this PR (reads absorbed by exec, and a mask the block only narrows). Expect a small textual conflict inphi_mask_okwhichever lands second.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T04:27:49Z.
Review: APPROVED
The wording and source-built rejection now pin the wave64 high-half case: a compare may write vcc_hi, but ANDing that half with exec_lo cannot prove absorption. The low-half NM and mask-narrowing O cases still pass. I verified both Python checks on this head, then ran the Release offscreen_check CTests with the current main composition: 12/12, no skips, on WARP and RTX 4060 Laptop, including the live-def controls and the existing waterfall broadcast mutation. This resolves my prior review point.