Repository navigation
startup: keep src_scc proven at a branch target one uniform SCC write reaches - #2577
Conversation
Fixes R0Y00#1820. Addresses review feedback on R0Y00#1821: Stage.u() now refuses src_scc unless a modeled SCC writer set scc_verified on the reaching path in the current block. scc_verified starts False at entry, clears at branch targets/joins, non-fallthroughs, SCC_UNMODELLED (such as s_add_u32, cleared after reading its sources), descriptor-elided SCC writes, calculated-PC elision, and s_wqm. Test runs full Stage.translate() over synthetic bytes covering entry refusal, modeled compare/bitwise writers, low16_only=True, the s_add_u32 carry case, input-before-write on s_add_u32, and CFG joins; all 62 pure-Python startup_gfx2hlsl checks and CTest src_scc/sopk_accum/startup_translator pass.
…c-proof # Conflicts: # docs/experiments.md
… reaches A compiler copies SCC into an SGPR on both arms of an if/else (s_cmp_* or s_bitcmp*, s_cbranch_scc0/1, then s_mov_b32 sN, src_scc in each arm). The arm at the branch target was refused as unverified, because every target dropped SCC. In 230 of the 239 locally refused requests, the first refused read has a single reaching SCC write. Each forward branch now carries the offset of the emitted SCC write that reaches it, but only when that write was uniform. A target keeps SCC proven when the fall-through and every edge into it carry the same write and no back edge enters it. Lane-mask SCC, unmodelled and elided writers, different writes on different paths, and loop heads stay refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…scc-proof # Conflicts: # tools/startup/gfx2hlsl.py
tedin7
left a comment
There was a problem hiding this comment.
Review of head 5814ea5 (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
tests/startup_gfx2hlsl_src_scc_check.pyandtests/startup_gfx2hlsl_src_scc_join_check.pypass and are wired in CMakeLists.txt. - Mutation 1:
len(set(defs)) == 1changed tolen(defs) >= 1makes both tests fail (join refusal, execz-skipped block). - Mutation 2: dropping the
off not in back_targetsguard makes the join test fail (back-edge target). - Docs and diff hygiene are clean.
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...HEAD- the two mutations above, each reverted with
git checkout -- .
AI-assisted; commands listed were executed locally.
…scc-proof # Conflicts: # docs/experiments.md
|
Review of head A lane-mask SCC reaches
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 Suggested fix: clear Plus a refusal control with the sequence above. The same per-lane reading of a lane-mask SCC is already accepted on main through AI-assisted. |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Win2025 WARP receipt for head d0682d1 (merge of main after #1821, plus one test). What I added, and why:
Review of the remaining diff (translator change only):
Commands executed locally:
AI-assisted; commands listed were executed locally. |
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 startup: support |x| abs modifier on v_cndmask_b32_e64 operands in gfx2hlsl #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