gfx2hlsl: allow structured wave-level if/else branches inside s_cbranch_execz blocks #3800

Manually merged
github merged 3 commits from github-bot/gh-3798 into main 2026-12-02 02:20:34 +00:00 AGit
Owner

@⁠Holastor on GitHub · 2026-12-01 23:18 UTC · original
Holastor:dxil/per-lane-execz-else-branch → main · +106 −1 · 2 files · 3 commits · merged 2026-12-02 02:15 UTC

Summary

Adds Stage.execz_else_branch in tools/startup/gfx2hlsl.py to accept structured wave-level if / else control flow inside s_cbranch_execz blocks instead of rejecting the trailing s_branch L_join at the end of the then arm with "branch out of the block".

Supported structured shapes (with guard preceded by s_and_saveexec_b32 sN, ... / s_and_saveexec_b64, s_branch L_join at else_idx - 1 with L_join > L_else, no external entries into the then arm (guard, L_else), no exits out of [L_else, L_join], and no clobber of sN in then other than s_andn2_b32/b64 sN, sN, exec):

  • Standard EXEC restore at L_else: s_mov_b32 exec_lo, sN (or s_mov_b64 exec, ...) at L_else.
  • Scalar else with EXEC restore at L_join: pure scalar instructions in [L_else, L_join) without EXEC writes or branches, followed by s_mov_b32 exec_lo, sN at L_join.
  • External scalar entry into else (76130159): s_cbranch_scc0 / s_cbranch_scc1 from < guard jumping into (L_else, L_join), provided sN is not read in [target, L_join) and L_join restores/overwrites EXEC (effects[join_idx][2] & EXEC_KEYS).

Verification

  • python -B tests/startup_gfx2hlsl_compute_check.py (pass; retains the negative control for unstructured branch out of the block, adds positive tests for EXEC-restoring else, scalar else, and hlsl_ext_else, plus negative controls for clobbered save registers and external jumps into then)
  • python -B tests/docs_links_check.py (147 Markdown files, 671 links — pass)
  • python -B tests/bidi_controls_check.py (2502 tracked files — pass)
**@⁠Holastor** on GitHub · 2026-12-01 23:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3798) `Holastor:dxil/per-lane-execz-else-branch` → `main` · +106 −1 · 2 files · 3 commits · merged 2026-12-02 02:15 UTC ## Summary Adds `Stage.execz_else_branch` in `tools/startup/gfx2hlsl.py` to accept structured wave-level `if / else` control flow inside `s_cbranch_execz` blocks instead of rejecting the trailing `s_branch L_join` at the end of the `then` arm with `"branch out of the block"`. Supported structured shapes (with `guard` preceded by `s_and_saveexec_b32 sN, ...` / `s_and_saveexec_b64`, `s_branch L_join` at `else_idx - 1` with `L_join > L_else`, no external entries into the `then` arm `(guard, L_else)`, no exits out of `[L_else, L_join]`, and no clobber of `sN` in `then` other than `s_andn2_b32/b64 sN, sN, exec`): - **Standard `EXEC` restore at `L_else`:** `s_mov_b32 exec_lo, sN` (or `s_mov_b64 exec, ...`) at `L_else`. - **Scalar `else` with `EXEC` restore at `L_join`:** pure scalar instructions in `[L_else, L_join)` without `EXEC` writes or branches, followed by `s_mov_b32 exec_lo, sN` at `L_join`. - **External scalar entry into `else` (`76130159`):** `s_cbranch_scc0` / `s_cbranch_scc1` from `< guard` jumping into `(L_else, L_join)`, provided `sN` is not read in `[target, L_join)` and `L_join` restores/overwrites `EXEC` (`effects[join_idx][2] & EXEC_KEYS`). ## Verification - `python -B tests/startup_gfx2hlsl_compute_check.py` (pass; retains the negative control for unstructured `branch out of the block`, adds positive tests for `EXEC`-restoring `else`, scalar `else`, and `hlsl_ext_else`, plus negative controls for clobbered save registers and external jumps into `then`) - `python -B tests/docs_links_check.py` (147 Markdown files, 671 links — pass) - `python -B tests/bidi_controls_check.py` (2502 tracked files — pass)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 23:19:11 +00:00
github manually merged commit b7d6163279 into main 2026-12-02 02:20:34 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.