Recompiler: tighten operand and EXEC checks in wave32_reductions #2365
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2365
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2365"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Decodere on GitHub · 2026-11-25 16:47 UTC · original
Decodere:fix-12f25f1-wave32-reductions→main· +128 −14 · 1 files · 1 commits · openPart of #1401
Follow-up to
12f25f1(crates/xcl/src/gpu/recomp/mod.rs).wave32_reductionsreplaces the console compiler's wave32 whole-wave reduction sequence withxcl_red_<op>(xcl_seed_<pc>)so waves that are not full still reduce every live lane. Several operand, mask, andEXEC-clobber checks were too loose and could rewrite non-reduction code or sequences whoseEXECwas modified mid-section.What is in it
wave32_reductions(crates/xcl/src/gpu/recomp/mod.rs):a,b,c) and DPP16 (mirror) step to bev(r == [v, v]), plusmirrorROW_MASK & 0x3 == 0x3andBANK_MASK == 0xF.cross(V_PERMLANEX16_B32) to beVariant::PlainwithSRC0 == 256 + vand single destinationcw != v; requirelastto beVariant::Plainwriting[v]with inputs strictly{v, cw}(lr == [v, cw] || lr == [cw, v]); and requireread(V_READLANE_B32) to beVariant::PlainwithSRC0 == 256 + vandSRC1 == 128.open(S_OR_SAVEEXEC_B32) whenSDSTis in126..=127(EXEC_LO/EXEC_HI), and reject any instruction inopen + 1..=endthat branches/jumps/terminates (F_TERMINATOR | F_BRANCH | F_INDIRECT) or writesEXEC— including implicitOPR_EXEC/OPR_SDST_EXECoutputs (V_CMPX_*,S_*_SAVEEXEC_*,S_ANDN{1,2}_WREXEC_*,S_SUBVECTOR_LOOP_*), explicit SGPR/VOP3/SMEM destinations in126..=127(sgpr_uses+ENC_SMEMSDATA), andENC_VOPCSDWA compare writes to126..=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) acrossROW_MASK0xF/0x3, bothlastoperand orders, and wave32 PS/VStranslate()emission, plus 19 invalid/clobbered shapes verified to be rejected by bothwave32_reductionsandtranslate().Tested
rustc 1.100.0, DXC1.9.2609.5, release profile (--release).cargo test --release -p xcl --lib gpu::recomp::wave32_reduction_tests:: -- --nocapture: 1 passed, 1 failed (invalid_wave32_reduction_shapes_and_exec_writes_are_rejectedfailed onorigin/main).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-existingSKIPPEDlines: 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 ingpu::recomp::wave32_reduction_tests).Regression run
main:
PR:
Not tested
wave32_reductionsis pure-CPU static RDNA2 analysis in the recompiler).title: 29640639.AI use
wave32_reductions,rdna2_spec.rs, andemit.rs, implemented the tightened operand/mask/EXECchecks and failing-first unit tests, and ran the workspace and paired smoke verification.`wave32_reductions` previously accepted several non-reduction shapes and mid-section `EXEC` mutations in wave32 VS/PS shaders: - DPP8 (`a, b, c`) and DPP16 (`mirror`) steps checked `r.contains(&v)` instead of requiring both operands to be `v` (`r == [v, v]`), and `mirror` did not verify `ROW_MASK & 0x3 == 0x3` and `BANK_MASK == 0xF`. - `V_PERMLANEX16_B32` (`cross`) did not check `Variant::Plain`, `SRC0 == 256 + v`, or `dst != v`; `last` checked `r.contains(&v)` instead of requiring inputs `{v, cross_dst}`; and `V_READLANE_B32` did not check `Variant::Plain` and `SRC0 == 256 + v`. - `S_OR_SAVEEXEC_B32` (`open`) accepted `SDST` in `126..=127` (writing the saved mask back into `EXEC`), and the `EXEC`-clobber check inside `open + 1..=end` missed implicit/SMEM/VOP3/SDWA `EXEC` writers such as `V_CMPX_*`, `S_ANDN{1,2}_WREXEC_*`, `S_SUBVECTOR_LOOP_*`, and `ENC_SMEM` loads targeting `EXEC_LO`/`EXEC_HI`. Enforce exact operand/mask matching across every reduction step and reject any `EXEC` write or branch/indirect transfer inside the section. Part of #1401 Assisted-by: Google Antigravity (Gemini 4 Neon)@emirduran707 on GitHub · 2026-11-25 17:37 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca(clean detached checkout, no local changes).Tested
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 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused 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.gpu::recomp::wave32_reduction_tests::valid_wave32_reductions_match_and_translateandinvalid_wave32_reduction_shapes_and_exec_writes_are_rejected.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 18:50 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!
@SlopTart on GitHub · 2026-11-25 19:06 UTC · original
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 targetx86_64-pc-windows-gnurun 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_2seed 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.
@upipibi on GitHub · 2026-11-26 04:16 UTC · original
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(thehle::xaudio2tests hang on this machine, onmaintoo):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 on GitHub · 2026-11-26 04:48 UTC · original
Independent NVIDIA test report on exact head
f5ac68e2c6bcb81a59f8340b5292dc7d6357a4ca(clean detached checkout, no local changes).Tested
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 SDK10.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).SKIPPEDGPU tests on this adapter: 21 wave64-only (no wave64), 3 wave32 per-lane f16/f32 semantics, 1no 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 oforigin/main(b49be18) and this PR's head (f5ac68e):main:
PR:
Not tested
XCL_SAMPLE_*tests; the 60 s smoke run covers boot/intro/menus and does not enter the 3D world.AI use
smoke.ps1commands on this machine and drafted this report from the captured outputs.@bmjask on GitHub · 2026-11-25 20:24 UTC · original · reviewed
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.