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

Merged
legacy-code-archaeologist merged 1 commit from upstream-pr/2163 into main 2026-11-25 02:15:22 +00:00
legacy-code-archaeologist commented 2026-11-25 02:03:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T02:03:47Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6595452144 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2163). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T02:03:47Z. --- 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)
upstream-sync closed this pull request 2026-11-25 03:01:13 +00:00
tedin7 commented 2026-11-25 03:01:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:10:06Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050608255 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2163#pullrequestreview-6050608255). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:10:06Z. **Review:** COMMENTED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2155
No description provided.