Recompiler: include RMW destination reads in rdna2::vgpr_uses and sgpr_uses #2134

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

@⁠Decodere on GitHub · 2026-11-25 05:42 UTC · original
Decodere:fix-336-rdna2-rmw-uses → main · +124 −1 · 1 files · 1 commits · open

What is in it
Tracks implicit read-modify-write (RMW) destination reads in rdna2::vgpr_uses() and rdna2::sgpr_uses() (crates/xcl/src/gpu/rdna2.rs) for RDNA2 instructions whose ISA table marks VDST/SDST as input: false, output: true:

  • In vgpr_uses(): extends the RMW accumulator list (V_FMAC_F32 / V_MAC_F32 / V_FMAC_LEGACY_F32) to include V_FMAC_F16, V_PK_FMAC_F16, V_DOT2C_F32_F16, and V_DOT4C_I32_I8. Previously, recomp::partition::classify wiped LANE_ID taint accumulated into VDST by those four instructions and falsely classified wave-cut-dependent shaders as Tier::Exact. (V_WRITELANE_B32 is intentionally not added, preserving mesh_wave.rs's vgpr_reads.first() == None expectation.)
  • In sgpr_uses(): appends w to r for S_CMOV* (S_CMOV_B32, S_CMOV_B64, S_CMOVK_I32), S_ADDK_I32, S_MULK_I32, S_BITSET0_B32, S_BITSET0_B64, S_BITSET1_B32, and S_BITSET1_B64 (matching x64_masks::keeps_destination, with NULL 125 already excluded from w). Previously, recomp::mesh_wave::analyze wiped mask taint on SDST across those scalar RMW ops and dropped mask-derived S_CBRANCH_SCC* branches from mask_scc_branches.
  • Adds 3 unit tests in gpu::rdna2::tests covering direct vgpr_uses (all 4 vector accumulators + negative controls including V_DOT2_F32_F16, V_ADD_NC_U32, V_WRITELANE_B32), direct sgpr_uses (all 9 scalar RMW ops, NULL 125, and plain overwrites), and end-to-end taint propagation through recomp::partition::classify and recomp::mesh_wave::analyze.

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::rdna2::tests::rmw_ -- --nocapture): 0 passed, 3 failed (V_FMAC_F16 omitted VDST from vgpr_uses reads, S_ADDK_I32 omitted SDST from sgpr_uses reads, and partition::classify returned Tier::Exact on V_MBCNT_LO_U32_B32 -> V_FMAC_F16 -> EXP).
  • Post-fix targeted CPU tests: gpu::rdna2::tests 20 passed / 0 failed (debug & --release), gpu::recomp::partition::tests 44 passed / 0 failed, gpu::recomp::mesh_wave::tests 13 passed / 0 failed (pure CPU tests, CI WARP-safe).
  • Full release workspace build & test (cargo build --release --workspace and cargo test --release --workspace -- --test-threads=4 --nocapture): 1,157 passed, 0 failed, 46 ignored across 21 test binaries (1101 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 (6020a33b) and clean PR head (5ea738c9):

Main (6020a33b16ba2de25b3aef5947552f2dc1831f09):

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

PR (5ea738c9377b677733621fa33e85f11f386b962c):

xcl-smoke v1
commit: 5ea738c9377b677733621fa33e85f11f386b962c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1556 (PresentX 1557)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14523 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 / mesh_wave::analyze are analysis passes not yet wired into runtime translation).

AI use
Google Antigravity (Gemini 4 Neon) wrote the rdna2::vgpr_uses/sgpr_uses 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:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2134) `Decodere:fix-336-rdna2-rmw-uses` → `main` · +124 −1 · 1 files · 1 commits · open **What is in it** Tracks implicit read-modify-write (RMW) destination reads in `rdna2::vgpr_uses()` and `rdna2::sgpr_uses()` (`crates/xcl/src/gpu/rdna2.rs`) for RDNA2 instructions whose ISA table marks `VDST`/`SDST` as `input: false, output: true`: - In `vgpr_uses()`: extends the RMW accumulator list (`V_FMAC_F32` / `V_MAC_F32` / `V_FMAC_LEGACY_F32`) to include `V_FMAC_F16`, `V_PK_FMAC_F16`, `V_DOT2C_F32_F16`, and `V_DOT4C_I32_I8`. Previously, `recomp::partition::classify` wiped `LANE_ID` taint accumulated into `VDST` by those four instructions and falsely classified wave-cut-dependent shaders as `Tier::Exact`. (`V_WRITELANE_B32` is intentionally not added, preserving `mesh_wave.rs`'s `vgpr_reads.first() == None` expectation.) - In `sgpr_uses()`: appends `w` to `r` for `S_CMOV*` (`S_CMOV_B32`, `S_CMOV_B64`, `S_CMOVK_I32`), `S_ADDK_I32`, `S_MULK_I32`, `S_BITSET0_B32`, `S_BITSET0_B64`, `S_BITSET1_B32`, and `S_BITSET1_B64` (matching `x64_masks::keeps_destination`, with `NULL` `125` already excluded from `w`). Previously, `recomp::mesh_wave::analyze` wiped mask taint on `SDST` across those scalar RMW ops and dropped mask-derived `S_CBRANCH_SCC*` branches from `mask_scc_branches`. - Adds 3 unit tests in `gpu::rdna2::tests` covering direct `vgpr_uses` (all 4 vector accumulators + negative controls including `V_DOT2_F32_F16`, `V_ADD_NC_U32`, `V_WRITELANE_B32`), direct `sgpr_uses` (all 9 scalar RMW ops, `NULL` `125`, and plain overwrites), and end-to-end taint propagation through `recomp::partition::classify` and `recomp::mesh_wave::analyze`. 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::rdna2::tests::rmw_ -- --nocapture`): 0 passed, 3 failed (`V_FMAC_F16` omitted `VDST` from `vgpr_uses` reads, `S_ADDK_I32` omitted `SDST` from `sgpr_uses` reads, and `partition::classify` returned `Tier::Exact` on `V_MBCNT_LO_U32_B32` -> `V_FMAC_F16` -> `EXP`). - Post-fix targeted CPU tests: `gpu::rdna2::tests` 20 passed / 0 failed (debug & `--release`), `gpu::recomp::partition::tests` 44 passed / 0 failed, `gpu::recomp::mesh_wave::tests` 13 passed / 0 failed (pure CPU tests, CI WARP-safe). - Full release workspace build & test (`cargo build --release --workspace` and `cargo test --release --workspace -- --test-threads=4 --nocapture`): 1,157 passed, 0 failed, 46 ignored across 21 test binaries (`1101` 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` (`6020a33b`) and clean PR head (`5ea738c9`): Main (`6020a33b16ba2de25b3aef5947552f2dc1831f09`): ``` xcl-smoke v1 commit: 6020a33b16ba2de25b3aef5947552f2dc1831f09 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1583 (PresentX 1583) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14516 MB ``` PR (`5ea738c9377b677733621fa33e85f11f386b962c`): ``` xcl-smoke v1 commit: 5ea738c9377b677733621fa33e85f11f386b962c gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1556 (PresentX 1557) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14523 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` / `mesh_wave::analyze` are analysis passes not yet wired into runtime translation). **AI use** Google Antigravity (Gemini 4 Neon) wrote the `rdna2::vgpr_uses`/`sgpr_uses` 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.
Track implicit destination reads for RDNA2 read-modify-write instructions
whose ISA spec marks VDST/SDST as output-only:
- In vgpr_uses(), include V_FMAC_F16, V_PK_FMAC_F16, V_DOT2C_F32_F16,
  and V_DOT4C_I32_I8 alongside V_FMAC_F32 / V_MAC_F32 / V_FMAC_LEGACY_F32
  so partition::classify preserves accumulator taint.
- In sgpr_uses(), include S_CMOV* (S_CMOV_B32/B64, S_CMOVK_I32),
  S_ADDK_I32, S_MULK_I32, and S_BITSET0/1_B32/B64 (matching
  x64_masks::keeps_destination) so mesh_wave::analyze preserves mask
  taint on RMW scalar destinations (while keeping NULL 125 excluded).

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:20:09 +00:00
Author
Owner

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

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (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:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2134#issuecomment-7154900057) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (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/2134/head:github-bot/gh-2134'
git switch 'github-bot/gh-2134'

Merge

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