Repository navigation
Conversation
…ar CFG scan, and early dropped-inst skip Speed up ir::build across all shaders with structurally identical SSA output: - Pruned SSA construction via parallel [u64; 7] bitset iterated dominance frontiers (propagating all 385 registers simultaneously) and single-pass iterative dominator-tree DFS renaming with an undo trail, eliminating maximal-SSA trivial phi creation, outs Vec allocations, and binary-search lookup() calls. - Drop live_out from liveness() (returning (live_in, defs)) and fast-return in remove_trivial_phis_steps() when no phis exist or none are removed. - Linear CFG block assignment in build_bounded() (dropping next_offsets Vec and per-instruction leaders binary searches) and early is_dropped() opcode skip before machine.fields(wave64) for scheduling/waitcnt hints. - Disjoint from Marvisak#2664's Exit::succs and effects() dedup. Measured (--release bench_ir_build_cfg_and_ssa, median of 3 runs, 102 blocks / 40 phis): - 613.6 -> 292.1 us/run (2.10x, -52.4%) Assisted-by: T3 Code (Antigravity, gemini-4-neon)
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and verified against main (63bcca43) on Windows 11 (RTX 5090 + WARP + dxil.dll) — clean, fast, and ready to merge:
build_pruned_ssa(crates/victory-shader/src/ir.rs:236-423) computes idoms/DF aftersplit_irreducible, builds pruned phi shells via[u64; REGS.div_ceil(64)]bitset IDF filtered bylive_in[y], and renames in a single explicit-stack dominator-tree pass with trail rollback.- Monotonic block scan and early
is_dropped(encoding, opcode)skip avoid unnecessarymachine.fields(wave64)work, andis_dropped_matches_dropped_namesguards against opcode drift. - Zero changes to
emit/lower.rs.
Local verification:
cargo test --locked -p victory-shader --lib:ir::11/11,structure::13/13,resource::35/35,emit::tests17/17,emit::lower::tests33/33 (includingpruned_ssa_matches_maximal_ssa_oracleandis_dropped_matches_dropped_names)emit::semantics_tests: 34/34 passed on both RTX 5090 and WARP--releasebench_ir_build_cfg_and_ssa:179.3 us/runcargo clippy(default &--all-features) +cargo xtask policy(191 files ok): 0 warnings
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: textbook pruned SSA. The parallel bitset IDF inserts phis only at df nodes where the reg is live-in (defs & live_in & !phi_regs), re-queueing on new bits — monotone so it terminates. Renaming is standard Cytron: phi values bound before reads, successor args filled at parent exit with current[], trail undo on Leave. The NONE-arg invariant holds because a reg live-in at a join is either defined on all reaching paths or lands in live_in[0] as an input. The is_dropped opcode table self-validates against DROPPED names via decode, and the linear leader scan replaces binary_search correctly since both lists are offset-sorted. The canonical oracle test comparing against maximal SSA on identical blocks is exactly the right check.
|
@RVZO6 I compared this PR and #2942 individually and together through the public Median wall time in ms for one batch of 64 distinct compute containers on a Ryzen 7 9850X3D, Windows x64, Rust 1.98.1 MSVC, release build. Lower is faster.
The buffer batch varies program size and puts one dynamic diamond per eight loads in half of its shaders. The join batch has 4–130 diamonds; all 16 VGPRs feed the final store. The largest emits 2,080 DXIL phi instructions. Half the inputs in each batch enable view marks. Every timed call parses its compressed synthetic container, builds the IR, structures it, tracks resources and emits DXIL. Each row is 15 measurements across five processes with run order rotated and a warm-up outside the timer. The worker threads use the in-memory inputs directly; no shader cache, D3D pipeline creation, validator, file I/O or GPU dispatch is in the timer. Correctness: I compared the actual DXIL bytes and the remaining Reproducible, test-only fixture 29c0e1b applies to the common base or either PR. From PowerShell: git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2957-translation-corpus
git cherry-pick 29c0e1b
$env:VICTORY_BENCH_WORKERS = '8'
foreach ($family in 'buffers','joins') {
$env:VICTORY_BENCH_CORPUS = $family
cargo test --release -p victory-shader --lib translate_public_compute_batch -- --ignored --nocapture
}Set |
|
Automated triage for the maintainers. Needs work. This replaces the SSA construction in The 2.1x figure is for CI: passing. Generated by Claude Code |
Speed up
victory_shader::ir::buildacross all shaders while producing structurally identical SSA output (crates/victory-shader/src/ir.rs):[u64; 7]bitset IDF + dominator-tree DFS renaming: propagate iterated dominance frontiers for all 385 registers simultaneously in bitset words, gate phi insertion bylive_in, and rename in a single iterative dominator-tree DFS with an undo trail — eliminating maximal-SSA trivial phi creation, per-blockoutsVecallocations, and binary-searchlookup()calls.liveness()and fast-return inremove_trivial_phis_steps(): drop unusedlive_outcomputation fromliveness()and skip extra passes when no phis exist or none are eliminated.is_dropped()skip: assign basic blocks linearly inbuild_bounded()(droppingnext_offsetsand per-instructionleadersbinary searches) and skip scheduling/waitcnt hints beforemachine.fields(wave64)viais_dropped().Exit::succsandeffects()dedup).Measured (
--release, median of 3 runs)bench_ir_build_cfg_and_ssa(102 basic blocks, 40 phis): 613.6 µs → 292.1 µs/run (2.10×, -52.4%)Verification
--tests+--features diagnosticsclippy,xtask policy, full workspace tests): RVZO6/VIctory CI run #45734072839 (green, combined Wave 7 check on63bcca4).ir::testspass, includingpruned_ssa_matches_maximal_ssa_oracle(verifying structural equivalence against the maximal-SSA algorithm) andis_dropped_matches_dropped_names.AI-assisted: T3 Code (Antigravity, gemini-4-neon).