gfx2hlsl: support v_cmpx_* with prior exec_lo save in wave-level if/else blocks #3802

Manually merged
github merged 4 commits from github-bot/gh-3800 into gh-pr/3800/base 2026-12-02 15:59:46 +00:00 AGit
Owner

@⁠Holastor on GitHub · 2026-12-01 23:44 UTC · original
Holastor:dxil/execz-vcmpx-else-branch → main · +90 −19 · 2 files · 4 commits · merged 2026-12-02 15:57 UTC

Depends on #3800

Summary

Extends Stage.execz_else_branch in tools/startup/gfx2hlsl.py to support wave-level if / else blocks opened by v_cmpx_* (guard - 1) when exec_lo / exec was saved earlier in the same basic block (s_mov_b32 sN, exec_lo or s_mov_b64 s[N:N+1], exec) without intervening branches, branch targets, or EXEC modifications.

  • Preserves all structured CFG invariants from #3800 (single-entry then arm, no clobber of sN in then, valid else entries, and EXEC restoration).
  • Unblocks v_cmpx_lt_u32 if/else regions in large .c67 compute shaders (advancing past the v_cmpx_* gate at instruction 265 in req_00840c5921f4d486.c67).
  • Scalar prologue before EXEC restore at join_idx (79cb4e6b): allows pure scalar instructions at join_idx (e.g. s_nand_b32) before s_mov_b32 exec_lo, sN / s_mov_b64 exec, ... when validating scalar-only else arms.

Verification

  • python -B tests/startup_gfx2hlsl_compute_check.py (pass; adds hlsl_cmpx_else and hlsl_join_prologue positive tests plus negative control for v_cmpx_* without a prior exec_lo save)
  • 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:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3800) `Holastor:dxil/execz-vcmpx-else-branch` → `main` · +90 −19 · 2 files · 4 commits · merged 2026-12-02 15:57 UTC Depends on #3800 ## Summary Extends `Stage.execz_else_branch` in `tools/startup/gfx2hlsl.py` to support wave-level `if / else` blocks opened by `v_cmpx_*` (`guard - 1`) when `exec_lo` / `exec` was saved earlier in the same basic block (`s_mov_b32 sN, exec_lo` or `s_mov_b64 s[N:N+1], exec`) without intervening branches, branch targets, or `EXEC` modifications. - Preserves all structured CFG invariants from #3800 (single-entry `then` arm, no clobber of `sN` in `then`, valid `else` entries, and `EXEC` restoration). - Unblocks `v_cmpx_lt_u32` `if/else` regions in large `.c67` compute shaders (advancing past the `v_cmpx_*` gate at instruction 265 in `req_00840c5921f4d486.c67`). - **Scalar prologue before `EXEC` restore at `join_idx` (`79cb4e6b`):** allows pure scalar instructions at `join_idx` (e.g. `s_nand_b32`) before `s_mov_b32 exec_lo, sN` / `s_mov_b64 exec, ...` when validating scalar-only `else` arms. ## Verification - `python -B tests/startup_gfx2hlsl_compute_check.py` (pass; adds `hlsl_cmpx_else` and `hlsl_join_prologue` positive tests plus negative control for `v_cmpx_*` without a prior `exec_lo` save) - `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:47:54 +00:00
github-bot force-pushed github-bot/gh-3800 from 79cb4e6bdb to 0d156d3c89 2026-12-02 07:11:27 +00:00 Compare
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 08:59 UTC · original · requested changes

The standard compute and nearby control-flow checks pass. Two one-instruction variants of the PR's new synthetic fixtures still take the widened structured path outside its stated proof. Replacing the NOP between s_mov_b32 s21, exec_lo and CMPX with s_mov_b32 s21, 0 is accepted even though the matching restore no longer reads the entering mask. The forward join scan likewise accepts replacing the join NOP with v_mov_b32 v5, 1 before the EXEC restore, despite the scalar-prologue rule. Please invalidate a save when its SGPRs are overwritten before CMPX, restrict the join scan to the supported prologue, and add both refusal controls.

**@⁠R0Y00** on GitHub · 2026-12-02 08:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3800#pullrequestreview-6147562995) · **requested changes** The standard compute and nearby control-flow checks pass. Two one-instruction variants of the PR's new synthetic fixtures still take the widened structured path outside its stated proof. Replacing the NOP between `s_mov_b32 s21, exec_lo` and CMPX with `s_mov_b32 s21, 0` is accepted even though the matching restore no longer reads the entering mask. The forward join scan likewise accepts replacing the join NOP with `v_mov_b32 v5, 1` before the EXEC restore, despite the scalar-prologue rule. Please invalidate a save when its SGPRs are overwritten before CMPX, restrict the join scan to the supported prologue, and add both refusal controls.
Author
Owner

@⁠Holastor on GitHub · 2026-12-02 10:20 UTC · original

Addressed both review comments in f5f0b476:

  1. v_cmpx_* save clobber check (tools/startup/gfx2hlsl.py): Track scalar registers written via effects[k][2] between the s_mov_b32/s_mov_b64 save and v_cmpx_*, rejecting the save if sN (or either half of s[N:N+1]) is overwritten.
  2. Strict scalar prologue at join_idx (tools/startup/gfx2hlsl.py): Restrict the forward scan at join_idx before restoring EXEC to pure scalar instructions (op.startswith('s_'), excluding EXECZ_REFUSED, branches/calls, vector writes effects[k][1], and EXEC writes).
  3. Negative controls (tests/startup_gfx2hlsl_compute_check.py): Added refusal tests for both s_mov_b32 s21, 0 clobbering s21 before v_cmpx_* and v_mov_b32 v5, 1 at join_idx before s_mov_b32 exec_lo, s21.

Verified with:

  • tests/startup_gfx2hlsl_compute_check.py
  • tests/docs_links_check.py
  • tests/bidi_controls_check.py
**@⁠Holastor** on GitHub · 2026-12-02 10:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3800#issuecomment-7342333489) Addressed both review comments in f5f0b476: 1. **`v_cmpx_*` save clobber check (`tools/startup/gfx2hlsl.py`):** Track scalar registers written via `effects[k][2]` between the `s_mov_b32`/`s_mov_b64` save and `v_cmpx_*`, rejecting the save if `sN` (or either half of `s[N:N+1]`) is overwritten. 2. **Strict scalar prologue at `join_idx` (`tools/startup/gfx2hlsl.py`):** Restrict the forward scan at `join_idx` before restoring `EXEC` to pure scalar instructions (`op.startswith('s_')`, excluding `EXECZ_REFUSED`, branches/calls, vector writes `effects[k][1]`, and `EXEC` writes). 3. **Negative controls (`tests/startup_gfx2hlsl_compute_check.py`):** Added refusal tests for both `s_mov_b32 s21, 0` clobbering `s21` before `v_cmpx_*` and `v_mov_b32 v5, 1` at `join_idx` before `s_mov_b32 exec_lo, s21`. Verified with: - `tests/startup_gfx2hlsl_compute_check.py` - `tests/docs_links_check.py` - `tests/bidi_controls_check.py`
github-bot force-pushed github-bot/gh-3800 from f5f0b47624 to f59d0681de 2026-12-02 10:56:28 +00:00 Compare
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 12:00 UTC · original · approved these changes

Both previous findings are addressed on f59d0681. The compute, join-symbol, mask-overwrite and readfirstlane-recompute Python checks passed. Removing either guard independently makes the matching new refusal control fail, and the source was restored. The required Windows job is still red in the inherited native_direct_mesh fixture (+0x34: unmapped graphics export); please sync after #3853 lands and let Windows CI rerun.

**@⁠R0Y00** on GitHub · 2026-12-02 12:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3800#pullrequestreview-6150287817) · **approved these changes** Both previous findings are addressed on `f59d0681`. The compute, join-symbol, mask-overwrite and readfirstlane-recompute Python checks passed. Removing either guard independently makes the matching new refusal control fail, and the source was restored. The required Windows job is still red in the inherited `native_direct_mesh` fixture (`+0x34: unmapped graphics export`); please sync after #3853 lands and let Windows CI rerun.
github-bot changed target branch from main to gh-pr/3800/base 2026-12-02 15:59:43 +00:00
github manually merged commit 58a2493155 into gh-pr/3800/base 2026-12-02 15:59:46 +00:00
Author
Owner

@⁠Holastor on GitHub · 2026-12-02 15:54 UTC · original

@⁠R0Y00 All CI green

**@⁠Holastor** on GitHub · 2026-12-02 15:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3800#issuecomment-7351137160) @⁠R0Y00 All CI green
This discussion has been locked. Commenting is limited to contributors.
No description provided.