compute: lower s_andn2_wrexec_b64 in the narrow wave64 model #3337

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

@⁠Leyukaka on GitHub · 2026-11-28 10:39 UTC · original
Leyukaka:compute-wave64-wrexec-same-reg → main · +163 −7 · 4 files · 2 commits · merged 2026-11-28 11:22 UTC

Part of #3226. Follows #3316.

s_andn2_wrexec_b64 was refused with unsupported wave64 scalar operation in a guest wave64 request of at most 32 threads. That request runs on the wave32 model (src/gfx1013_compute_native.cpp, the wave64 comment in translate_program), and the b64 path only accepted wrexec with the full wave64 model.

  • translate_program records the narrow model (!stage && direct_dxil && !request.wave32 && !wave64). s_andn2_wrexec_b64 is lowered there as in full wave64: D = S0 & ~EXEC and EXEC = D, on both words, with SCC = D != 0. EXEC_HI starts at zero.
  • In that model a V_CMPX also writes 0 to EXEC_HI: lanes 32-63 hold no thread. This is exact when EXEC_HI was 0; if scalar code set bits there, the hardware result depends on VGPRs of lanes without threads.
  • transfer(): #3316 already clears the EXEC symbols after every _wrexec_b64. The V_CMPX branch now also drops the s127 symbol in the narrow model.

Tests (Windows 11, RTX 5080, SDK 10.0.26100 DXC, Release, main 3f780716 plus #3316 and this commit; after the rebase on 7e5c378d the 27 targeted tests pass again):

  • native_scalar_mask64_controls compiles s_andn2_wrexec_b64 s[28:29], s[28:29] in a 32-thread wave64 request in three variants: EXEC_HI left at zero, set by a scalar move, and set by a scalar move then reset by v_cmpx_eq_u32 0, v0 before the WREXEC (EXEC_HI 0, 0x40000009 and 0 before the WREXEC). It checks the two and/xor words, the EXEC stores and SCC. An odd destination stays refused. The test also keeps three s_bcnt1_i32_b64 refusals that pass on main too.
  • On main the three positive programs are refused with unsupported wave64 scalar operation.
  • native_scalar_mask64_hardware replays the three variants and compares the lane stores, the destination words and SCC.
  • ctest -R "native_|startup_compute|compile_dxil|salu": 528 of 529. native_scalar_lds_hardware fails as on main.
  • 882 captured compute requests, compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests: 250 to 252. The added programs weigh 4,998 dispatches in that run. None is lost. Two programs that already compiled change only by the added store i32 0 to EXEC_HI after a V_CMPX.

Not covered: in the narrow model a V_CMP into an SGPR pair writes only the low word, so a WREXEC whose source pair comes from a V_CMP reads a stale high word (the same gap exists for s_and_b64 on main). In the two programs added above, the source pair comes from s_and_saveexec_b64 or s_mov_b64 ..., exec. No source mutations were run.

**@⁠Leyukaka** on GitHub · 2026-11-28 10:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3335) `Leyukaka:compute-wave64-wrexec-same-reg` → `main` · +163 −7 · 4 files · 2 commits · merged 2026-11-28 11:22 UTC Part of #3226. Follows #3316. `s_andn2_wrexec_b64` was refused with `unsupported wave64 scalar operation` in a guest wave64 request of at most 32 threads. That request runs on the wave32 model (`src/gfx1013_compute_native.cpp`, the wave64 comment in `translate_program`), and the b64 path only accepted `wrexec` with the full wave64 model. - `translate_program` records the narrow model (`!stage && direct_dxil && !request.wave32 && !wave64`). `s_andn2_wrexec_b64` is lowered there as in full wave64: D = S0 & ~EXEC and EXEC = D, on both words, with SCC = D != 0. EXEC_HI starts at zero. - In that model a V_CMPX also writes 0 to EXEC_HI: lanes 32-63 hold no thread. This is exact when EXEC_HI was 0; if scalar code set bits there, the hardware result depends on VGPRs of lanes without threads. - `transfer()`: #3316 already clears the EXEC symbols after every `_wrexec_b64`. The V_CMPX branch now also drops the s127 symbol in the narrow model. Tests (Windows 11, RTX 5080, SDK 10.0.26100 DXC, Release, `main` `3f780716` plus #3316 and this commit; after the rebase on `7e5c378d` the 27 targeted tests pass again): - `native_scalar_mask64_controls` compiles `s_andn2_wrexec_b64 s[28:29], s[28:29]` in a 32-thread wave64 request in three variants: EXEC_HI left at zero, set by a scalar move, and set by a scalar move then reset by `v_cmpx_eq_u32 0, v0` before the WREXEC (EXEC_HI 0, 0x40000009 and 0 before the WREXEC). It checks the two `and`/`xor` words, the EXEC stores and SCC. An odd destination stays refused. The test also keeps three `s_bcnt1_i32_b64` refusals that pass on `main` too. - On `main` the three positive programs are refused with `unsupported wave64 scalar operation`. - `native_scalar_mask64_hardware` replays the three variants and compares the lane stores, the destination words and SCC. - `ctest -R "native_|startup_compute|compile_dxil|salu"`: 528 of 529. `native_scalar_lds_hardware` fails as on `main`. - 882 captured compute requests, `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`: 250 to 252. The added programs weigh 4,998 dispatches in that run. None is lost. Two programs that already compiled change only by the added `store i32 0` to EXEC_HI after a V_CMPX. Not covered: in the narrow model a V_CMP into an SGPR pair writes only the low word, so a WREXEC whose source pair comes from a V_CMP reads a stale high word (the same gap exists for `s_and_b64` on `main`). In the two programs added above, the source pair comes from `s_and_saveexec_b64` or `s_mov_b64 ..., exec`. No source mutations were run.
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.
A guest wave64 request of at most 32 threads runs on the wave32 model,
where EXEC_HI starts at zero. s_andn2_wrexec_b64 is now lowered there as
in full wave64: D = S0 & ~EXEC and EXEC = D on both words. A V_CMPX that
writes EXEC also writes 0 to EXEC_HI in that model, since the guest has
no upper lanes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 10:43:28 +00:00
github-bot force-pushed github-bot/gh-3335 from 8c2aaf8548 to d62f93a776 2026-11-28 11:09:09 +00:00 Compare
github-bot changed target branch from main to gh-pr/3335/base 2026-11-28 11:28:18 +00:00
github manually merged commit 7c5ecc3bc3 into gh-pr/3335/base 2026-11-28 11:28:20 +00:00
Author
Owner

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

Review of head 7c5ecc3b (the PR's own change is unchanged; the new head only merges current main). The base #3316 is merged.

What I checked:

  • src/gfx1013_compute_native.cpp: a new narrow_wave64 flag (guest wave64 request that runs on the wave32 model) is threaded through parse and transfer; the V_CMPX-into-EXEC carry/compare destination is treated as a 64-bit pair only in that model. Wave64 and wave32 behaviour is unchanged.
  • src/gfx1013_direct_compute.inl: s_andn2_wrexec_b64 is accepted in the narrow model (s_andn1_wrexec_b64 stays wave64-only), and a V_CMPX into EXEC zeroes EXEC_HI in that model. The destination and source alignment limits are kept.
  • Tests native_scalar_mask64_controls (DXIL and refusals) and native_scalar_mask64_hardware (real D3D12 readback on WARP, which ran and did not skip) check lanes, EXEC words and the stored pair against a CPU reference.
  • No other open PR covers this slice.

Commands run:

  • Linux: git diff --check origin/main...HEAD clean, python3 -m py_compile tests/native_scalar_mask64_check.py ok.
  • Windows Server 2025, D3D12 WARP 1.0.22, -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$': dev 6/6 passed, release 6/6 passed.
  • Mutation 1 (the EXEC_HI zeroing after V_CMPX removed): native_scalar_mask64_controls and native_scalar_mask64_hardware fail (the cmpx case).
  • Mutation 2 (wrexec no longer accepted in the narrow model): both fail with unsupported wave64 scalar operation.

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

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 11:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3335#pullrequestreview-6097446777) · **reviewed** Review of head `7c5ecc3b` (the PR's own change is unchanged; the new head only merges current `main`). The base #3316 is merged. What I checked: - `src/gfx1013_compute_native.cpp`: a new `narrow_wave64` flag (guest wave64 request that runs on the wave32 model) is threaded through `parse` and `transfer`; the V_CMPX-into-EXEC carry/compare destination is treated as a 64-bit pair only in that model. Wave64 and wave32 behaviour is unchanged. - `src/gfx1013_direct_compute.inl`: `s_andn2_wrexec_b64` is accepted in the narrow model (`s_andn1_wrexec_b64` stays wave64-only), and a V_CMPX into EXEC zeroes EXEC_HI in that model. The destination and source alignment limits are kept. - Tests `native_scalar_mask64_controls` (DXIL and refusals) and `native_scalar_mask64_hardware` (real D3D12 readback on WARP, which ran and did not skip) check lanes, EXEC words and the stored pair against a CPU reference. - No other open PR covers this slice. Commands run: - Linux: `git diff --check origin/main...HEAD` clean, `python3 -m py_compile tests/native_scalar_mask64_check.py` ok. - Windows Server 2025, D3D12 WARP 1.0.22, `-R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$'`: dev 6/6 passed, release 6/6 passed. - Mutation 1 (the EXEC_HI zeroing after V_CMPX removed): `native_scalar_mask64_controls` and `native_scalar_mask64_hardware` fail (the `cmpx` case). - Mutation 2 (wrexec no longer accepted in the narrow model): both fail with `unsupported wave64 scalar operation`. 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:20 UTC · original

Win2025 WARP receipt for head 7c5ecc3b after updating with main.

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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target compile_dxil native_store_replay -- -j 6): 6.87s (configure 0.00s)
    • Test (ctest --preset dev -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$' --parallel 6 --no-tests=error --output-on-failure): 6/6 passed (1.70s: native_salu64_controls 0.22s, native_exec_symbol_b64_controls 0.26s, native_scalar_mask64_hardware 0.39s, native_scalar_mask64_controls 0.55s, native_wave64_exec_salu_hardware 1.11s, native_salu64_hardware 1.34s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target compile_dxil native_store_replay -- -j 6): 33.98s (configure 0.00s)
    • Test (ctest --preset release -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$' --parallel 6 --no-tests=error --output-on-failure): 6/6 passed (1.37s: native_salu64_controls 0.16s, native_exec_symbol_b64_controls 0.20s, native_scalar_mask64_hardware 0.30s, native_scalar_mask64_controls 0.40s, native_wave64_exec_salu_hardware 0.88s, native_salu64_hardware 1.00s)
  • sccache: 0/4 hits; wall 39.6s

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 11:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3335#issuecomment-7238491638) Win2025 WARP receipt for head 7c5ecc3b after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `7c5ecc3bc3694235066607f284032d31b5d31fbd`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target compile_dxil native_store_replay -- -j 6`): `6.87s` (configure `0.00s`) - Test (`ctest --preset dev -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$' --parallel 6 --no-tests=error --output-on-failure`): **6/6 passed** (`1.70s`: `native_salu64_controls` `0.22s`, `native_exec_symbol_b64_controls` `0.26s`, `native_scalar_mask64_hardware` `0.39s`, `native_scalar_mask64_controls` `0.55s`, `native_wave64_exec_salu_hardware` `1.11s`, `native_salu64_hardware` `1.34s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target compile_dxil native_store_replay -- -j 6`): `33.98s` (configure `0.00s`) - Test (`ctest --preset release -R '^native_(scalar_mask64_(controls|hardware)|exec_symbol_b64_controls|wave64_exec_salu_hardware|salu64_(controls|hardware))$' --parallel 6 --no-tests=error --output-on-failure`): **6/6 passed** (`1.37s`: `native_salu64_controls` `0.16s`, `native_exec_symbol_b64_controls` `0.20s`, `native_scalar_mask64_hardware` `0.30s`, `native_scalar_mask64_controls` `0.40s`, `native_wave64_exec_salu_hardware` `0.88s`, `native_salu64_hardware` `1.00s`) - `sccache`: 0/4 hits; wall `39.6s` AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.