compute: accept VCC as destination and source in s_andn2_wrexec_b64 and s_andn1_wrexec_b64 #3421

Merged
Ammmae0x merged 1 commit from upstream-pr/3421 into main 2026-11-29 08:44:28 +00:00
Ammmae0x commented 2026-11-29 00:24:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-29T00:24:14Z.


Refs #3224, #2935

Accept VCC (106) as destination and as S0 source in s_andn2_wrexec_b64 and s_andn1_wrexec_b64 in the direct C++ compute path.

  • src/gfx1013_direct_compute.inl: one-line wrexec guard change; EXEC (126) dst, M0 (124), odd SGPRs, and inline/literal sources (> 107) still refused with "unsupported wave64 scalar operation". The names exist only in sop1_names[] (opcodes 0x39/0x3A), so no SOP2 encoding can reach the branch.
  • transfer() in src/gfx1013_compute_native.cpp already clears the destination pair and both EXEC words for every *_wrexec_b64 instruction, so a VCC destination resets VCC symbolic state and EXEC symbols are forgotten cleanly; no transfer() change needed. uses_scc_after() already lists both ops in mask_scc, so SCC is overwritten.
  • In-place safety: a (vcc_lo) is read before the branch and ah (vcc_hi), bl (exec_lo), bh (exec_hi) are all read before any write() in the branch, so s_andn*_wrexec_b64 vcc, vcc keeps its original inputs.
  • New test tests/native_wrexec64_vcc_check.py (+ tests/cmake/native_wrexec64_vcc.cmake, _controls and _hardware): 12 wave64 dispatches (VCC dst, VCC src, in-place vcc, vcc; non-zero, zero, high-word-only SCC; active-lane store checks the lane-masking effect on EXEC), 9 refusals (EXEC dst, M0, odd SGPR, inline 0, literal, wave32 model), 5 reference mutants.
  • Updated the two obsolete VCC-source refusals to M0-source refusals (M0 primed with s_mov_b32 m0, 0 so the guard, not require_numeric, refuses): tests/native_saveexec_wrexec_check.py and tests/native_wrexec64_check.py.
  • docs/experiments/native-saveexec-wrexec.md updated.

Linux verification (this host cannot run Windows CTest or compile_dxil):

  • py_compile on touched Python files: pass
  • tests/form_coverage_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py: pass
  • offline harness (12 hand-computed case expectations, program encodings, 9 refusal guard simulations, guard text, layout spot-check): pass; 5/5 spot-mutations on /tmp copies fail as expected, /tmp cleaned up

Windows verification (compile_dxil, native CTest) still pending.

Windows Verification (d4d353d2)

Commit: d4d353d22953382b8cb25ca0ba1f42be6836dfbe (Windows 11 build 26100.7623)
Adapter: NVIDIA GeForce RTX 4050 Laptop GPU (10de:28e1), driver 32.0.15.9186 (D3D12 debug layer not enabled by native_store_replay)
dev:
  cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump
  $env:XBOX2WINDOWS_ADAPTER='NVIDIA'; ctest --preset dev --no-tests=error -R '^(native_wrexec64(_vcc)?_|native_saveexec_wrexec_|native_exec_symbol_b64_)' --output-on-failure
  -> 7/7 passed, 0 failed, 0 skipped (14.30s; all 3 _hardware suites passed on RTX 4050)
Repo checks: form_coverage_check, docs_links_check, bidi_controls_check -> 3/3 passed
AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5546005748 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3421). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-29T00:24:14Z. --- Refs #3224, #2935 Accept VCC (106) as destination and as S0 source in s_andn2_wrexec_b64 and s_andn1_wrexec_b64 in the direct C++ compute path. - src/gfx1013_direct_compute.inl: one-line wrexec guard change; EXEC (126) dst, M0 (124), odd SGPRs, and inline/literal sources (> 107) still refused with "unsupported wave64 scalar operation". The names exist only in sop1_names[] (opcodes 0x39/0x3A), so no SOP2 encoding can reach the branch. - transfer() in src/gfx1013_compute_native.cpp already clears the destination pair and both EXEC words for every *_wrexec_b64 instruction, so a VCC destination resets VCC symbolic state and EXEC symbols are forgotten cleanly; no transfer() change needed. uses_scc_after() already lists both ops in mask_scc, so SCC is overwritten. - In-place safety: a (vcc_lo) is read before the branch and ah (vcc_hi), bl (exec_lo), bh (exec_hi) are all read before any write() in the branch, so s_andn*_wrexec_b64 vcc, vcc keeps its original inputs. - New test tests/native_wrexec64_vcc_check.py (+ tests/cmake/native_wrexec64_vcc.cmake, _controls and _hardware): 12 wave64 dispatches (VCC dst, VCC src, in-place vcc, vcc; non-zero, zero, high-word-only SCC; active-lane store checks the lane-masking effect on EXEC), 9 refusals (EXEC dst, M0, odd SGPR, inline 0, literal, wave32 model), 5 reference mutants. - Updated the two obsolete VCC-source refusals to M0-source refusals (M0 primed with s_mov_b32 m0, 0 so the guard, not require_numeric, refuses): tests/native_saveexec_wrexec_check.py and tests/native_wrexec64_check.py. - docs/experiments/native-saveexec-wrexec.md updated. Linux verification (this host cannot run Windows CTest or compile_dxil): - py_compile on touched Python files: pass - tests/form_coverage_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py: pass - offline harness (12 hand-computed case expectations, program encodings, 9 refusal guard simulations, guard text, layout spot-check): pass; 5/5 spot-mutations on /tmp copies fail as expected, /tmp cleaned up Windows verification (compile_dxil, native CTest) still pending. ### Windows Verification (d4d353d2) ```text Commit: d4d353d22953382b8cb25ca0ba1f42be6836dfbe (Windows 11 build 26100.7623) Adapter: NVIDIA GeForce RTX 4050 Laptop GPU (10de:28e1), driver 32.0.15.9186 (D3D12 debug layer not enabled by native_store_replay) dev: cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump $env:XBOX2WINDOWS_ADAPTER='NVIDIA'; ctest --preset dev --no-tests=error -R '^(native_wrexec64(_vcc)?_|native_saveexec_wrexec_|native_exec_symbol_b64_)' --output-on-failure -> 7/7 passed, 0 failed, 0 skipped (14.30s; all 3 _hardware suites passed on RTX 4050) Repo checks: form_coverage_check, docs_links_check, bidi_controls_check -> 3/3 passed AI-assisted. ``` <!-- WIN-VERIFY: passed | sha=d4d353d22953382b8cb25ca0ba1f42be6836dfbe -->
Leyukaka commented 2026-11-29 04:26:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T04:26:23Z.

Review: APPROVED


Approve d4d353d2. Reviewed by reading the diff and the cited sources; nothing built or run here.

  • src/gfx1013_direct_compute.inl:3892 (same line on main): the wrexec guard now accepts 106 as destination and as S0. 106 decodes as the vcc pair for 64-bit operands (tools/disasm_rdna2.py:81-93), and s_andn1_wrexec_b64 / s_andn2_wrexec_b64 are EXEC = ~S0 & EXEC / EXEC = S0 & ~EXEC, D = EXEC (docs/experiments/native-saveexec-wrexec.md:26, combine_scalar_mask :3877-3880). pair_high (:243-251) already reads 107 for 106. The odd check still refuses 105/107, and 124, 126 and inline/literal sources are still refused.
  • Read-before-write holds: a (:3806), ah (:3896) and both EXEC words (:3898-3901) are loaded before the writes at :3907-3909. For vcc, vcc the only overlap is 107, which is read first.
  • transfer() (src/gfx1013_compute_native.cpp:769-776) already clears the destination pair and both EXEC words for *_wrexec_b64, and uses_scc_after lists both ops (src/gfx1013_direct_compute.inl:2738).
  • On main, tests/native_saveexec_wrexec_check.py:295 and tests/native_wrexec64_check.py:90 asserted the VCC-source refusal. The PR retargets both to a primed m0, which fails the same guard with the same message. No other test asserts that refusal.
  • Expected values in tests/native_wrexec64_vcc_check.py:133-148 check out (for example SRC_A & ~EXEC_A = (0x84, 0x80000020) and ~SRC_A & EXEC_A = (0x12, 0x8), plus the zero and high-word-only rows). The incoming SCC is primed to the opposite value, and the destination starts as a sentinel except in the in-place rows.
  • Mutants, by reading only: dropping or moving either 106 exemption, or dropping the odd or source clause, fails _controls (compile or message mismatch). Two mutants survive because no case covers them: accepting exec as the source and accepting m0 as the destination.
  • CI passes, but it does not run these tests: the pr preset filter (CMakePresets.json:51) has none of them, and the dev ctest line excludes _hardware$ (.github/workflows/windows.yml:498). The evidence is the author's run in the PR body (7/7 at this head, including the 3 _hardware suites).
  • git merge-tree against main (212d4b5f) is clean.

Non-blocking:

  • Add a refusal case for m0 as destination, for example (64, init + [sop1(ANDN2_WREXEC_B64, M0, 22), END], error) in refused_programs() (:163). Without it a guard that also exempts 124 for i.dst passes every test and writes 124/125.
  • _controls only checks for and i32, xor i32 and icmp ne i32 (:191). active() (src/gfx1013_direct_compute.inl:148-152) emits and and icmp ne for every store, and both ops emit the xor, so these checks cannot tell andn1 from andn2; only _hardware can. The 5 "reference mutants" (:202-210) mutate the Python reference, not the C++.
  • In the vcc inplace rows (:139-140) the only register shared by the reads and the writes is 107, and hi is computed from it, so no reordering of the lowering changes their result. They catch a missing write, like the vcc dst rows, and nothing more.
  • The guard also opens VCC to s_andn2_wrexec_b64 in the narrow wave64 model (:3889, a wave64 request of at most 32 threads), and no VCC case covers it: every new row uses 64 threads. In that model write_ballot stores only the low word of a VCC destination (:235-236), the same limitation SGPR pairs already have (src/gfx1013_compute_native.cpp:1840-1843). One 32-thread VCC row would cover it.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101394174 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3421#pullrequestreview-6101394174). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T04:26:23Z. **Review:** APPROVED --- Approve `d4d353d2`. Reviewed by reading the diff and the cited sources; nothing built or run here. - `src/gfx1013_direct_compute.inl:3892` (same line on `main`): the wrexec guard now accepts 106 as destination and as S0. 106 decodes as the `vcc` pair for 64-bit operands (`tools/disasm_rdna2.py:81-93`), and `s_andn1_wrexec_b64` / `s_andn2_wrexec_b64` are `EXEC = ~S0 & EXEC` / `EXEC = S0 & ~EXEC`, `D = EXEC` (`docs/experiments/native-saveexec-wrexec.md:26`, `combine_scalar_mask` `:3877-3880`). `pair_high` (`:243-251`) already reads 107 for 106. The odd check still refuses 105/107, and 124, 126 and inline/literal sources are still refused. - Read-before-write holds: `a` (`:3806`), `ah` (`:3896`) and both EXEC words (`:3898-3901`) are loaded before the writes at `:3907-3909`. For `vcc, vcc` the only overlap is 107, which is read first. - `transfer()` (`src/gfx1013_compute_native.cpp:769-776`) already clears the destination pair and both EXEC words for `*_wrexec_b64`, and `uses_scc_after` lists both ops (`src/gfx1013_direct_compute.inl:2738`). - On `main`, `tests/native_saveexec_wrexec_check.py:295` and `tests/native_wrexec64_check.py:90` asserted the VCC-source refusal. The PR retargets both to a primed `m0`, which fails the same guard with the same message. No other test asserts that refusal. - Expected values in `tests/native_wrexec64_vcc_check.py:133-148` check out (for example `SRC_A & ~EXEC_A = (0x84, 0x80000020)` and `~SRC_A & EXEC_A = (0x12, 0x8)`, plus the zero and high-word-only rows). The incoming SCC is primed to the opposite value, and the destination starts as a sentinel except in the in-place rows. - Mutants, by reading only: dropping or moving either 106 exemption, or dropping the odd or source clause, fails `_controls` (compile or message mismatch). Two mutants survive because no case covers them: accepting `exec` as the source and accepting `m0` as the destination. - CI passes, but it does not run these tests: the `pr` preset filter (`CMakePresets.json:51`) has none of them, and the `dev` ctest line excludes `_hardware$` (`.github/workflows/windows.yml:498`). The evidence is the author's run in the PR body (7/7 at this head, including the 3 `_hardware` suites). - `git merge-tree` against `main` (`212d4b5f`) is clean. Non-blocking: - Add a refusal case for `m0` as destination, for example `(64, init + [sop1(ANDN2_WREXEC_B64, M0, 22), END], error)` in `refused_programs()` (`:163`). Without it a guard that also exempts 124 for `i.dst` passes every test and writes 124/125. - `_controls` only checks for `and i32`, `xor i32` and `icmp ne i32` (`:191`). `active()` (`src/gfx1013_direct_compute.inl:148-152`) emits `and` and `icmp ne` for every store, and both ops emit the `xor`, so these checks cannot tell andn1 from andn2; only `_hardware` can. The 5 "reference mutants" (`:202-210`) mutate the Python reference, not the C++. - In the `vcc inplace` rows (`:139-140`) the only register shared by the reads and the writes is 107, and `hi` is computed from it, so no reordering of the lowering changes their result. They catch a missing write, like the `vcc dst` rows, and nothing more. - The guard also opens VCC to `s_andn2_wrexec_b64` in the narrow wave64 model (`:3889`, a wave64 request of at most 32 threads), and no VCC case covers it: every new row uses 64 threads. In that model `write_ballot` stores only the low word of a VCC destination (`:235-236`), the same limitation SGPR pairs already have (`src/gfx1013_compute_native.cpp:1840-1843`). One 32-thread VCC row would cover it.
tedin7 commented 2026-11-29 08:26:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-29T08:26:02Z.

Review: COMMENTED


Reviewed d4d353d229dd0e38c2b7fb83b7b03596992bd6cb:

Running the targeted tests on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) failed in both Debug and Release:

  • ctest --preset dev -R '^(native_wrexec64|native_saveexec_wrexec)' --parallel 2 --no-tests=error --output-on-failure: 5/6 passed, 1 failed (native_wrexec64_vcc_controls, native_wrexec64_vcc_hardware, native_wrexec64, native_saveexec_wrexec_ir, and native_saveexec_wrexec_controls passed; native_saveexec_wrexec_hardware failed with AssertionError: ('w32_andn1_z', [(265, '0x69696969', '0xa5'), ...])).
  • ctest --preset release -R '^(native_wrexec64|native_saveexec_wrexec)' --parallel 2 --no-tests=error --output-on-failure: 5/6 passed, 1 failed (same failure in native_saveexec_wrexec_hardware).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6102076230 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3421#pullrequestreview-6102076230). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-29T08:26:02Z. **Review:** COMMENTED --- Reviewed `d4d353d229dd0e38c2b7fb83b7b03596992bd6cb`: Running the targeted tests on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) failed in both Debug and Release: - `ctest --preset dev -R '^(native_wrexec64|native_saveexec_wrexec)' --parallel 2 --no-tests=error --output-on-failure`: **5/6 passed, 1 failed** (`native_wrexec64_vcc_controls`, `native_wrexec64_vcc_hardware`, `native_wrexec64`, `native_saveexec_wrexec_ir`, and `native_saveexec_wrexec_controls` passed; `native_saveexec_wrexec_hardware` failed with `AssertionError: ('w32_andn1_z', [(265, '0x69696969', '0xa5'), ...])`). - `ctest --preset release -R '^(native_wrexec64|native_saveexec_wrexec)' --parallel 2 --no-tests=error --output-on-failure`: **5/6 passed, 1 failed** (same failure in `native_saveexec_wrexec_hardware`). 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!3421
No description provided.