shader: carry pre-branch EXEC mask subset facts into compute execz blocks (#2645 T1) #2869
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2877"
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 stan495 on 2026-11-26T15:57:20Z.
Summary
'exec', 0), ('exec_hi', 1), while keeping \EXEC_SUBSET\ as the per-step \exec write\ check invariant so overwritten saved masks cannot be re-injected inside the skipped block.Test environment & results (commit \
33b4e3d0)Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T16:21:00Z.
Independent T1 check at
33b4e3d07b980a9c339a0a0cb56359c40abb07de. The pure-Pythonstartup_gfx2hlsl_compute_check.pycontrols passed, including the original loop-break fixture that still reports the T2 boundary. I ranO-loop-subsetdirectly throughrun_case()with MSVC Releaseoffscreen_check(the--compute-store-casepath is unchanged) and SDK DXC1.9.2602.17on Windows26300.10075. All 320 words matched on in-box WARP10.0.26100.10068and physical RTX 407032.0.16.2124, with zero debug errors or warnings and no skips. The registeredo-subset-remask-droppedmutation differed at exactly three words on both adapters, beginning withword=0 expected=00000009 actual=00000001.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T20:59:49Z.
Review: COMMENTED
Complex and correct. This PR introduces subset-after tracking (#2645 T1) to prove that scalar words assigned from EXEC before an s_cbranch_execz carry a subset guarantee (sM <= EXEC), which prevents the translator from refusing exec writes inside the skipped block when the assignment is provably safe.
A few observations:
subset_after() handles four categories cleanly:
The fixed-point iteration in execz_refusals() (pre_sub propagation) correctly merges joins via intersection, which is the right lattice operation for subset tracking.
The test harness is comprehensive: subset_after() unit checks, accepted setups (pre_and_copy, pre_mov), near-miss controls (narrowed_saveexec, narrowed_cmpx, overwritten_before/inside, join_one_arm), and the binary o-subset-remask-dropped test. The bad_wave vs bad_singles disagreement check (lane 1 skips in singleton but enters via stale mask in wave) is an excellent mutation test.
One potential concern: the fixed-point loop runs in place over pre_sub without an explicit termination condition beyond changed=False. For very large basic blocks this could be slow, though the fact lattice is small (EXEC_SUBSET + at most ~4 scalar words), so it terminates quickly in practice. Worth noting in a comment for future readers.
Looks solid. This is a quality addition to the translator safety guarantees.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T19:54:49Z.
Review: COMMENTED
I tried to review
33b4e3d0over currentmain454fc0ed. The trial merge conflicts indocs/experiments.md. Since this PR's baseb505c32b,mainhas added entries there in #3010, #2882, #2871, #2829 and #2857. The other three files merge cleanly.I'll review it once it is updated with
main.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T02:30:46Z.
I merged
main50e4f763into this branch asf4bf0949. The push fast-forwards from33b4e3d0; there was no rebase and no force-push.Conflict and resolution.
docs/experiments.md. This branch adds itssubset_afterparagraph to the end of the section before "Startup compute formatted buffer reads".maininserts the new "Scalar run before the EXEC restore at a compute exit target (#2645 T3)" section in the same place. I kept both: this branch's paragraph stays at the end of its section, andmain's section follows it.tools/startup/gfx2hlsl.pyandtests/startup_gfx2hlsl_compute_check.pymerged without conflicts. Both sides change execz handling in compute stages (T1 here, T3 onmain), so I ran the wholestartup_gfx2hlsl_*set.git diff --check origin/main...HEADis clean.What I ran. I built everything in
devandrelease(/O2), then ran_hardware117/117 pass._hardware117/117 pass.These runs include this branch's
startup_gfx2hlsl_compute_o-subset-remask-dropped_{warp,hardware}andstartup_gfx2hlsl_compute_controls.This needs a re-review from someone else. I won't review or merge it myself.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10.
This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T04:16:30Z.
Review: APPROVED
Reviewed
f4bf0949(c's merge ofmain) integrated over currentmainf41806a9. The merge is clean (tree371d047d) andgit diff --cached --checkis clean.What I traced.
subset_afteris a forward must-analysis ofsM <= EXECfacts. It is seeded by as_movof EXEC into an SGPR pair and kept across as_mov/s_or/s_or_saveexecinto EXEC only when the OR keeps an EXEC source word. It is dropped on any other EXEC write, on a write to the fact's word, ons_movrel*, and at a join that lacks it on any edge.execz_refusalsseeds the skipped block's entry with those facts, while the per-instructionexec writecheck still compares againstEXEC_SUBSETalone. So a saved mask that is overwritten inside the skipped block can't be restored as a subset. c'sdocs/experiments.mdresolution keeps both sides, andmain's T3 work doesn't touchentry.What I ran.
devandrelease/O2.ctest --test-dir out/build/<preset> --no-tests=error -j 8 -R '^startup_gfx2hlsl_' -E '_hardware$': 270/270 pass in Debug and in Release.ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^startup_gfx2hlsl_compute.*_hardware$': 34/34 pass, with no skips. On the earlier trial over0fe4cebcthe same 34 also passed inrelease.ctest --test-dir out/build/dev --no-tests=error -j 8 -E '(startup_audio|_hardware$)'gives 2016 tests: 1956 pass, 1 fails and 59 are capability skips.xmem_lazy_commit_off, which passes 5 of 5 runs alone at-j 1.0fe4cebc, the one full-run failure wasstartup_storage_alloc_failure. Alone at-j 1it failed 1 of 13 runs.CMakeLists.txtand the docs, so I read both as unrelated intermittent failures.s_mov_b64 s[22:23], execbefore the branch ands_mov_b64 exec, s[22:23]inside the skipped block. The baseline is accepted, and so is ans_or_b32 exec_lo, exec_lo, s30widening before the branch.Mutants of
tools/startup/gfx2hlsl.py, each run againsttests/startup_gfx2hlsl_compute_check.pyafter an unmutated baseline that passes:EXEC_SUBSET)O-loop-subsetrefused)s_movrel*keeps all factss_movinto EXEC adds no source facto-subset-remask-dropped)exec writecheck uses the entry factsRestored afterwards;
git diff --quietis clean.Non-blocking.
any(...)test replaced byTrue,s_or_b32 exec_lo, s1, s2would keep everysM <= EXECfact, though the new EXEC needn't contain the old one. The code drops the facts correctly today; a near-miss control with that instruction before the branch, which must refuse, would pin it.src[p] == ('exec', 'exec_hi')[p]tests source wordpagainst EXEC halfp, not against the destination half. Fors_or_b32 exec_hi, exec_lo, s30, word 0 isexec_lo, so it counts as a widening and the(s23, 1)fact is kept, butexec_hi = exec_lo | s30needn't contain the oldexec_hi. I checked this by callingsubset_afterdirectly. It isn't reachable end to end today: the translator refusess_or_b32with destinationexec_hi(operand 'exec_hi'). Comparing each source word with the destination word would close it before that destination is ever accepted (unconfirmed suggestion).Verdict: approve on
f4bf0949.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass onf4bf0949.This reply was AI-assisted.