gfx2hlsl: support cascaded else-if EXEC narrowing and balanced save tracking #3804
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3804
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3802"
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?
@Holastor on GitHub · 2026-12-02 00:18 UTC · original
Holastor:dxil/execz-elseif-cascade→main· +105 −13 · 2 files · 5 commits · merged 2026-12-03 03:30 UTCDepends on #3802
Summary
Extends
Stage.execz_else_branchintools/startup/gfx2hlsl.pyto support cascaded wave-levelelse-ifchains where an inners_cbranch_execznarrowsEXECafter an earlier outerEXECsave (s_mov_b32 sN, exec_lo/s_and_saveexec_b32 sN, ...).EXECnarrowing &else_idxscalar prologue (3e49cba4): resolves the dominating savedsNregister whenguard - 1narrowsEXECin-place, and permits a pure scalar prologue atelse_idxbefores_mov_b32 exec_lo, sN.s_andn2_b32/s_andn2_b64join restores (fb4b212a): acceptss_andn2_b32 exec_lo, sN, exec_lo(and 64-bits_andn2_b64) when switchingEXECfrom thethenarm to the outerelsearm atjoin_idx.EXECsave tracking (94f66241): skips closed inners_and_saveexec/s_mov_b32 exec_lo, sRpairs during backward save lookup so nestedv_cmpx_*/s_and_b32regions resolve the enclosing active save registersN.4c699f59): allows unconditionals_branchfrom< guardinto(else_idx, join_idx)whensNis unread in[target, join_idx)andjoin_idxrestoresEXEC.Verification
python -B tests/startup_gfx2hlsl_compute_check.py(pass; addshlsl_cascade_else,hlsl_andn2_join,hlsl_balanced_save, andhlsl_shared_epiloguepositive tests plus negative controls for clobbered outer save registers and externals_branchintothen)python -B tests/docs_links_check.py(147 Markdown files, 671 links — pass)python -B tests/bidi_controls_check.py(2502 tracked files — pass)4c699f5904to7e49781da0@R0Y00 on GitHub · 2026-12-02 17:44 UTC · original · requested changes
The four nearby Python suites passed on
569b3785. Two source-built variants still pass the widened EXEC proof. In the CMPX variant, inserts_mov_b32 s21, 0; s_branch 1; s_mov_b32 s21, exec_loimmediately beforev_cmpx_lt_u32 v0, 1. The generated HLSL branches around the save and still lowers the laters_cbranch_execzto a per-lane branch using the purported saved mask. In the cascade control, replacing the else-prologues_nop 0withs_mov_b32 s21, 0also translates, and the generated restore becomesexec = (0x00000000u) & 1. Please require the selected save to dominate the guard, and limit the else prologue to scalar operations that leave the saved mask intact. Add both as refusal controls.@Holastor on GitHub · 2026-12-02 20:45 UTC · original
Addressed both review findings in commit
7e49781d:tools/startup/gfx2hlsl.py): Restricted the backward save scan inStage.execz_else_branchto stop at any basic-block entry (k + 1 in into) or branch/terminator (s_branch,s_cbranch*,s_setpc*,s_swappc*,s_movrel*,s_call*,s_endpgm,s_rfe) so a bypassed save beforev_cmpx_*/ narrowing is rejected.else_idxprologue (tools/startup/gfx2hlsl.py): Rejected scalar instructions in theelse_idxprologue beforeEXECrestoration whenevereffects[k][2] & savedis non-empty.tests/startup_gfx2hlsl_compute_check.py): Added both requested controls (bypasseds_mov_b32 s21, 0; s_branch 1; s_mov_b32 s21, exec_lobeforev_cmpx_lt_u32, ands_mov_b32 s21, 0replacings_nop 0in theelse_idxprologue); reverting either guard independently fails its matching control.Verification:
python -B tests/startup_gfx2hlsl_compute_check.py— passpython -B tests/docs_links_check.py,tests/bidi_controls_check.py,tests/startup_triage_run_check.py, andtests/startup_gfx2hlsl_refusals_check.py— passReady for re-review (@R0Y00).
@R0Y00 on GitHub · 2026-12-03 03:30 UTC · original · approved these changes
Re-reviewed
7e49781din a clean trial merge onto7db6f197(git diff --cached --check github/mainpassed). #3802 is in main. This revision addresses both blockers from my review: the backward save scan stops at an intervening block boundary, and the else prologue refuses a write to the saved EXEC mask. I removed each guard independently in the trial tree. Each corresponding source-built control then failed withaccepted, expected a refusal, and both pass with the guards restored.python -B tests/startup_gfx2hlsl_compute_check.pyand the adjacentstartup_gfx2hlsl_{refusals,spill_branches,loop_constants}_check.pysuites passed. With the same trial tree I ran the compute check indispatch <dxc> <offscreen_check> <adapter>andcontrol m-else-unswitched <dxc> <offscreen_check> <adapter>modes. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 each matched 320 words in all 34 dispatch cases and caught the unswitched-else mutant at word 1 (c5c5c5c5vsfedcba98). Windows build 26300, SDK DXC, D3D12 debug layer enabled, no capability skips.