shader: lower wave32 masked regions (s_and_saveexec_b32) in pixel_aot #2163

Manually merged
github merged 1 commit from gh-pr/2163/head into gh-pr/2163/base 2026-11-27 00:01:53 +00:00
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-25 02:03 UTC · original
legacy-code-archaeologist:shader/wave32-regions → main · +258 −37 · 4 files · 1 commits · merged 2026-11-25 02:15 UTC

Fixes #2137.

Under the declared wave32 guest profile, lower(..., wave_size=32), s_and_saveexec_b32 sN, vcc_lo|sM opens the same structured masked region as s_and_saveexec_b64. A wave32 guest's EXEC is exec_lo, so the following forms work on the one saved SGPR:

  • s_mov_b32 exec_lo, sN and s_or_b32 exec_lo, exec_lo, sN close the region.
  • s_andn2_b32 exec_lo, sN, exec_lo switches it once to its else arm.
  • s_cbranch_execz targets those spellings.

The arm, join, skip, wait, scalar-load and scalar-ALU rules of the wave64 region apply unchanged.

Behaviour

  • Width: a region accepts only the close and else spellings of its own width. A wave32 form inside a wave64 region therefore keeps its existing Instruction cannot run in a masked region refusal, and no existing pixel_aot assertion changes.

  • Opener refusals (Unsupported execution mask save):

    • any other operand spelling: vcc, an SGPR pair, a constant, or exec_lo, m0, vcc_lo or a pair as destination;
    • a save into the condition register;
    • a pending save register;
    • an untracked or two-register condition;
    • a mask other than the entry mask.

    Without the profile it is refused as 32-bit execution mask save requires a validated wave32 guest profile, and an out-of-range register keeps Scalar register out of range.

  • Other refusals: a close, else or skip onto another SGPR, a second transition and nesting. An SCC reader after either close is also refused, because the opener already leaves SCC unknown, as after the b64 MOV close.

  • Only sN is saved: a write to sN+1 inside a wave32 region is an ordinary scalar write.

  • Condition tracking: the compare that writes the condition is tracked the same way in both profiles; no width is recorded for it.

Evidence

Base be3c6c0e, Windows 11 build 26100, debug layer unavailable.

Check Result
python -B tests/pixel_aot_check.py, new check_wave32_region_controls pass
HLSL equality Each wave32 fixture is derived from a wave64 fixture by replacing its exec lines: the plain, complementary and skip regions with both closes, the 8 saveexec if/else shapes, and the saveexec wait (11 forms × skip), scalar-ALU, scalar-load and body families. It must lower to identical HLSL and is refused with wave_size=64 and None.
Scratch mutation run, not committed (14 mutations of the new branches) 13 fail the controls. The survivor drops the scc = None after the s_or_b32 close, which no reader can observe.
`ctest -R '^pixel_aot_exec_regions_(warp hardware)$'` on WARP 10.0.26100.8972
same, XBOX2WINDOWS_ADAPTER=Quadro (NVIDIA Quadro M1000M, 32.0.15.7371) same counts
same, XBOX2WINDOWS_ADAPTER=Intel (Intel HD Graphics 530, 31.0.101.2111) same counts
pixel_aot_check.py binary, LLVM 15.0.7, wave32 twins assembled and disassembled with +wavefrontsize32,-wavefrontsize64 pass
ctest -R '^pixel_aot_' -E '_hardware$' -j 3 (before the final rebase) 89/89
tests/form_coverage_check.py, tests/rdna2_tools_check.py (LLVM, 154 tests, 1 skip), docs_links_check, shader_census_check, shader_probe_check pass

The wave32 draws lower to the same HLSL as their wave64 fixtures. They add form coverage records for s_and_saveexec_b32, not new pixel evidence, and nothing here runs on gfx1013.

Changed assertion (intended): tests/form_coverage_check.py no longer lists s_and_saveexec_b32 in rejected_forms. It now asserts that the form is accepted and covered as SOP1 s_and_saveexec_b32 in gfx1013.tsv.

Not in this PR

  • No corpus count changes. No tool passes wave_size=32 today, and there is no command-line option for it. tools/scan_unsupported_shaders.py forwards a wave_size argument, but its SUPPORTED_INSTRUCTIONS_REGEX list is unchanged.
  • Out of scope: the wave32 v_cmpx opener after s_mov_b32 sN, exec_lo, the compute translator's own s_and_saveexec_b32 guard, and the other translators.

AI-assisted.

🤖 Generated with Claude Code

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-25 02:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2163) `legacy-code-archaeologist:shader/wave32-regions` → `main` · +258 −37 · 4 files · 1 commits · merged 2026-11-25 02:15 UTC Fixes #2137. Under the declared wave32 guest profile, `lower(..., wave_size=32)`, `s_and_saveexec_b32 sN, vcc_lo|sM` opens the same structured masked region as `s_and_saveexec_b64`. A wave32 guest's EXEC is `exec_lo`, so the following forms work on the one saved SGPR: - `s_mov_b32 exec_lo, sN` and `s_or_b32 exec_lo, exec_lo, sN` close the region. - `s_andn2_b32 exec_lo, sN, exec_lo` switches it once to its else arm. - `s_cbranch_execz` targets those spellings. The arm, join, skip, wait, scalar-load and scalar-ALU rules of the wave64 region apply unchanged. ## Behaviour - **Width:** a region accepts only the close and else spellings of its own width. A wave32 form inside a wave64 region therefore keeps its existing `Instruction cannot run in a masked region` refusal, and no existing pixel_aot assertion changes. - **Opener refusals** (`Unsupported execution mask save`): - any other operand spelling: `vcc`, an SGPR pair, a constant, or `exec_lo`, `m0`, `vcc_lo` or a pair as destination; - a save into the condition register; - a pending save register; - an untracked or two-register condition; - a mask other than the entry mask. Without the profile it is refused as `32-bit execution mask save requires a validated wave32 guest profile`, and an out-of-range register keeps `Scalar register out of range`. - **Other refusals:** a close, else or skip onto another SGPR, a second transition and nesting. An SCC reader after either close is also refused, because the opener already leaves SCC unknown, as after the b64 MOV close. - **Only `sN` is saved:** a write to `sN+1` inside a wave32 region is an ordinary scalar write. - **Condition tracking:** the compare that writes the condition is tracked the same way in both profiles; no width is recorded for it. ## Evidence Base `be3c6c0e`, Windows 11 build 26100, debug layer unavailable. | Check | Result | |---|---| | `python -B tests/pixel_aot_check.py`, new `check_wave32_region_controls` | pass | | HLSL equality | Each wave32 fixture is derived from a wave64 fixture by replacing its exec lines: the plain, complementary and skip regions with both closes, the 8 saveexec if/else shapes, and the saveexec wait (11 forms × skip), scalar-ALU, scalar-load and body families. It must lower to identical HLSL and is refused with `wave_size=64` and `None`. | | Scratch mutation run, not committed (14 mutations of the new branches) | 13 fail the controls. The survivor drops the `scc = None` after the `s_or_b32` close, which no reader can observe. | | `ctest -R '^pixel_aot_exec_regions_(warp|hardware)$'` on WARP 10.0.26100.8972 | 50 batches, 21 of them wave32 twins. 108/108 pass cases match, 14/14 mutant cases mismatch. | | same, `XBOX2WINDOWS_ADAPTER=Quadro` (NVIDIA Quadro M1000M, 32.0.15.7371) | same counts | | same, `XBOX2WINDOWS_ADAPTER=Intel` (Intel HD Graphics 530, 31.0.101.2111) | same counts | | `pixel_aot_check.py binary`, LLVM 15.0.7, wave32 twins assembled and disassembled with `+wavefrontsize32,-wavefrontsize64` | pass | | `ctest -R '^pixel_aot_' -E '_hardware$' -j 3` (before the final rebase) | 89/89 | | `tests/form_coverage_check.py`, `tests/rdna2_tools_check.py` (LLVM, 154 tests, 1 skip), `docs_links_check`, `shader_census_check`, `shader_probe_check` | pass | The wave32 draws lower to the same HLSL as their wave64 fixtures. They add form coverage records for `s_and_saveexec_b32`, not new pixel evidence, and nothing here runs on gfx1013. **Changed assertion (intended):** `tests/form_coverage_check.py` no longer lists `s_and_saveexec_b32` in `rejected_forms`. It now asserts that the form is accepted and covered as `SOP1 s_and_saveexec_b32` in `gfx1013.tsv`. ## Not in this PR - **No corpus count changes.** No tool passes `wave_size=32` today, and there is no command-line option for it. `tools/scan_unsupported_shaders.py` forwards a `wave_size` argument, but its `SUPPORTED_INSTRUCTIONS_REGEX` list is unchanged. - **Out of scope:** the wave32 `v_cmpx` opener after `s_mov_b32 sN, exec_lo`, the compute translator's own `s_and_saveexec_b32` guard, and the other translators. _AI-assisted._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Under the declared wave32 guest profile (lower(..., wave_size=32)),
s_and_saveexec_b32 sN, vcc_lo|sM opens the same structured masked region
as s_and_saveexec_b64. A wave32 guest's EXEC is exec_lo, so the
following forms work on the one saved SGPR, with the wave64 arm, join,
skip, wait, scalar-load and scalar-ALU rules unchanged:

- s_mov_b32 exec_lo, sN and s_or_b32 exec_lo, exec_lo, sN close the
  region;
- s_andn2_b32 exec_lo, sN, exec_lo switches it once to its else arm;
- s_cbranch_execz targets the wave32 close or else.

A region accepts only the close and else spellings of its own width, so
a wave32 form in a wave64 region keeps its old refusal message. The
opener is refused without the profile, with any other operand spelling,
when it saves into the condition register, when the save register is
pending or out of range, when the condition is untracked or spans two
registers, and outside the entry mask.

check_wave32_region_controls derives each wave32 fixture from a wave64
fixture by replacing its exec lines. The fixtures are the plain,
complementary and skip regions, every saveexec if/else shape, and the
saveexec wait, scalar-ALU, scalar-load and body families. Each wave32
fixture must lower to identical HLSL, and every refusal is pinned with
its message.

The exec_regions draws and the LLVM 15 round trip (+wavefrontsize32)
include the wave32 twins. tests/form_coverage_check.py no longer lists
s_and_saveexec_b32 as rejected and asserts that it is covered.

Fixes #2137

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:01:51 +00:00
github manually merged commit 396367e776 into gh-pr/2163/base 2026-11-27 00:01:53 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:10 UTC · original · reviewed

Review of head 396367e776 (comment only).

Result: 0 P1, 0 P2.

Logic: s_and_saveexec_b32 on exec_lo is admitted only under a validated wave32 profile. It needs a tracked single-register condition, and a save into the condition register is refused. The region records width 32. Close and else spellings are accepted per width only (b32 forms in a 32-wide region, b64 forms in a 64-wide one). The skip target is matched against the single saved SGPR. Wave32 lowers to the same HLSL as its wave64 twin, and the tests assert exactly that across the plain, else, scalar-alu, wait, scalar-load and body families. The wrong-width, wrong-register and double-else controls are covered.

Commands run locally (worktree at this SHA):

  • python3 tests/pixel_aot_check.py -> rc=0
  • python3 tests/docs_links_check.py -> Self-test passed, 399 links
  • python3 tests/bidi_controls_check.py -> no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • tests/form_coverage_check.py needs iced_x86, which is not installed locally. The Linux CI job covers it and is green.

Mutations (each reverted with git checkout -- .):

  1. The wave32 in-region filter was switched to width 64. pixel_aot_check.py failed (check_masked_mov_close_controls).
  2. The self-save refusal (m[1] == m[2]) was removed. pixel_aot_check.py failed (check_wave32_region_controls).

CI: Linux checks pass, fixtures pass, Build and test on Windows pass. The change touches only .py and .md files.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 02:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2163#pullrequestreview-6050608255) · **reviewed** Review of head 396367e7763d344c4e973d859eb9863e9cb08696 (comment only). Result: 0 P1, 0 P2. Logic: s_and_saveexec_b32 on exec_lo is admitted only under a validated wave32 profile. It needs a tracked single-register condition, and a save into the condition register is refused. The region records width 32. Close and else spellings are accepted per width only (b32 forms in a 32-wide region, b64 forms in a 64-wide one). The skip target is matched against the single saved SGPR. Wave32 lowers to the same HLSL as its wave64 twin, and the tests assert exactly that across the plain, else, scalar-alu, wait, scalar-load and body families. The wrong-width, wrong-register and double-else controls are covered. Commands run locally (worktree at this SHA): - python3 tests/pixel_aot_check.py -> rc=0 - python3 tests/docs_links_check.py -> Self-test passed, 399 links - python3 tests/bidi_controls_check.py -> no bidirectional controls - git diff --check origin/main...HEAD -> clean - tests/form_coverage_check.py needs iced_x86, which is not installed locally. The Linux CI job covers it and is green. Mutations (each reverted with git checkout -- .): 1. The wave32 in-region filter was switched to width 64. pixel_aot_check.py failed (check_masked_mov_close_controls). 2. The self-save refusal (m[1] == m[2]) was removed. pixel_aot_check.py failed (check_wave32_region_controls). CI: Linux checks pass, fixtures pass, Build and test on Windows pass. The change touches only .py and .md files. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.