Recompiler: tighten operand and EXEC checks in wave32_reductions #2355

Closed
Decodere wants to merge 1 commit from upstream-pr/2365 into main
Decodere commented 2026-11-25 16:47:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T16:47:17Z.


Part of #1401

Follow-up to 12f25f1 (crates/xcl/src/gpu/recomp/mod.rs).

wave32_reductions replaces the console compiler's wave32 whole-wave reduction sequence with xcl_red_<op>(xcl_seed_<pc>) so waves that are not full still reduce every live lane. Several operand, mask, and EXEC-clobber checks were too loose and could rewrite non-reduction code or sequences whose EXEC was modified mid-section.

What is in it

  • wave32_reductions (crates/xcl/src/gpu/recomp/mod.rs):
    • Require both VGPR operands of each DPP8 (a, b, c) and DPP16 (mirror) step to be v (r == [v, v]), plus mirror ROW_MASK & 0x3 == 0x3 and BANK_MASK == 0xF.
    • Require cross (V_PERMLANEX16_B32) to be Variant::Plain with SRC0 == 256 + v and single destination cw != v; require last to be Variant::Plain writing [v] with inputs strictly {v, cw} (lr == [v, cw] || lr == [cw, v]); and require read (V_READLANE_B32) to be Variant::Plain with SRC0 == 256 + v and SRC1 == 128.
    • Reject open (S_OR_SAVEEXEC_B32) when SDST is in 126..=127 (EXEC_LO / EXEC_HI), and reject any instruction in open + 1..=end that branches/jumps/terminates (F_TERMINATOR | F_BRANCH | F_INDIRECT) or writes EXEC — including implicit OPR_EXEC / OPR_SDST_EXEC outputs (V_CMPX_*, S_*_SAVEEXEC_*, S_ANDN{1,2}_WREXEC_*, S_SUBVECTOR_LOOP_*), explicit SGPR/VOP3/SMEM destinations in 126..=127 (sgpr_uses + ENC_SMEM SDATA), and ENC_VOPC SDWA compare writes to 126..=127.
  • wave32_reduction_tests (crates/xcl/src/gpu/recomp/mod.rs): 2 pure-CPU unit tests covering all 4 valid reduction ops (or / max / and / min) across ROW_MASK 0xF/0x3, both last operand orders, and wave32 PS/VS translate() emission, plus 19 invalid/clobbered shapes verified to be rejected by both wave32_reductions and translate().

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 build 26200, rustc 1.100.0, DXC 1.9.2609.5, release profile (--release).
  • Failing-first (before fix): cargo test --release -p xcl --lib gpu::recomp::wave32_reduction_tests:: -- --nocapture: 1 passed, 1 failed (invalid_wave32_reduction_shapes_and_exec_writes_are_rejected failed on origin/main).
  • Targeted unit tests (after fix): cargo test --release -p xcl --lib gpu::recomp::wave32_reduction_tests:: -- --nocapture: 2 passed, 0 failed, 0 ignored (0.01 s).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1286 passed, 0 failed, 46 ignored across 23 test binaries (28 pre-existing SKIPPED lines: 21 no wave64 on RTX 4060, 3 per-lane wave32 refused, 2 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in gpu::recomp::wave32_reduction_tests).

Regression run

main:

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

PR:

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

Not tested

  • AMD / native wave64 hardware and D3D12 debug-layer test subsets (skipped on this RTX 4060 / non-debug-layer host; wave32_reductions is pure-CPU static RDNA2 analysis in the recompiler).
  • Retail titles other than title: 29640639.

AI use

  • Google Antigravity (Gemini 4 Neon) — audited wave32_reductions, rdna2_spec.rs, and emit.rs, implemented the tightened operand/mask/EXEC checks and failing-first unit tests, and ran the workspace and paired smoke verification.
<!-- greyfinch-sync:ivall/xcl:issue:5495406419 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-25T16:47:17Z. --- Part of #1401 Follow-up to `12f25f1` (`crates/xcl/src/gpu/recomp/mod.rs`). `wave32_reductions` replaces the console compiler's wave32 whole-wave reduction sequence with `xcl_red_<op>(xcl_seed_<pc>)` so waves that are not full still reduce every live lane. Several operand, mask, and `EXEC`-clobber checks were too loose and could rewrite non-reduction code or sequences whose `EXEC` was modified mid-section. **What is in it** - `wave32_reductions` (`crates/xcl/src/gpu/recomp/mod.rs`): - Require both VGPR operands of each DPP8 (`a`, `b`, `c`) and DPP16 (`mirror`) step to be `v` (`r == [v, v]`), plus `mirror` `ROW_MASK & 0x3 == 0x3` and `BANK_MASK == 0xF`. - Require `cross` (`V_PERMLANEX16_B32`) to be `Variant::Plain` with `SRC0 == 256 + v` and single destination `cw != v`; require `last` to be `Variant::Plain` writing `[v]` with inputs strictly `{v, cw}` (`lr == [v, cw] || lr == [cw, v]`); and require `read` (`V_READLANE_B32`) to be `Variant::Plain` with `SRC0 == 256 + v` and `SRC1 == 128`. - Reject `open` (`S_OR_SAVEEXEC_B32`) when `SDST` is in `126..=127` (`EXEC_LO` / `EXEC_HI`), and reject any instruction in `open + 1..=end` that branches/jumps/terminates (`F_TERMINATOR | F_BRANCH | F_INDIRECT`) or writes `EXEC` — including implicit `OPR_EXEC` / `OPR_SDST_EXEC` outputs (`V_CMPX_*`, `S_*_SAVEEXEC_*`, `S_ANDN{1,2}_WREXEC_*`, `S_SUBVECTOR_LOOP_*`), explicit SGPR/VOP3/SMEM destinations in `126..=127` (`sgpr_uses` + `ENC_SMEM` `SDATA`), and `ENC_VOPC` SDWA compare writes to `126..=127`. - `wave32_reduction_tests` (`crates/xcl/src/gpu/recomp/mod.rs`): 2 pure-CPU unit tests covering all 4 valid reduction ops (`or` / `max` / `and` / `min`) across `ROW_MASK` `0xF`/`0x3`, both `last` operand orders, and wave32 PS/VS `translate()` emission, plus 19 invalid/clobbered shapes verified to be rejected by both `wave32_reductions` and `translate()`. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 4060 8 GB (driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 build 26200, `rustc 1.100.0`, DXC `1.9.2609.5`, release profile (`--release`). - Failing-first (before fix): `cargo test --release -p xcl --lib gpu::recomp::wave32_reduction_tests:: -- --nocapture`: 1 passed, 1 failed (`invalid_wave32_reduction_shapes_and_exec_writes_are_rejected` failed on `origin/main`). - Targeted unit tests (after fix): `cargo test --release -p xcl --lib gpu::recomp::wave32_reduction_tests:: -- --nocapture`: 2 passed, 0 failed, 0 ignored (`0.01 s`). - `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture`: 1286 passed, 0 failed, 46 ignored across 23 test binaries (28 pre-existing `SKIPPED` lines: 21 no wave64 on RTX 4060, 3 per-lane wave32 refused, 2 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in `gpu::recomp::wave32_reduction_tests`). **Regression run** main: ``` xcl-smoke v1 commit: 55d64c277be137cb6b47d7528dc6a88082bf573e gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1523 (PresentX 1523) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14000 MB ``` PR: ``` xcl-smoke v1 commit: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1429 (PresentX 1429) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14033 MB ``` **Not tested** - AMD / native wave64 hardware and D3D12 debug-layer test subsets (skipped on this RTX 4060 / non-debug-layer host; `wave32_reductions` is pure-CPU static RDNA2 analysis in the recompiler). - Retail titles other than `title: 29640639`. **AI use** - Google Antigravity (Gemini 4 Neon) — audited `wave32_reductions`, `rdna2_spec.rs`, and `emit.rs`, implemented the tightened operand/mask/`EXEC` checks and failing-first unit tests, and ran the workspace and paired smoke verification.
emirduran707 commented 2026-11-25 18:04:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T17:37:37Z.


Independent AMD RDNA4 (native wave64) test report on exact head f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1284 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed: gpu::recomp::wave32_reduction_tests::valid_wave32_reductions_match_and_translate and invalid_wave32_reduction_shapes_and_exec_writes_are_rejected.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1619 (PresentX 1619)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14455 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7169772390 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7169772390). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-25T17:37:37Z. --- Independent AMD RDNA4 (native wave64) test report on exact head `f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1284 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - Both PR tests passed: `gpu::recomp::wave32_reduction_tests::valid_wave32_reductions_match_and_translate` and `invalid_wave32_reduction_shapes_and_exec_writes_are_rejected`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1619 (PresentX 1619) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14455 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
DavidM1911 commented 2026-11-25 19:09:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:50:19Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7171470261 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7171470261). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T18:50:19Z. --- 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!
SlopTart commented 2026-11-25 19:09:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T19:06:05Z.


Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).
suite: 145/3 = the three known baseline failures on this lane (fuzz_validate_and_gpu_2 seed 1003, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed) (this head's new gpu_ wave32 f16/f32 min/max reduction tests are among the passes). Targeted run of the new invalid-wave32-reduction fuzz: passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7171820054 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7171820054). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T19:06:05Z. --- **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). suite: 145/3 = the three known baseline failures on this lane (`fuzz_validate_and_gpu_2` seed 1003, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`) (this head's new gpu_ wave32 f16/f32 min/max reduction tests are among the passes). Targeted run of the new invalid-wave32-reduction fuzz: passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
bmjask commented 2026-11-25 20:24:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:24:38Z.

Review: COMMENTED


No concrete defect found. The recognizer validates the relevant DPP/permlane/readlane shapes and expanded EXEC-write cases; unit coverage is broad and current Windows CI plus the RTX smoke pair are green. Residual validation is the disclosed lack of AMD/native-wave64 testing, but the changed recognizer is CPU-side static analysis. I found no blocker.

<!-- greyfinch-sync:ivall/xcl:review:6064444879 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#pullrequestreview-6064444879). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:24:38Z. **Review:** COMMENTED --- No concrete defect found. The recognizer validates the relevant DPP/permlane/readlane shapes and expanded EXEC-write cases; unit coverage is broad and current Windows CI plus the RTX smoke pair are green. Residual validation is the disclosed lack of AMD/native-wave64 testing, but the changed recognizer is CPU-side static analysis. I found no blocker.
upipibi commented 2026-11-26 05:05:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T04:16:39Z.


NVIDIA test report for f5ac68e: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.

  • cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4 (the hle::xaudio2 tests hang on this machine, on main too):
  • this PR: 1208 passed, 0 failed, 26 ignored; 25 SKIPPED lines (21 "no wave64", 3 f16/f32 per-lane forms refused for #1426 semantics, 1 PSO measurement needing Developer Mode), the same lines as on the base.
  • base 55d64c2: 1206 passed, 0 failed, 26 ignored; the same 25 SKIPPED lines. The two extra passes are this PR's new tests.
  • gpu::recomp::wave32_reduction_tests (valid_wave32_reductions_match_and_translate, invalid_wave32_reduction_shapes_and_exec_writes_are_rejected) 3 times with --test-threads=1 --nocapture: 2 passed, 0 failed each run.

Lib tests only; no title run.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7182452753 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7182452753). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T04:16:39Z. --- NVIDIA test report for `f5ac68e`: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. - `cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4` (the `hle::xaudio2` tests hang on this machine, on `main` too): - this PR: 1208 passed, 0 failed, 26 ignored; 25 SKIPPED lines (21 "no wave64", 3 f16/f32 per-lane forms refused for #1426 semantics, 1 PSO measurement needing Developer Mode), the same lines as on the base. - base `55d64c2`: 1206 passed, 0 failed, 26 ignored; the same 25 SKIPPED lines. The two extra passes are this PR's new tests. - `gpu::recomp::wave32_reduction_tests` (`valid_wave32_reductions_match_and_translate`, `invalid_wave32_reduction_shapes_and_exec_writes_are_rejected`) 3 times with `--test-threads=1 --nocapture`: 2 passed, 0 failed each run. Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5).
LocranKing commented 2026-11-26 05:05:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-26T04:48:48Z.


Independent NVIDIA test report on exact head f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca (clean detached checkout, no local changes).

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (Ampere, wave32, driver 32.0.16.2140 / 621.40), AMD Ryzen 5 5500, 32 GB RAM, Windows 11 Home (build 26300), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 1286 passed, 0 failed, 46 ignored (xcl --lib: 1217 passed, 0 failed, 26 ignored).
  • 28 SKIPPED GPU tests on this adapter: 21 wave64-only (no wave64), 3 wave32 per-lane f16/f32 semantics, 1 no heap windows, 2 D3D12 debug layer (no d3d12SDKLayers.dll / 0x887A002D), 1 cannot disable driver cache without Developer Mode (0x887A002D).

Regression run
scripts/smoke.ps1 -Seconds 60, release builds of origin/main (b49be18) and this PR's head (f5ac68e):

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1409 (PresentX 1409)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14032 MB

PR:

xcl-smoke v1
commit: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1521 (PresentX 1521)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14003 MB

Not tested

  • AMD / Intel / Linux GPUs; XCL_SAMPLE_* tests; the 60 s smoke run covers boot/intro/menus and does not enter the 3D world.

AI use

  • Antigravity (Gemini 4 Hydrogen) ran the builds, test suite, and smoke.ps1 commands on this machine and drafted this report from the captured outputs.
<!-- greyfinch-sync:ivall/xcl:comment:7182924714 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7182924714). Originally posted by [LocranKing](https://github.com/LocranKing) on 2026-11-26T04:48:48Z. --- Independent NVIDIA test report on exact head `f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca` (clean detached checkout, no local changes). **Tested** - Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (Ampere, wave32, driver `32.0.16.2140` / 621.40), AMD Ryzen 5 5500, 32 GB RAM, Windows 11 Home (build 26300), Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), Windows SDK `10.0.26100.0`. - `cargo build --workspace` + `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): 1286 passed, 0 failed, 46 ignored (`xcl --lib`: 1217 passed, 0 failed, 26 ignored). - 28 `SKIPPED` GPU tests on this adapter: 21 wave64-only (`no wave64`), 3 wave32 per-lane f16/f32 semantics, 1 `no heap windows`, 2 D3D12 debug layer (`no d3d12SDKLayers.dll` / `0x887A002D`), 1 cannot disable driver cache without Developer Mode (`0x887A002D`). **Regression run** `scripts/smoke.ps1 -Seconds 60`, release builds of `origin/main` (`b49be18`) and this PR's head (`f5ac68e`): main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1409 (PresentX 1409) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14032 MB ``` PR: ``` xcl-smoke v1 commit: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1521 (PresentX 1521) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14003 MB ``` **Not tested** - AMD / Intel / Linux GPUs; `XCL_SAMPLE_*` tests; the 60 s smoke run covers boot/intro/menus and does not enter the 3D world. **AI use** - Antigravity (Gemini 4 Hydrogen) ran the builds, test suite, and `smoke.ps1` commands on this machine and drafted this report from the captured outputs.
thehollowedone commented 2026-11-27 20:26:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T20:26:59Z.


merge-check
base: 6089122a1c
head: f5ac68e2c6
merge: clean
build: cargo build --workspace -> ok
tests: XCL_ADAPTER=nvidia cargo test --workspace --no-fail-fast -- --test-threads=4 on the untouched merge -> 1466 passed, 1 failed, 47 ignored; 25 SKIPPED notices. Both new wave32_reduction_tests passed. The sole failure was gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (DXIL not compiled), also reproduced on untouched main at this base here.
review: The new BANK_MASK == 0xF condition rejects a valid fixed-selector reduction. In this PR's own Seq fixture, BANK_MASK=0x7, ROW_MASK=0x3, and zero V_PERMLANEX16_B32 selectors still update mirror lanes 0 and 16; the cross-row call reads lane 16 into lane 0, and V_READLANE_B32 consumes lane 0. AMD's RDNA2 ISA specifies that the bank mask gates destination writes, not source reads, and describes the cross-row gather. The 0x7 case was moved into this PR's negative tests, so the current matcher drops the sparse-wave reduction replacement for that shape. This is a synthetic correctness boundary; I did not measure a title using it. I changed that case to a positive test and used 0xE (bank 0 disabled) as the negative: the focused test failed 1/2 on the unchanged PR head, then passed 2/2 with the conditional matcher below. The candidate did not receive a full-suite rerun.
performance: The stricter matcher may leave this valid reduction on the ordinary translated path instead of using xcl_red_*; title frequency and frame-time impact were not measured.
verdict: not yet: preserve the proven fixed-selector/bank-0 case, keep conservative full-bank matching for other selectors, and add the paired positive/negative regression before merge.
hardware / tool and model: NVIDIA RTX 3080 Ti 12 GiB, driver 621.35; Ryzen 7 9800X3D; Windows 11 build 26300; rustc 1.99.1 MSVC; DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the tests, checked the ISA and wrote the candidate; Codex (GPT-6.2 Astra) independently traced the lane semantics.

Candidate matcher and regression diff (local, uncommitted)
diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs
index b9adf88c..a712d57b 100644
--- a/crates/xcl/src/gpu/recomp/mod.rs
+++ b/crates/xcl/src/gpu/recomp/mod.rs
@@ -1010,10 +1010,18 @@ fn wave32_reductions(insts: &[Decoded], leaders: &std::collections::BTreeSet<u64
             op_of(d).map(|o| o.0) == Some(op) && d.variant == variant && w == [v] && r == [v, v]
         };
         let dpp8 = [a, b, c].iter().enumerate().all(|(k, d)| same_v(d, rdna2::Variant::Dpp8) && (0..8).all(|n| other_half(k, n, ext(d, &format!("LANE_SEL_{n}")))));
+        let mirror_banks = ext(mirror, "BANK_MASK");
+        // With a literal zero selector, lane 0 reads the opposite row's lane 0.
+        // Only bank 0's mirror writes can reach the final lane-0 read.
+        let bank_mask_ok = if f(cross, "SRC1") == Some(128) {
+            mirror_banks.is_some_and(|m| m & 1 != 0)
+        } else {
+            mirror_banks == Some(0xF)
+        };
         let mirrored = same_v(mirror, rdna2::Variant::Dpp16)
             && ext(mirror, "DPP_CTRL") == Some(0x140)
             && ext(mirror, "ROW_MASK").is_some_and(|m| m & 0x3 == 0x3)
-            && ext(mirror, "BANK_MASK") == Some(0xF);
+            && bank_mask_ok;
         let [cw] = rdna2::vgpr_uses(cross).1[..] else { continue };
         let crossed = cross.inst.name == "V_PERMLANEX16_B32" && cross.variant == rdna2::Variant::Plain && f(cross, "SRC0") == Some(256 + v) && cw != v;
         let (lr, lw) = rdna2::vgpr_uses(last);
@@ -1773,9 +1781,9 @@ mod wave32_reduction_tests {
     #[test]
     fn valid_wave32_reductions_match_and_translate() {
         for (inst, id, op) in [("V_OR_B32", 128, "or"), ("V_MAX_U32", 128, "max"), ("V_AND_B32", 193, "and"), ("V_MIN_U32", 193, "min")] {
-            for (row_mask, last_src) in [(0xF, (256 + 1, 0)), (0x3, (256, 1))] {
+            for (row_mask, bank_mask, last_src) in [(0xF, 0xF, (256 + 1, 0)), (0x3, 0xF, (256, 1)), (0x3, 0x7, (256 + 1, 0))] {
                 let mut s = Seq::valid(inst, id);
-                (s.row_mask, s.last_src) = (row_mask, last_src);
+                (s.row_mask, s.bank_mask, s.last_src) = (row_mask, bank_mask, last_src);
                 let code = s.build();
                 let (insts, leaders) = decode_all(&code);
                 assert_eq!(wave32_reductions(&insts, &leaders).reads.values().map(|x| x.1).collect::<Vec<_>>(), vec![op], "{inst}");
@@ -1796,7 +1804,7 @@ mod wave32_reduction_tests {
             ("mirror_wrong_vsrc0", case(|s| s.mir_src = (2, 0))),
             ("mirror_row_mask_1", case(|s| s.row_mask = 0x1)),
             ("mirror_row_mask_2", case(|s| s.row_mask = 0x2)),
-            ("mirror_bank_mask", case(|s| s.bank_mask = 0x7)),
+            ("mirror_bank_mask", case(|s| s.bank_mask = 0xE)),
             ("cross_inplace", case(|s| { s.cross_dst = 0; s.last_src = (256, 0); })),
             ("cross_wrong_src0", case(|s| s.cross_src = 2)),
             ("last_ignores_cw", case(|s| s.last_src = (256, 0))),
<!-- greyfinch-sync:ivall/xcl:comment:7227517209 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7227517209). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-27T20:26:59Z. --- merge-check base: 6089122a1c96dff16e93b6fdf04c8ed20cfb6102 head: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca merge: clean build: `cargo build --workspace` -> ok tests: `XCL_ADAPTER=nvidia cargo test --workspace --no-fail-fast -- --test-threads=4` on the untouched merge -> 1466 passed, 1 failed, 47 ignored; 25 `SKIPPED` notices. Both new `wave32_reduction_tests` passed. The sole failure was `gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk` (`DXIL not compiled`), also reproduced on untouched `main` at this base [here](https://github.com/xcl-dev/xcl/pull/671#issuecomment-7223888221). review: The new `BANK_MASK == 0xF` condition rejects a valid fixed-selector reduction. In this PR's own `Seq` fixture, `BANK_MASK=0x7`, `ROW_MASK=0x3`, and zero `V_PERMLANEX16_B32` selectors still update mirror lanes 0 and 16; the cross-row call reads lane 16 into lane 0, and `V_READLANE_B32` consumes lane 0. [AMD's RDNA2 ISA](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content) specifies that the bank mask gates destination writes, not source reads, and describes the cross-row gather. The `0x7` case was moved into this PR's negative tests, so the current matcher drops the sparse-wave reduction replacement for that shape. This is a synthetic correctness boundary; I did not measure a title using it. I changed that case to a positive test and used `0xE` (bank 0 disabled) as the negative: the focused test failed 1/2 on the unchanged PR head, then passed 2/2 with the conditional matcher below. The candidate did not receive a full-suite rerun. performance: The stricter matcher may leave this valid reduction on the ordinary translated path instead of using `xcl_red_*`; title frequency and frame-time impact were not measured. verdict: not yet: preserve the proven fixed-selector/bank-0 case, keep conservative full-bank matching for other selectors, and add the paired positive/negative regression before merge. hardware / tool and model: NVIDIA RTX 3080 Ti 12 GiB, driver 621.35; Ryzen 7 9800X3D; Windows 11 build 26300; rustc 1.99.1 MSVC; DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the tests, checked the ISA and wrote the candidate; Codex (GPT-6.2 Astra) independently traced the lane semantics. <details><summary>Candidate matcher and regression diff (local, uncommitted)</summary> ```diff diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs index b9adf88c..a712d57b 100644 --- a/crates/xcl/src/gpu/recomp/mod.rs +++ b/crates/xcl/src/gpu/recomp/mod.rs @@ -1010,10 +1010,18 @@ fn wave32_reductions(insts: &[Decoded], leaders: &std::collections::BTreeSet<u64 op_of(d).map(|o| o.0) == Some(op) && d.variant == variant && w == [v] && r == [v, v] }; let dpp8 = [a, b, c].iter().enumerate().all(|(k, d)| same_v(d, rdna2::Variant::Dpp8) && (0..8).all(|n| other_half(k, n, ext(d, &format!("LANE_SEL_{n}"))))); + let mirror_banks = ext(mirror, "BANK_MASK"); + // With a literal zero selector, lane 0 reads the opposite row's lane 0. + // Only bank 0's mirror writes can reach the final lane-0 read. + let bank_mask_ok = if f(cross, "SRC1") == Some(128) { + mirror_banks.is_some_and(|m| m & 1 != 0) + } else { + mirror_banks == Some(0xF) + }; let mirrored = same_v(mirror, rdna2::Variant::Dpp16) && ext(mirror, "DPP_CTRL") == Some(0x140) && ext(mirror, "ROW_MASK").is_some_and(|m| m & 0x3 == 0x3) - && ext(mirror, "BANK_MASK") == Some(0xF); + && bank_mask_ok; let [cw] = rdna2::vgpr_uses(cross).1[..] else { continue }; let crossed = cross.inst.name == "V_PERMLANEX16_B32" && cross.variant == rdna2::Variant::Plain && f(cross, "SRC0") == Some(256 + v) && cw != v; let (lr, lw) = rdna2::vgpr_uses(last); @@ -1773,9 +1781,9 @@ mod wave32_reduction_tests { #[test] fn valid_wave32_reductions_match_and_translate() { for (inst, id, op) in [("V_OR_B32", 128, "or"), ("V_MAX_U32", 128, "max"), ("V_AND_B32", 193, "and"), ("V_MIN_U32", 193, "min")] { - for (row_mask, last_src) in [(0xF, (256 + 1, 0)), (0x3, (256, 1))] { + for (row_mask, bank_mask, last_src) in [(0xF, 0xF, (256 + 1, 0)), (0x3, 0xF, (256, 1)), (0x3, 0x7, (256 + 1, 0))] { let mut s = Seq::valid(inst, id); - (s.row_mask, s.last_src) = (row_mask, last_src); + (s.row_mask, s.bank_mask, s.last_src) = (row_mask, bank_mask, last_src); let code = s.build(); let (insts, leaders) = decode_all(&code); assert_eq!(wave32_reductions(&insts, &leaders).reads.values().map(|x| x.1).collect::<Vec<_>>(), vec![op], "{inst}"); @@ -1796,7 +1804,7 @@ mod wave32_reduction_tests { ("mirror_wrong_vsrc0", case(|s| s.mir_src = (2, 0))), ("mirror_row_mask_1", case(|s| s.row_mask = 0x1)), ("mirror_row_mask_2", case(|s| s.row_mask = 0x2)), - ("mirror_bank_mask", case(|s| s.bank_mask = 0x7)), + ("mirror_bank_mask", case(|s| s.bank_mask = 0xE)), ("cross_inplace", case(|s| { s.cross_dst = 0; s.last_src = (256, 0); })), ("cross_wrong_src0", case(|s| s.cross_src = 2)), ("last_ignores_cw", case(|s| s.last_src = (256, 0))), ``` </details>
throny commented 2026-11-27 20:32:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:32:17Z.


merge-check claim
head: f5ac68e2c6

<!-- greyfinch-sync:ivall/xcl:comment:7227600631 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7227600631). Originally posted by [throny](https://github.com/throny) on 2026-11-27T20:32:17Z. --- merge-check claim head: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca
throny commented 2026-11-27 20:52:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:52:25Z.


merge-check
base: 6089122a
head: f5ac68e2c6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: one open point, raised earlier in the thread and confirmed by reading the code, not reproduced: the new requirement BANK_MASK == 0xF on the mirror step rejects a reduction that main matched and that looks valid (with a partial bank mask and zero permute selectors, lane 0 still reads a written lane, so the read-back is the full reduction). The PR's negative test asserts the rejection. A rejected shape falls back to the general translation; whether that is right for waves that are not full is the question to answer. No title is known to emit this shape. Everything else checks out (the EXEC-write checks, the operand checks; the other negative cases would match on main).
performance: it changes a translator source (recomp/mod.rs): every tester re-translates all shaders once. No runtime cost unless a real reduction is now rejected.
verdict: not yet: keep the partial-bank case or say why rejecting it is right (a test with a wave that is not full would settle it); small, I will re-check on a reply or a new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7227920360 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7227920360). Originally posted by [throny](https://github.com/throny) on 2026-11-27T20:52:25Z. --- merge-check base: 6089122a head: f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored review: one open point, raised earlier in the thread and confirmed by reading the code, not reproduced: the new requirement BANK_MASK == 0xF on the mirror step rejects a reduction that main matched and that looks valid (with a partial bank mask and zero permute selectors, lane 0 still reads a written lane, so the read-back is the full reduction). The PR's negative test asserts the rejection. A rejected shape falls back to the general translation; whether that is right for waves that are not full is the question to answer. No title is known to emit this shape. Everything else checks out (the EXEC-write checks, the operand checks; the other negative cases would match on main). performance: it changes a translator source (recomp/mod.rs): every tester re-translates all shaders once. No runtime cost unless a real reduction is now rejected. verdict: not yet: keep the partial-bank case or say why rejecting it is right (a test with a wave that is not full would settle it); small, I will re-check on a reply or a new head. hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Foniass commented 2026-12-01 07:56:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:56:20Z.


Triage (#1607) – head f5ac68e

wave32_reductions in crates/xcl/src/gpu/recomp/mod.rs no longer exists on main: commit fb0931da ("Recompiler: rebuild partial-wave graphics reductions") replaced it with graphics_reductions, which already requires exact operands on the DPP8/mirror/permlanex16/last steps, ROW_MASK/BANK_MASK = 0xf on the mirror, and rejects SAVEEXEC, WREXEC, V_CMPX and any SGPR 126/127 write inside the section.
What this PR has beyond main: the opener's SDST not being EXEC, SMEM loads into EXEC, SDWA VOPC writing EXEC, and accepting ROW_MASK 0x3 (main is stricter there). If those cases matter, a small PR on top of graphics_reductions with the matching rejection tests from wave32_reduction_tests would carry them.
Recommendation: close (superseded by main commit fb0931da).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304669934 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7304669934). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:56:20Z. --- **Triage (#1607)** – head f5ac68e `wave32_reductions` in `crates/xcl/src/gpu/recomp/mod.rs` no longer exists on main: commit fb0931da ("Recompiler: rebuild partial-wave graphics reductions") replaced it with `graphics_reductions`, which already requires exact operands on the DPP8/mirror/permlanex16/last steps, `ROW_MASK`/`BANK_MASK` = 0xf on the mirror, and rejects SAVEEXEC, WREXEC, V_CMPX and any SGPR 126/127 write inside the section. What this PR has beyond main: the opener's SDST not being EXEC, SMEM loads into EXEC, SDWA VOPC writing EXEC, and accepting ROW_MASK 0x3 (main is stricter there). If those cases matter, a small PR on top of `graphics_reductions` with the matching rejection tests from `wave32_reduction_tests` would carry them. Recommendation: close (superseded by main commit fb0931da). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Decodere commented 2026-12-02 07:49:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T07:49:03Z.


Closing as superseded by main commit fb0931da, which replaced wave32_reductions with graphics_reductions in crates/xcl/src/gpu/recomp/mod.rs with strict operand, mask, and EXEC-write checks. Thanks @Foniass, @throny, and @thehollowedone for the reviews and checks. (AI note: verified with Antigravity, Gemini 4 Neon.)

<!-- greyfinch-sync:ivall/xcl:comment:7338646022 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2365#issuecomment-7338646022). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T07:49:03Z. --- Closing as superseded by `main` commit `fb0931da`, which replaced `wave32_reductions` with `graphics_reductions` in `crates/xcl/src/gpu/recomp/mod.rs` with strict operand, mask, and EXEC-write checks. Thanks @Foniass, @throny, and @thehollowedone for the reviews and checks. (AI note: verified with Antigravity, Gemini 4 Neon.)

Pull request closed

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
xcl-dev/xcl!2355
No description provided.