shader: accept the s_mov_b64 close of an s_and_saveexec_b64 masked region #1321

Merged
MasterDomino merged 1 commit from upstream-pr/1328 into main 2026-11-24 08:33:48 +00:00
MasterDomino commented 2026-11-24 08:12:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T08:12:27Z.


Refs #1315 (Stage A only; the else transition stays for a later review)

An s_and_saveexec_b64 masked region may now close with s_mov_b64 exec, s[a:b], the copy of its exact saved pair. Until now that close was only accepted after a v_cmpx opener (#957). Precompiled pixel programs close every such region this way: in the local input measured on #1315, none of 77,129 simple regions closes with s_or_b64.

Behaviour (tools/pixel_aot.py)

  • Close: the region gate and the close handler accept s_mov_b64 exec, s[a:b] for both openers. close_region still requires the exact saved pair. Inside the region EXEC is a subset of the saved entry mask, so the copy restores the same mask as s_or_b64 exec, exec, s[a:b] and emits the same per-lane selects.
  • Skip: the skip keeps its current rule. One s_cbranch_execz directly after the opener must land on the close of the same pair, which may now be either form.
  • SCC: s_mov_b64 does not write SCC. But s_and_saveexec_b64 has already written SCC from the new EXEC, which the profile does not track. So SCC is not observable after either close, and a reader still rejects. In the v_cmpx profile SCC is tracked through the region, and cmpx_observables (#957) already draws it surviving the MOV close.
  • Unchanged: wave64 only. Wave32 copies, the s_andn2_b64 exec, s[a:b], exec else transition and nesting still reject.

Tests (tests/pixel_aot_check.py)

  • Fixtures: masked_region, masked_skip, masked_skip_asm and masked_complementary now take the close as a parameter (MASKED_OR_RESTORE / MASKED_MOV_RESTORE). draw-exec-regions draws all three with each close.
  • New check_masked_mov_close_controls:
    • The MOV close gives identical HLSL to the OR close for the region, skip and complementary programs.
    • Refused, each with its message:
case message
MOV close of another pair Unexpected execution mask restore
MOV close with no open region Unsupported execution mask
second close Unsupported execution mask
skip landing on another pair's copy Execution skip does not target the matching restore
s_andn2_b64 exec, s[60:61], exec before the close Instruction cannot run in a masked region
s_mov_b32 exec_lo, s60 before the close Instruction cannot run in a masked region
  • An SCC reader after either close rejects with Conditional move requires a tracked SCC. An SCC written after the close is tracked again.
  • Changed existing check: check_cmpx_controls asserted that s_mov_b64 exec, s[60:61] cannot close an s_and_saveexec_b64 region. That is the rule this PR changes. It now asserts that the MOV close lowers identically to the OR close, and that a copy of a different pair still rejects with Unexpected execution mask restore.
  • LLVM 15 binary regression: covers the region, complementary and labelled-skip programs with both closes.

Results

Environment: Windows 11 26H2 (build 26300.9974), dev preset, DXC 1.8.2502.11. Python 3.13.1. LLVM 15.0.7 (LLVM-C.dll, llvm-mc, llvm-objcopy).

python -B tests/pixel_aot_check.py                                  # controls: pass
python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>   # pass
ctest --preset dev --no-tests=error -R '^pixel_aot_(exec_regions|cmpx_regions)_(warp|hardware)$'   # 4/4 pass
backend passing cases (mixed 0.5 / full 10 / empty -1) mutants that must mismatch
WARP 10.0.26100.9818 region, skip, complementary × {OR, MOV}: 18/18, 64/64 pixels each reversed and unmasked × {OR, MOV}: 4/4 mismatch
AMD Radeon RX 9070 XT, driver 32.0.31044.16 18/18 4/4 mismatch

tests/rdna2_tools_check.py (with LLVM, 1 existing skip), form_coverage_check, shader_census_check, shader_corpus_report_check, pso_readiness_check, docs_links_check and bidi_controls_check also pass.

Negative control: with tools/pixel_aot.py restored to main, check_masked_mov_close_controls and the updated check_cmpx_controls fail on the MOV close, with Instruction cannot run in a masked region: s_mov_b64 exec, s[60:61]. The MOV-closed skip program is refused with Execution skip does not target the matching restore.

Not measured

#1314 shows that the shader scan's translator verdict stops at unbound entry registers. So the number of local records that now pass this region close is not measured. The structural counts on #1315 are shape counts only (22,511 wave64 if-only regions in 4,523 records). These draws pin the translator's model on desktop adapters; they are not evidence for gfx1013 hardware.

docs/experiments.md: the region paragraph now names both closes and records these results.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6577475954 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1328). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T08:12:27Z. --- Refs #1315 (Stage A only; the else transition stays for a later review) An `s_and_saveexec_b64` masked region may now close with `s_mov_b64 exec, s[a:b]`, the copy of its exact saved pair. Until now that close was only accepted after a `v_cmpx` opener (#957). Precompiled pixel programs close every such region this way: in the local input measured on #1315, none of 77,129 simple regions closes with `s_or_b64`. ## Behaviour (`tools/pixel_aot.py`) - **Close:** the region gate and the close handler accept `s_mov_b64 exec, s[a:b]` for both openers. `close_region` still requires the exact saved pair. Inside the region EXEC is a subset of the saved entry mask, so the copy restores the same mask as `s_or_b64 exec, exec, s[a:b]` and emits the same per-lane selects. - **Skip:** the skip keeps its current rule. One `s_cbranch_execz` directly after the opener must land on the close of the same pair, which may now be either form. - **SCC:** `s_mov_b64` does not write SCC. But `s_and_saveexec_b64` has already written SCC from the new EXEC, which the profile does not track. So SCC is not observable after either close, and a reader still rejects. In the `v_cmpx` profile SCC is tracked through the region, and `cmpx_observables` (#957) already draws it surviving the MOV close. - **Unchanged:** wave64 only. Wave32 copies, the `s_andn2_b64 exec, s[a:b], exec` else transition and nesting still reject. ## Tests (`tests/pixel_aot_check.py`) - **Fixtures:** `masked_region`, `masked_skip`, `masked_skip_asm` and `masked_complementary` now take the close as a parameter (`MASKED_OR_RESTORE` / `MASKED_MOV_RESTORE`). `draw-exec-regions` draws all three with each close. - **New `check_masked_mov_close_controls`:** - The MOV close gives identical HLSL to the OR close for the region, skip and complementary programs. - Refused, each with its message: | case | message | |---|---| | MOV close of another pair | `Unexpected execution mask restore` | | MOV close with no open region | `Unsupported execution mask` | | second close | `Unsupported execution mask` | | skip landing on another pair's copy | `Execution skip does not target the matching restore` | | `s_andn2_b64 exec, s[60:61], exec` before the close | `Instruction cannot run in a masked region` | | `s_mov_b32 exec_lo, s60` before the close | `Instruction cannot run in a masked region` | - An SCC reader after either close rejects with `Conditional move requires a tracked SCC`. An SCC written after the close is tracked again. - **Changed existing check:** `check_cmpx_controls` asserted that `s_mov_b64 exec, s[60:61]` cannot close an `s_and_saveexec_b64` region. That is the rule this PR changes. It now asserts that the MOV close lowers identically to the OR close, and that a copy of a different pair still rejects with `Unexpected execution mask restore`. - **LLVM 15 binary regression:** covers the region, complementary and labelled-skip programs with both closes. ## Results Environment: Windows 11 26H2 (build 26300.9974), `dev` preset, DXC 1.8.2502.11. Python 3.13.1. LLVM 15.0.7 (`LLVM-C.dll`, `llvm-mc`, `llvm-objcopy`). ``` python -B tests/pixel_aot_check.py # controls: pass python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll> # pass ctest --preset dev --no-tests=error -R '^pixel_aot_(exec_regions|cmpx_regions)_(warp|hardware)$' # 4/4 pass ``` | backend | passing cases (mixed 0.5 / full 10 / empty -1) | mutants that must mismatch | |---|---|---| | WARP 10.0.26100.9818 | region, skip, complementary × {OR, MOV}: 18/18, 64/64 pixels each | reversed and unmasked × {OR, MOV}: 4/4 mismatch | | AMD Radeon RX 9070 XT, driver 32.0.31044.16 | 18/18 | 4/4 mismatch | `tests/rdna2_tools_check.py` (with LLVM, 1 existing skip), `form_coverage_check`, `shader_census_check`, `shader_corpus_report_check`, `pso_readiness_check`, `docs_links_check` and `bidi_controls_check` also pass. **Negative control:** with `tools/pixel_aot.py` restored to main, `check_masked_mov_close_controls` and the updated `check_cmpx_controls` fail on the MOV close, with `Instruction cannot run in a masked region: s_mov_b64 exec, s[60:61]`. The MOV-closed skip program is refused with `Execution skip does not target the matching restore`. ## Not measured #1314 shows that the shader scan's translator verdict stops at unbound entry registers. So the number of local records that now pass this region close is not measured. The structural counts on #1315 are shape counts only (22,511 wave64 if-only regions in 4,523 records). These draws pin the translator's model on desktop adapters; they are not evidence for gfx1013 hardware. `docs/experiments.md`: the region paragraph now names both closes and records these results. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 09:04:32 +00:00
tedin7 commented 2026-11-24 09:04:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:16:13Z.

Review: COMMENTED


Reviewed at commit 8ce2a03778010e425583eb918a21bde5d36fffbf.

Code Review

  • tools/pixel_aot.py: cleanly extends the region gate, s_mov_b64 exec, s[a:b] close handler, and s_cbranch_execz skip target validation to s_and_saveexec_b64 regions while preserving close_region exact-pair matching, scc untrackedness after s_and_saveexec_b64, and rejection of s_andn2_b64 / wave32 s_mov_b32.
  • tests/pixel_aot_check.py: parameterizes masked_region, masked_skip, masked_skip_asm, and masked_complementary over MASKED_OR_RESTORE / MASKED_MOV_RESTORE, adds check_masked_mov_close_controls (covering equivalence, wrong-pair / no-open-region / second-close / skip-target / else-transition / wave32 / SCC negative controls), updates check_cmpx_controls, and adds both closes to check_masked_draw and check_binary.

Verification

Linux (LLVM 19):

  • git diff --check origin/main...HEAD: clean
  • python -B tests/docs_links_check.py: passed (16 Markdown files, 291 links)
  • python -B tests/bidi_controls_check.py: passed (1099 files)
  • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so python -B tests/pixel_aot_check.py: passed
  • Note: tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so stopped earlier in check_f16_cvt_int16_binary on an unrelated LLVM 19 literal encoding difference (v_cvt_f16_i16_e32 v1, 0xfff0 -> ffa2027ef0ff0000).

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):

  • python -B tests/pixel_aot_check.py: passed (12.89s)
  • Debug (--preset dev): cmake --build --preset dev --target offscreen_check -- -j 6 (4.43s) + ctest --preset dev -R '^pixel_aot_(exec|cmpx|region)_.*_warp$' --parallel 4 --no-tests=error --output-on-failure: 6/6 passed (3.46s)
  • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check -- -j 6 (2.29s) + ctest --preset release -R '^pixel_aot_(exec|cmpx|region)_.*_warp$' --parallel 4 --no-tests=error --output-on-failure: 6/6 passed (3.99s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035774210 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1328#pullrequestreview-6035774210). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:16:13Z. **Review:** COMMENTED --- Reviewed at commit `8ce2a03778010e425583eb918a21bde5d36fffbf`. ### Code Review - `tools/pixel_aot.py`: cleanly extends the region gate, `s_mov_b64 exec, s[a:b]` close handler, and `s_cbranch_execz` skip target validation to `s_and_saveexec_b64` regions while preserving `close_region` exact-pair matching, `scc` untrackedness after `s_and_saveexec_b64`, and rejection of `s_andn2_b64` / wave32 `s_mov_b32`. - `tests/pixel_aot_check.py`: parameterizes `masked_region`, `masked_skip`, `masked_skip_asm`, and `masked_complementary` over `MASKED_OR_RESTORE` / `MASKED_MOV_RESTORE`, adds `check_masked_mov_close_controls` (covering equivalence, wrong-pair / no-open-region / second-close / skip-target / else-transition / wave32 / SCC negative controls), updates `check_cmpx_controls`, and adds both closes to `check_masked_draw` and `check_binary`. ### Verification **Linux (LLVM 19):** - `git diff --check origin/main...HEAD`: clean - `python -B tests/docs_links_check.py`: passed (16 Markdown files, 291 links) - `python -B tests/bidi_controls_check.py`: passed (1099 files) - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so python -B tests/pixel_aot_check.py`: passed - Note: `tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so` stopped earlier in `check_f16_cvt_int16_binary` on an unrelated LLVM 19 literal encoding difference (`v_cvt_f16_i16_e32 v1, 0xfff0` -> `ffa2027ef0ff0000`). **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):** - `python -B tests/pixel_aot_check.py`: passed (`12.89s`) - **Debug (`--preset dev`)**: `cmake --build --preset dev --target offscreen_check -- -j 6` (`4.43s`) + `ctest --preset dev -R '^pixel_aot_(exec|cmpx|region)_.*_warp$' --parallel 4 --no-tests=error --output-on-failure`: **6/6 passed** (`3.46s`) - **Release `/O2` (`--preset release`)**: `cmake --build --preset release --target offscreen_check -- -j 6` (`2.29s`) + `ctest --preset release -R '^pixel_aot_(exec|cmpx|region)_.*_warp$' --parallel 4 --no-tests=error --output-on-failure`: **6/6 passed** (`3.99s`)
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!1321
No description provided.