Shaders/IR: pruned SSA via bitset IDF + dominator-tree renaming, linear CFG scan, and early dropped-inst skip #2957
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2957
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2957"
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?
@RVZO6 on GitHub · 2026-11-26 01:30 UTC · original
RVZO6:rvzo/ir-pruned-ssa→main· +511 −70 · 1 files · 1 commits · openSpeed 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).
@steven-seagull27 on GitHub · 2026-11-26 02:53 UTC · original
@RVZO6 I compared this PR and #2942 individually and together through the public
translate_withentry point, in light of the eight translation workers reported on #2936. Both commits start at63bcca4, affect different compiler stages, and merge cleanly.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.
dfa61261569277The 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
HostShaderbinding metadata for all 128 inputs. All four builds matched, and the Windows SDK DXIL validator accepted every output on each build (512 validations). Output sizes were 2,512–99,264 bytes. The paired change reduced these eight-worker medians by 16% in both batches. #2942 showed the more consistent individual benefit. The small eight-worker difference between #2957 alone and base is within the spread of repeated runs.Reproducible, test-only fixture 29c0e1b applies to the common base or either PR. From PowerShell:
Set
VICTORY_BENCH_OUTPUTto a separate directory for each build and batch to validate and save the binary outputs and binding metadata before timing. No title files were used; the eight-worker cold-cache run of the actual game remains the check for gameplay startup.@Marvisak on GitHub · 2026-11-26 05:22 UTC · original
Automated triage for the maintainers.
Needs work. This replaces the SSA construction in
crates/victory-shader/src/ir.rs(build_pruned_ssa: dominance-frontier phi placement gated bylive_in, dominator-tree renaming with an undo trail), scans leaders linearly inbuild_bounded, and skips dropped instructions before decoding fields. Reading it, the renaming and phi-argument filling look right, andpruned_ssa_matches_maximal_ssa_oraclecompares against the old algorithm, but it rewrites the core of every shader's translation, so the bar is a measured benefit.The 2.1x figure is for
ir::buildalone on one synthetic program. The end-to-end measurement in this thread (steven-seagull27,translate_withover 128 synthetic containers, byte-identical DXIL on all builds) found this PR alone inside run-to-run noise with 8 workers and slower in one 1-worker batch (299.2 -> 307.5 ms), while #2942 gave the more consistent gain. To move this forward: show a whole-titlevictory translatetiming (cold cache, the worker count the loader uses) where this PR measurably helps on its own or on top of #2942, plus a program-by-program comparison showing identical output across the title's shaders. Without that, the risk of a core IR rewrite isn't matched by a demonstrated gain.CI: passing.
Generated by Claude Code
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.