startup: keep src_scc proven at a branch target one uniform SCC write reaches #2569
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2577"
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-25T21:36:32Z.
Depends on #1821. This branch merges it; the review diff starts after that merge.
What changed
#1821 reads
src_sccas(scc ? 1u : 0u)only while a modelled writer has set SCC in the current block. Every branch target drops that proof. In the local request cache,src_scc with unverified SCCis the largest single refusal. In the samples inspected, the first refused read is the compiler copying SCC into an SGPR on both arms of an if/else:Stage.translate()now tracksscc_def, the offset of the emitted SCC write that reaches each instruction, and only when that write was uniform (scc_uniformtrue at the write). Each forward branch records itsscc_deffor its target. A target keeps SCC proven when:Every path into the target then ran that one write last, both for the lane being modelled and for the wave, whichever path each took. That includes a block that
s_cbranch_execzskips for one lane while the wave runs it. So the model's SCC is the hardware value.These stay refused:
set_exec_scc, a mask op onvcc/exec, which is never uniform)SCC_UNMODELLED) and descriptor-elided writers on any pathThe existing whole-program
descriptor_scc_readscheck is unchanged.Census (local cache, 239 requests whose recorded refusal is
src_scc)All counts are from the first refused
src_sccread per request. The reaching writer comes from a backward walk over the control-flow graph, not from program order.s_mov_b32 sN, src_scc238,s_mul_i32 sN, sN, src_scc1.s_bitcmp1_b32 sN, imm169s_bitcmp0_b32 sN, imm17s_cmp_eq_i32 sN, imm17s_cmp_lg_i32 sN, imm16s_cmp_lt_i327s_cmp_lt_u32 sN, sN6s_cmp_eq_u64 sN, sN3s_and_b64 sN, vcc, exec2 (lane mask: stays refused)s_cmp_eq_i32 | s_cmp_lg_i322s_branch(120) or an elideds_bfe_u32of a descriptor word (103). Neither reaches the read.Measured
The translator was origin/main plus #1821, 4 workers, fxc compile on. The cached requests were keyed under translation revision 14, so the measuring harness, not this branch, recomputed the compute and RTV keys with that revision.
src_scc. The other 154 stop earlier on refusals in main: 137 onNEG on an integer or literal source, 7 ons_bfm_b64, 4 ons_load with a register offset through ('resheap',), 4 onv_readfirstlane_b32 requires a proven uniform source, and 2 onSDWA form of v_cndmask_b32.... inside a block s_cbranch_execz skips per lane: definition of X, live where the block joinsrefusals (s_buffer_load_dwordx2, s_mov_b64, s_and_saveexec_b64, s_cselect_b64, s_load_dwordx4, v_cmp_lt_f32_e64)src_scc, all compute requests. Each has at least one reachings_cmp_*whose SGPR source the model does not prove uniform. In 7, a different write reaches on another path; in 3, the path crosses a loop head.Requests that still have a
src_sccrefusal site somewhere, collecting every refusal (keep-going mode; these counts are noisier than first refusals):s_cmp_*whose SGPR source the model does not prove uniforms_cmp_eq_i32 sN, imm(300),s_bitcmp1_b32 sN, imm(3) ands_and_b32 sN, sN, src_scc(1).SDWA form of v_cndmask_b32, both before and after, even with #2449's head merged locally.Hypothesis, not measured
Tests
Run with
out/pe-env/Scripts/python.exe -B. Each line gives the last line the check printed:ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_src_scc(_join)?$' -Vwas not run: no CMake configure here. The new test is registered next to #1821's.The new check builds its words from the decoder's field layout.
s_cbranch_execzsrc_scc with unverified SCC:s_and_b32withvcc_lobefore the branch (the same program withs5is accepted)s_add_u32on one pathsrc_scc with unverified SCC.#1821's join case used a skipped
s_nop, which is now accepted. It now skips an SCC write, so it still pins the join refusal. Its old input is positive case 2 in the new check.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:41:36Z.
Review: COMMENTED
Review of head
5814ea5e(comment only, no merge from me).Not merge-ready yet: the PR says it depends on #1821, and #1821 is still open. It should land first.
What I checked:
tools/startup/gfx2hlsl.py: SCC proof at a branch target is kept only when the fall-through and every forward edge carry the same uniform emitted write, and no back edge enters. That matches the PR text. Lane-mask, unmodelled and descriptor-elided writers still refuse.tests/startup_gfx2hlsl_src_scc_check.pyandtests/startup_gfx2hlsl_src_scc_join_check.pypass and are wired in CMakeLists.txt.len(set(defs)) == 1changed tolen(defs) >= 1makes both tests fail (join refusal, execz-skipped block).off not in back_targetsguard makes the join test fail (back-edge target).Scope note: these are fixture and code checks only. The census and request counts in the body come from the author's local cache and I did not reproduce them. Any claim about startup progress has to be verified on the real title by whoever merges.
Commands run:
python3 tests/startup_gfx2hlsl_src_scc_check.pypython3 tests/startup_gfx2hlsl_src_scc_join_check.pypython3 tests/docs_links_check.pypython3 tests/bidi_controls_check.pygit diff --check origin/main...HEADgit checkout -- .AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T22:33:24Z.
Review of head
58ad96d2, by reading the diff against mainfc97ade(not run).A lane-mask SCC reaches
src_sccin the same block (compute or pixel stage):s_and_b32takes theis_maskpath (maingfx2hlsl.py:3338and:3375), sos6is the lane's own bit andset_s(..., scc='$ != 0')callsset_scc('s6 != 0'). With this PRset_sccsetsscc_verified = Trueunconditionally, whilescc_uniformbecomes False because of thevcctoken.u('src_scc')checks onlyscc_verified, so the read is accepted and emitss6 = (vcc & ...) & 1; scc = s6 != 0; s10 = (scc ? 1u : 0u);. Lane 0 getss10 = 0, while the guest writes 1.The docs paragraph says lane-mask writers stay refused. The join test covers that across a branch, but nothing covers a lane-mask writer followed by
src_sccin the same block.Suggested fix: clear
scc_verifiedonly where a lane-mask writer sets SCC, not inset_sccas a whole. That means theis_maskpath afterset_s, the path with anexec/vccdestination, them0destination path when a source is a lane mask (s_and_b32 m0, vcc_lo, -1), andset_exec_scc.set_sdiscards the destination frommasksbefore it callsset_scc, so the test cannot live insideset_scc. Makingset_sccsetscc_verified = scc_uniforminstead would also refusejoin_rewritteninstartup_gfx2hlsl_src_scc_check.py: after the joinsince_joinis empty, sos4is not proven uniform there.Plus a refusal control with the sequence above.
The same per-lane reading of a lane-mask SCC is already accepted on main through
s_cselect_b32 s10, 1, 0(scalar_select,gfx2hlsl.py:3557). That is outside this PR.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:50:04Z.
Review: COMMENTED
Reviewed head
d0682d17(translator diff after #1821, plus the WARP readback test). No blocking findings; details and commands are in the receipt comment above.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:49:54Z.
Win2025 WARP receipt for head
d0682d17(merge of main after #1821, plus one test).What I added, and why:
origin/main(#1821 is in main now). Conflicts inCMakeLists.txt,tools/startup/gfx2hlsl.pyandtests/startup_gfx2hlsl_src_scc_check.pyresolved keeping both sides: thescc_deftracking on top of main's address-carrys_add_u32branch, and the join case insrc_scc_checkthat now skips an SCC write.dispatchmode totests/startup_gfx2hlsl_src_scc_join_check.py(the same pattern asstartup_gfx2hlsl_pack_absdiff_dispatch_*): the translated if/else and skipped-block programs are compiled with DXC and run on D3D12 (WARP and hardware tests:startup_gfx2hlsl_src_scc_join_dispatch_warp/_hardware). The UAV readback is compared with a CPU reference (bit 3 of s4 on both arms;s4 == s5at the join) over 6 value pairs.Review of the remaining diff (translator change only):
len(set(defs)) == 1->>= 1, and dropping theoff not in back_targetsguard.git diff --checkis clean.Commands executed locally:
python3 -B tests/startup_gfx2hlsl_src_scc_check.py,..._src_scc_join_check.py,tests/startup_translator_check.py: pass.x2w_pipe.py win2025 2577 --patch <diff to d0682d17> --regex 'startup_gfx2hlsl_src_scc|startup_translator|startup_gfx2hlsl_compute|startup_gfx2hlsl_s_bitcmp|startup_gfx2hlsl_calculated|startup_gfx2hlsl_join' --keep-release:ctest --preset dev: 43/43 passed.ctest --preset release: 43/43 passed.startup_gfx2hlsl_src_scc_join_dispatch_warpand_hardware.AI-assisted; commands listed were executed locally.