Recompiler: close four wave64-on-wave32 partition classifier soundness holes #2122

Open
github-bot wants to merge 1 commit from github-bot/gh-2122 into main AGit
Owner

@⁠Decodere on GitHub · 2026-11-25 05:13 UTC · original
Decodere:fix-336-partition-soundness → main · +215 −23 · 1 files · 1 commits · open

What is in it
Closes four soundness holes in the wave64-on-wave32 partition classifier (crates/xcl/src/gpu/recomp/partition.rs) where cut-dependent shaders were misclassified as Tier::Exact:

  • Per-lane mask taint & SRC2 handling (uses(), source_taint(), step()):
    • Propagates taint bits from u.lane_mask in step() so V_CNDMASK_B32 / V_ADD_CO_CI_U32 / V_SUB_CO_CI_U32 / V_SUBREV_CO_CI_U32 no longer drop LANE_ID / mask taint from their mask operand.
    • Distinguishes VOP3 SRC2 presence in uses(): decodes valid SGPR pairs including EXEC (126), excludes M0 (124) / NULL (125) / constants instead of mis-mapping them to VCC, and falls back to [VCC, VCC + 1] only for VOP2 forms without SRC2.
    • Flags non-lane selectors/carries on those four ops with MASK_DATA in source_taint() unless SRC2 is 0 / -1 / null (125 | 128 | 193) or a tracked st.lanes SGPR pair (or tracked VCC for VOP2).
  • WREXEC lane-set check (source_taint()): Includes n.contains("WREXEC") alongside SAVEEXEC in the bitwise lane-set check (and treats 125 null as a zero lane set), catching S_ANDN1_WREXEC_B64 / S_ANDN2_WREXEC_B64 with non-lane operands as mask-data.
  • Non-lane EXEC writes (step()): Computes lane_src / lanes_made (including checking SDST for S_CMOV_B*) before the writes_exec sink check, flagging any non-lane write to EXEC (e.g. S_MOV_B64 exec, s[0:1] where s[0:1] holds a number, S_CSELECT_B64 exec, 1, 0, S_CMOV_B64 exec, 1, S_NOT_B64 exec, 1) and single-word EXEC writes with MASK_DATA (both recording "mask-data" and tainting EXEC).
  • Complement SAVEEXEC & non-mask S_ANDN2* uniformity (step()): Replaces || n.contains("SAVEEXEC") in keeps_uniform with an explicit allowlist of non-complement ops (excluding S_NOR/S_NAND/S_XNOR/S_ORN1/S_ORN2/S_XOR_SAVEEXEC_B64), and requires S_ANDN2_* SSRC0 to be zero (125 | 128) or a tracked mask SGPR pair (st.mask[s] && st.mask[s + 1]) rather than -1 or a non-mask SGPR.
  • Adds 4 unit tests (with counter-examples and positive controls) in gpu::recomp::partition::tests.

Part of #336

Tested
Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC 1.9.2609.5 (01b62ad4).

  • Failing-first pre-fix check (cargo test -j 4 -p xcl --lib gpu::recomp::partition::tests -- --nocapture): 44 passed, 4 failed — all 4 new counter-example tests (lane_mask_taint_and_non_lane_selectors_are_caught, wrexec_with_non_lane_operand_is_mask_data, non_lane_exec_writes_are_mask_data, complement_saveexec_and_andn2_with_non_mask_are_not_uniform) returned [] (Tier::Exact) pre-fix.
  • Post-fix targeted tests (cargo test --release -p xcl --lib gpu::recomp::partition::tests -- --nocapture): 48 passed, 0 failed (pure CPU unit tests, CI WARP-safe).
  • Full release workspace build & test (cargo build --release --workspace and cargo test --release --workspace -- --test-threads=4 --nocapture): 1,158 passed, 0 failed, 46 ignored across 21 test binaries (1102 in xcl lib, 56 across the remaining 20 binaries), with 27 SKIPPED lines on this RTX 4060:
    • 20 no wave64 (RTX 4060 is wave32-only)
    • 3 per-lane form: refused (wave32 f16 arithmetic, f16 packed, f32 conversions)
    • 2 no d3d12SDKLayers.dll / no D3D12 debug layer
    • 1 cannot disable the driver cache (Windows Developer Mode not enabled)
    • 1 no heap windows

Regression run
Paired 60 s runs via scripts/smoke.ps1 on clean origin/main (f5c5bdf0) and clean PR head (ddcda018):

Main (f5c5bdf0e91035f8f1404f46f4f2f7aedc259e7f):

xcl-smoke v1
commit: f5c5bdf0e91035f8f1404f46f4f2f7aedc259e7f
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14486 MB

PR (ddcda0184c4fb347a1546f9c61be127c70795713):

xcl-smoke v1
commit: ddcda0184c4fb347a1546f9c61be127c70795713
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1586)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14522 MB

Not tested

  • Native wave64 GPU execution (20 no wave64 skips on RTX 4060), D3D12 debug layer tests (2 skips without d3d12SDKLayers.dll), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip without XCL_HEAP_WINDOWS).
  • Retail titles other than title: 29640639, and partition::classify is classification-only (not yet wired into runtime translation).

AI use
Google Antigravity (Gemini 4 Neon) wrote the partition.rs soundness fixes, unit tests, and this PR description. All pre-fix/post-fix unit tests, full release workspace tests, paired 60 s smoke runs, and scripts/pr_check.py --local validation were run locally on this machine.

**@⁠Decodere** on GitHub · 2026-11-25 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/2122) `Decodere:fix-336-partition-soundness` → `main` · +215 −23 · 1 files · 1 commits · open **What is in it** Closes four soundness holes in the wave64-on-wave32 partition classifier (`crates/xcl/src/gpu/recomp/partition.rs`) where cut-dependent shaders were misclassified as `Tier::Exact`: - **Per-lane mask taint & `SRC2` handling (`uses()`, `source_taint()`, `step()`):** - Propagates taint bits from `u.lane_mask` in `step()` so `V_CNDMASK_B32` / `V_ADD_CO_CI_U32` / `V_SUB_CO_CI_U32` / `V_SUBREV_CO_CI_U32` no longer drop `LANE_ID` / mask taint from their mask operand. - Distinguishes VOP3 `SRC2` presence in `uses()`: decodes valid SGPR pairs including `EXEC` (`126`), excludes `M0` (`124`) / `NULL` (`125`) / constants instead of mis-mapping them to `VCC`, and falls back to `[VCC, VCC + 1]` only for VOP2 forms without `SRC2`. - Flags non-lane selectors/carries on those four ops with `MASK_DATA` in `source_taint()` unless `SRC2` is `0` / `-1` / `null` (`125 | 128 | 193`) or a tracked `st.lanes` SGPR pair (or tracked `VCC` for VOP2). - **`WREXEC` lane-set check (`source_taint()`):** Includes `n.contains("WREXEC")` alongside `SAVEEXEC` in the bitwise lane-set check (and treats `125` `null` as a zero lane set), catching `S_ANDN1_WREXEC_B64` / `S_ANDN2_WREXEC_B64` with non-lane operands as `mask-data`. - **Non-lane `EXEC` writes (`step()`):** Computes `lane_src` / `lanes_made` (including checking `SDST` for `S_CMOV_B*`) before the `writes_exec` sink check, flagging any non-lane write to `EXEC` (e.g. `S_MOV_B64 exec, s[0:1]` where `s[0:1]` holds a number, `S_CSELECT_B64 exec, 1, 0`, `S_CMOV_B64 exec, 1`, `S_NOT_B64 exec, 1`) and single-word `EXEC` writes with `MASK_DATA` (both recording `"mask-data"` and tainting `EXEC`). - **Complement `SAVEEXEC` & non-mask `S_ANDN2*` uniformity (`step()`):** Replaces `|| n.contains("SAVEEXEC")` in `keeps_uniform` with an explicit allowlist of non-complement ops (excluding `S_NOR`/`S_NAND`/`S_XNOR`/`S_ORN1`/`S_ORN2`/`S_XOR_SAVEEXEC_B64`), and requires `S_ANDN2_*` `SSRC0` to be zero (`125 | 128`) or a tracked mask SGPR pair (`st.mask[s] && st.mask[s + 1]`) rather than `-1` or a non-mask SGPR. - Adds 4 unit tests (with counter-examples and positive controls) in `gpu::recomp::partition::tests`. Part of #336 **Tested** Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC `1.9.2609.5` (`01b62ad4`). - Failing-first pre-fix check (`cargo test -j 4 -p xcl --lib gpu::recomp::partition::tests -- --nocapture`): 44 passed, 4 failed — all 4 new counter-example tests (`lane_mask_taint_and_non_lane_selectors_are_caught`, `wrexec_with_non_lane_operand_is_mask_data`, `non_lane_exec_writes_are_mask_data`, `complement_saveexec_and_andn2_with_non_mask_are_not_uniform`) returned `[]` (`Tier::Exact`) pre-fix. - Post-fix targeted tests (`cargo test --release -p xcl --lib gpu::recomp::partition::tests -- --nocapture`): 48 passed, 0 failed (pure CPU unit tests, CI WARP-safe). - Full release workspace build & test (`cargo build --release --workspace` and `cargo test --release --workspace -- --test-threads=4 --nocapture`): 1,158 passed, 0 failed, 46 ignored across 21 test binaries (`1102` in `xcl` lib, `56` across the remaining 20 binaries), with 27 `SKIPPED` lines on this RTX 4060: - 20 `no wave64` (RTX 4060 is wave32-only) - 3 `per-lane form: refused` (wave32 f16 arithmetic, f16 packed, f32 conversions) - 2 `no d3d12SDKLayers.dll` / `no D3D12 debug layer` - 1 `cannot disable the driver cache` (Windows Developer Mode not enabled) - 1 `no heap windows` **Regression run** Paired 60 s runs via `scripts/smoke.ps1` on clean `origin/main` (`f5c5bdf0`) and clean PR head (`ddcda018`): Main (`f5c5bdf0e91035f8f1404f46f4f2f7aedc259e7f`): ``` xcl-smoke v1 commit: f5c5bdf0e91035f8f1404f46f4f2f7aedc259e7f gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1536 (PresentX 1536) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14486 MB ``` PR (`ddcda0184c4fb347a1546f9c61be127c70795713`): ``` xcl-smoke v1 commit: ddcda0184c4fb347a1546f9c61be127c70795713 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1586 (PresentX 1586) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14522 MB ``` **Not tested** - Native wave64 GPU execution (20 `no wave64` skips on RTX 4060), D3D12 debug layer tests (2 skips without `d3d12SDKLayers.dll`), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip without `XCL_HEAP_WINDOWS`). - Retail titles other than `title: 29640639`, and `partition::classify` is classification-only (not yet wired into runtime translation). **AI use** Google Antigravity (Gemini 4 Neon) wrote the `partition.rs` soundness fixes, unit tests, and this PR description. All pre-fix/post-fix unit tests, full release workspace tests, paired 60 s smoke runs, and `scripts/pr_check.py --local` validation were run locally on this machine.
Tighten crates/xcl/src/gpu/recomp/partition.rs so cut-dependent shaders
cannot be misclassified as Tier::Exact:
- Propagate taint from u.lane_mask in step(), decode VOP3 SRC2 properly
  (supporting EXEC = 126 without mis-mapping constants/NULL to VCC), and
  flag non-lane selectors/carries on V_CNDMASK_B32 / V_*_CO_CI_U32 with
  MASK_DATA.
- Include WREXEC alongside SAVEEXEC in source_taint()'s bitwise lane-set
  check and treat NULL (125) as a zero lane set.
- Generalize non-lane EXEC write detection in step() using lanes_made
  (including S_CMOV_B destination checks) and taint EXEC on non-lane or
  single-word EXEC writes.
- Restrict keeps_uniform to non-complement mask ops (excluding NOR/NAND/
  XNOR/ORN1/ORN2/XOR SAVEEXEC) and require S_ANDN2_* SSRC0 to be zero or
  a tracked mask SGPR pair.

Part of #336

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:45 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 06:18 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 06:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2122#issuecomment-7154661293) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun. Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2122/head:github-bot/gh-2122'
git switch 'github-bot/gh-2122'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2122'
git switch 'github-bot/gh-2122'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2122'
git switch 'github-bot/gh-2122'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2122'
git switch 'main'
git merge --squash 'github-bot/gh-2122'
git switch 'main'
git merge --ff-only 'github-bot/gh-2122'
git switch 'main'
git merge 'github-bot/gh-2122'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.