compute: lower s_andn2_wrexec_b64 in the narrow wave64 model #3335

Merged
Leyukaka merged 2 commits from upstream-pr/3335 into main 2026-11-28 11:22:06 +00:00
Leyukaka commented 2026-11-28 10:39:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T10:39:22Z.


Part of #3224. Follows #3314.

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(): #3314 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 #3314 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5539263586 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3335). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T10:39:22Z. --- Part of #3224. Follows #3314. `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()`: #3314 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 #3314 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.
tedin7 commented 2026-11-28 11:20:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T11:20:54Z.

Review: COMMENTED


Review of head 7c5ecc3b (the PR's own change is unchanged; the new head only merges current main). The base #3314 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6097446777 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3335#pullrequestreview-6097446777). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T11:20:54Z. **Review:** COMMENTED --- Review of head `7c5ecc3b` (the PR's own change is unchanged; the new head only merges current `main`). The base #3314 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 commented 2026-11-28 11:20:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T11:20:55Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7238491638 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3335#issuecomment-7238491638). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T11:20:55Z. --- 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.
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!3335
No description provided.