compute: forget EXEC symbols after 64-bit saveexec and wrexec #3316

Manually merged
github merged 2 commits from github-bot/gh-3314 into gh-pr/3314/base 2026-11-28 11:08:49 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-28 08:38 UTC · original
Leyukaka:exec-symbol-b64 → main · +62 −0 · 3 files · 2 commits · merged 2026-11-28 11:01 UTC

Part of #2935. Target branch main. Follow-up to my review on #3299.

Problem. transfer() (src/gfx1013_compute_native.cpp) records a symbol for EXEC in s[126]/s[127], for example a constant after s_mov_b64 exec, <literal>. The wave32 saveexec/wrexec branch clears s[126]. The 64-bit *_saveexec_b64 and *_wrexec_b64 instead fell into the generic SOP1 branch, which clears only the destination pair, so the old EXEC constant survived them.

  • A later s_mov_b32 sN, exec_lo then copied that constant into sN, and the constant-sampler path could fold a value the program no longer had. I have not seen this in a real shader; it is a soundness gap.
  • This covered all twelve 64-bit forms the direct path lowers: the ten *_saveexec_b64 (two added by #3299), s_andn1_wrexec_b64 (#3299) and s_andn2_wrexec_b64 (my #3249).

Change. Compute SOP1 ops whose name ends in _saveexec_b64 or _wrexec_b64 now clear the destination pair and both EXEC words. Nothing else changes.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on main c6f23813 plus this commit.

  • New native_exec_symbol_b64_controls builds a wave64 program that takes a sampler word from exec_lo:
    • with a constant EXEC and no saveexec, it compiles;
    • after s_and_saveexec_b64 or s_andn2_wrexec_b64 with an unknown source, it is refused with "nonconstant sampler".
  • With main's compile_dxil, both the saveexec and the wrexec case compile, because the stale constant is folded. With this commit both are refused with "nonconstant sampler".
  • The saveexec, wrexec, wave64 EXEC SALU and native_direct_container tests pass, 11 of 11.
  • On a full build, ctest -R "native_|startup_compute|compile_dxil|salu" passes 526 of 527. native_scalar_lds_hardware fails as on main.

The test reads only exec_lo, so the s[127] clear is not covered, and I did not run a mutation that keeps one EXEC word. The results on main cover removing the fix entirely.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-28 08:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3314) `Leyukaka:exec-symbol-b64` → `main` · +62 −0 · 3 files · 2 commits · merged 2026-11-28 11:01 UTC Part of #2935. Target branch `main`. Follow-up to my review on #3299. **Problem.** `transfer()` (`src/gfx1013_compute_native.cpp`) records a symbol for EXEC in `s[126]`/`s[127]`, for example a constant after `s_mov_b64 exec, <literal>`. The wave32 saveexec/wrexec branch clears `s[126]`. The 64-bit `*_saveexec_b64` and `*_wrexec_b64` instead fell into the generic SOP1 branch, which clears only the destination pair, so the old EXEC constant survived them. - A later `s_mov_b32 sN, exec_lo` then copied that constant into sN, and the constant-sampler path could fold a value the program no longer had. I have not seen this in a real shader; it is a soundness gap. - This covered all twelve 64-bit forms the direct path lowers: the ten `*_saveexec_b64` (two added by #3299), `s_andn1_wrexec_b64` (#3299) and `s_andn2_wrexec_b64` (my #3249). **Change.** Compute SOP1 ops whose name ends in `_saveexec_b64` or `_wrexec_b64` now clear the destination pair and both EXEC words. Nothing else changes. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on `main` `c6f23813` plus this commit. - New `native_exec_symbol_b64_controls` builds a wave64 program that takes a sampler word from `exec_lo`: - with a constant EXEC and no saveexec, it compiles; - after `s_and_saveexec_b64` or `s_andn2_wrexec_b64` with an unknown source, it is refused with "nonconstant sampler". - With `main`'s `compile_dxil`, both the saveexec and the wrexec case compile, because the stale constant is folded. With this commit both are refused with "nonconstant sampler". - The saveexec, wrexec, wave64 EXEC SALU and `native_direct_container` tests pass, 11 of 11. - On a full build, `ctest -R "native_|startup_compute|compile_dxil|salu"` passes 526 of 527. `native_scalar_lds_hardware` fails as on `main`. The test reads only `exec_lo`, so the `s[127]` clear is not covered, and I did not run a mutation that keeps one EXEC word. The results on `main` cover removing the fix entirely. AI-assisted.
transfer() records the symbol of EXEC in s[126]/s[127], for example a
constant after s_mov_b64 exec, <literal>. The wave32 saveexec/wrexec
branch clears s[126], but the 64-bit *_saveexec_b64 and *_wrexec_b64
fell into the generic SOP1 branch, which clears only the destination
pair. The analysis then kept the old EXEC constant, and a later
s_mov_b32 sN, exec_lo copied it, so the constant-sampler path could
fold a value the program no longer had. These ops now clear the
destination pair and both EXEC words.

New test native_exec_symbol_b64_controls: a sampler word taken from
exec_lo compiles while EXEC is a known constant, and is refused with
"nonconstant sampler" after s_and_saveexec_b64 or s_andn2_wrexec_b64
with an unknown source.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 08:50:34 +00:00
github-bot changed target branch from main to gh-pr/3314/base 2026-11-28 11:08:46 +00:00
github manually merged commit 2814bec1b3 into gh-pr/3314/base 2026-11-28 11:08:49 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 11:00 UTC · original · reviewed

Review of head 2814bec1 (the PR's own change is unchanged from 4c8513e0; the new head only merges current main).

What I checked:

  • src/gfx1013_compute_native.cpp, transfer(): the new branch covers the 64-bit *_saveexec_b64 and *_wrexec_b64 SOP1 forms, clears the destination pair plus both EXEC words (126/127) and is limited to the non-graphics path. The wave32 branch above it is untouched. The name suffix tests are length-safe.
  • Test native_exec_symbol_b64_controls builds a wave64 container, copies EXEC into a sampler word after s_and_saveexec_b64 / s_andn2_wrexec_b64, and requires the translator to refuse the now non-constant sampler (the constant-EXEC control still compiles). It guards the behavior the caller sees (compile result and message).
  • No other open PR covers this slice: #3337 only stacks on this commit; #3299 (merged) is the earlier lowering.

Commands run:

  • Linux: python3 tests/docs_links_check.py ok, python3 tests/bidi_controls_check.py ok, git diff --check origin/main...HEAD clean, python3 -m py_compile tests/native_exec_symbol_b64_check.py ok.
  • Windows Server 2025, D3D12 WARP 1.0.22, -R '^native_(exec_symbol_b64_controls|direct_container|salu64_controls|compute_clear)$': dev 4/4 passed, release 4/4 passed.
  • Mutation 1 (drop set(126, {}) in the new branch): native_exec_symbol_b64_controls fails at the saveexec case.
  • Mutation 2 (wrexec suffix no longer matches): native_exec_symbol_b64_controls fails at the wrexec case.

No blocking findings. The receipt follows in a separate comment.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 11:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3314#pullrequestreview-6097350606) · **reviewed** Review of head `2814bec1` (the PR's own change is unchanged from `4c8513e0`; the new head only merges current `main`). What I checked: - `src/gfx1013_compute_native.cpp`, `transfer()`: the new branch covers the 64-bit `*_saveexec_b64` and `*_wrexec_b64` SOP1 forms, clears the destination pair plus both EXEC words (126/127) and is limited to the non-graphics path. The wave32 branch above it is untouched. The name suffix tests are length-safe. - Test `native_exec_symbol_b64_controls` builds a wave64 container, copies EXEC into a sampler word after `s_and_saveexec_b64` / `s_andn2_wrexec_b64`, and requires the translator to refuse the now non-constant sampler (the constant-EXEC control still compiles). It guards the behavior the caller sees (compile result and message). - No other open PR covers this slice: #3337 only stacks on this commit; #3299 (merged) is the earlier lowering. Commands run: - Linux: `python3 tests/docs_links_check.py` ok, `python3 tests/bidi_controls_check.py` ok, `git diff --check origin/main...HEAD` clean, `python3 -m py_compile tests/native_exec_symbol_b64_check.py` ok. - Windows Server 2025, D3D12 WARP 1.0.22, `-R '^native_(exec_symbol_b64_controls|direct_container|salu64_controls|compute_clear)$'`: dev 4/4 passed, release 4/4 passed. - Mutation 1 (drop `set(126, {})` in the new branch): `native_exec_symbol_b64_controls` fails at the `saveexec` case. - Mutation 2 (wrexec suffix no longer matches): `native_exec_symbol_b64_controls` fails at the `wrexec` case. No blocking findings. The receipt follows in a separate comment. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 11:00 UTC · original

Win2025 WARP receipt for head 2814bec1 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 2814bec1b312728c2be3d1bbbe8b0cc57416e4c9:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target compile_dxil native_store_replay -- -j 3): 8.07s (configure 2.38s)
    • Test (ctest --preset dev -R '^native_(exec_symbol_b64_controls|direct_container|salu64_controls|compute_clear)$' --parallel 4 --no-tests=error --output-on-failure): 4/4 passed (17.28s: native_salu64_controls 0.22s, native_exec_symbol_b64_controls 0.28s, native_compute_clear 0.33s, native_direct_container 16.74s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target compile_dxil native_store_replay -- -j 3): 46.35s (configure 6.48s)
    • Test (ctest --preset release -R '^native_(exec_symbol_b64_controls|direct_container|salu64_controls|compute_clear)$' --parallel 4 --no-tests=error --output-on-failure): 4/4 passed (12.48s: native_salu64_controls 0.21s, native_exec_symbol_b64_controls 0.25s, native_compute_clear 0.30s, native_direct_container 11.98s)
  • sccache: 192/251 hits; wall 74.4s

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 11:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3314#issuecomment-7238268803) Win2025 WARP receipt for head 2814bec1 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `2814bec1b312728c2be3d1bbbe8b0cc57416e4c9`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target compile_dxil native_store_replay -- -j 3`): `8.07s` (configure `2.38s`) - Test (`ctest --preset dev -R '^native_(exec_symbol_b64_controls|direct_container|salu64_controls|compute_clear)$' --parallel 4 --no-tests=error --output-on-failure`): **4/4 passed** (`17.28s`: `native_salu64_controls` `0.22s`, `native_exec_symbol_b64_controls` `0.28s`, `native_compute_clear` `0.33s`, `native_direct_container` `16.74s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target compile_dxil native_store_replay -- -j 3`): `46.35s` (configure `6.48s`) - Test (`ctest --preset release -R '^native_(exec_symbol_b64_controls|direct_container|salu64_controls|compute_clear)$' --parallel 4 --no-tests=error --output-on-failure`): **4/4 passed** (`12.48s`: `native_salu64_controls` `0.21s`, `native_exec_symbol_b64_controls` `0.25s`, `native_compute_clear` `0.30s`, `native_direct_container` `11.98s`) - `sccache`: 192/251 hits; wall `74.4s` AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.