Recompiler: solve split-wave64 mask liveness per basic block with precomputed operand plans #1090
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!1090
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1090/head"
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?
@TG0000 on GitHub · 2026-11-24 11:27 UTC · original
TG0000:perf/x64-masks-block-liveness→main· +787 −20 · 1 files · 1 commits · merged 2026-11-25 01:07 UTCWhat is in it
Accelerate split-wave64 SGPR mask liveness analysis (
crates/xcl/src/gpu/recomp/x64_masks.rs), which runs during shader translation for wave64 compute, mesh, and geometry programs on 32-lane-wave GPUs:LOOP_GUARDexit mask). Because(X & !k) | X == Xfor bitmasks, the constant per-block exit mask collapses out of intra-block composition, reducing the backward fixpoint from instruction granularity (O(iters * N)) to basic-block granularity (O(iters * B)) with a single linear backward pass per block to reconstructlive_out.BTreeMap<u64, usize>PC table, per-instructionVec<usize>successor lists, and per-instructionVec<Option<usize>>loop-exit lists with binary search on sorted PCs, an inlineBlockSuccenum, and a single flatexit_targetsbuffer populated via anO(B * depth + L log B)sweep.UsePlanTable): Lazily precompute static bit-range descriptors and fixed register masks per(InstEnc, Encoding)in a flat open-addressed table, eliminating per-instruction string.contains()scans and linearEncoding::fieldlookups inuses().Release benchmark (
cargo test --release --lib gpu::recomp::x64_masks::tests::bench_whole_live_out -- --ignored --nocapture, synthetic multi-loop shaders with nested loops, diamond branches, compares,v_cndmask, and carry chains; bit-for-bit verified against the original solver):whole_live_out_reference)whole_live_out)Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)(stable-x86_64-pc-windows-msvc), debug and release.cargo test --lib gpu::recomp::x64_masks: 19 passed, 0 failed, 1 ignored (manual release benchmark). Includes exhaustive equivalence check ofuses()vsuses_fallback()across every RDNA2 instruction and encoding, 200-case fuzz check ofnested_loop_ranges()against the quadratic merge, and bit-for-bitwhole_live_out()equivalence across synthetic multi-loop shaders for bothend_reads_all = falseandtrue.cargo test --release --lib gpu::recomp::x64_masks::tests::bench_whole_live_out -- --ignored --nocapture: 1 passed, 0 failed (11.13x–23.37x speedup).cargo build --release -p xcl: succeeded cleanly.Regression run
Baseline (
origin/main):PR (
7bea019319cc08a54cdb3c9e49a0941d88b35283):Not tested
cargo test --workspaceand live split-wave64 shader compilation on an NVIDIA (wave32-only) GPU; covered by the exhaustive unit and bit-for-bit equivalence tests above.AI use
UsePlanTable, equivalence tests, and release benchmark, and ran local builds, unit tests, and the retail smoke run.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@fromthemoonx on GitHub · 2026-11-24 11:53 UTC · original
NVIDIA (32-lane) run, since Not tested lists the full suite and live split-wave64 compilation on a wave32-only GPU.
Tested
NVIDIA GeForce RTX 3060 12 GB (32-lane waves only, so the translator uses split wave64), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), Graphics Tools installed; rustc 1.100.0
stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17Exact head
7bea019319cc08a54cdb3c9e49a0941d88b35283, which is on currentmain47efa2e(so this is also the merged result):cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4, debug: 744 passed, 0 failed, 42 ignored (lib 701 / 0 / 22; the extra ignored test is the new benchmark)cargo test -p xcl --lib gpu::recomp::x64_masks: 19 passed, 1 ignored. The three new equivalence tests passed:use_plan_matches_fallback_across_all_rdna2_instructions,nested_loop_ranges_matches_quadratic_merge_on_overlapping_intervals,block_liveness_matches_reference_bit_for_bit.Live split-wave64 translation on this GPU:
x64_masks::by_pcfeedsx64_whole_liveinrecomp/mod.rs. I ran the three new tests together with everygpu_split_wave64_*andgpu_wave64_*GPU test (wave64 programs translated with this liveness, compiled by DXC and run on the RTX 3060), 10 runs: 10 of 10 passed (11 tests each time)Release benchmark, your command (
cargo test --release --lib gpu::recomp::x64_masks::tests::bench_whole_live_out -- --ignored --nocapture), 3 runs:Same order as your 11–23×, a bit lower on this CPU.
SKIPPED (no wave64 on this adapter):
gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareNot tested
AI use
@SlopTart on GitHub · 2026-11-24 13:19 UTC · original
Wine/RDNA3 datapoint: merged this head (lane merge
7bea019= head, fast-forward onto47efa2e) and ran the forced-split cluster (XCL_SPLIT_WAVE64=1,--test-threads=1, release) for 3 reps, plain-main control in the same session.gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves- 0/3 (control 0/3)gpu_split_wave64_masks_read_whole_after_partial_writes- 0/3 (control 0/3)gpu_split_wave64_waves_diverge- 1/3 (control 0/3; inside this rig's flake band for that test)gpu_split_wave64_lane_local_masks- 6/6 total both lanesPer-block mask liveness reads fine on native wave64 hardware, but it does not move the nondeterministic exchange cluster documented in my #772 follow-up. One mechanical note: this head and #1111 both rewrite
x64_masks.rsand conflict when merged together, so whoever lands second needs a rebase, and the two fixes cannot be validated in combination yet.Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@Cecerw on GitHub · 2026-11-24 14:09 UTC · original
Tested on NVIDIA Ampere (32-lane waves, split wave64): passes
7bea019(base47efa2e)main930e8b4.\scripts\test.ps1(cargo test --workspace -- --test-threads=4), no local changes; the merge was done locally, no conflictsuse_plan_matches_fallback_across_all_rdna2_instructions,nested_loop_ranges_matches_quadratic_merge_on_overlapping_intervals,block_liveness_matches_reference_bit_for_bit: ok (bench_whole_live_outignored, not run)gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware)Not tested: AMD, any title (no smoke run).
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@tatazildo on GitHub · 2026-11-25 12:17 UTC · original
Independently tested the Wave64 mask-liveness optimization on commit
1a0bbe3.Environment:
The benchmark passed, including the equality assertions between the reference and optimized implementations.
ChatGPT assisted with the testing procedure and report preparation.