perf(shader): opt-in empty-edge CFG elimination with exact execution coverage #647
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!647
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-647"
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?
@tommiehansen on GitHub · 2026-12-05 23:16 UTC · original
tommiehansen:perf/empty-edge-20261206→main· +588 −0 · 6 files · 9 commits · openWhy
Empty control-flow blocks can add work to shader graph construction and lowering without performing useful instructions. Removing them may simplify shader preparation, provided phi predecessors, critical edges and divergent EXEC behavior remain intact.
What changes
A worklist contracts proven empty edges and revisits affected candidates. Small shared unconditional fan-in blocks are eligible only if the target has no phi; critical edges are excluded. The pass is independently switchable with a separate v2 shader cache identity. It does not change loop-abort semantics. Inspired by cool_fox / CNF-Larp #247.
Benchmark results — Windows shader preparation
CI 47586760732,
31a4163, eight paired blocks per shape (192 exact arms, two divergent dispatches per arm). Total is translation + validation + WARP PSO creation; absolute times are medians of block medians.33/48 blocks faster in total; lowering alone varies from −3.06% to +7.62%, and DXIL size reductions are 0.19–4.73%. Offline ACO, 24 matched four-arm cases, reports identical final AMD ISA, register allocation, spill/scratch and occupancy. The GFX1200 profile is compiler-only. No physical GPU speedup established.
Why this should be merged
A bounded graph simplification could reduce preparation overhead for eligible complex shaders. The improved pass has repeatable scoped CPU preparation savings on the larger generated CFGs, with an inexpensive no-candidate return. Ready for review as an opt-in CPU preparation optimization; retain default off. No runtime GPU benefit or general shader-corpus speedup is claimed.
Validation and compatibility
Initial exact cases: 56/56 translated WARP outputs, both wave widths and divergent cutoffs; structural coverage, Linux and Windows production compilation. Full Windows suite has the existing descriptor PSO failure, also with the option off. Shared join controls and latest four CI jobs pass.
Reproduce:
cargo test --locked --release -p victory-shader --lib empty_edge_full_translation_cost -- --ignored --nocapture --test-threads=1. Representative title CFGs and physical AMD execution remain useful follow-up coverage, not prerequisites for review of this scoped CPU benefit.Final implementation and paired validation —
ef0dd14Avoid all graph allocation when no candidate exists; build predecessors during the reachability walk and take rather than clone the removed edge's predecessor vector. Preserve existing legality checks. All four final CI jobs pass, including structural parity with the preceding implementation and 192 exact Windows full-preparation arms. The prior run 47597015971 independently produced exact Windows output; its Linux log-count gate (not the tests) was fixed at final head.
This compares pass cost with the preceding implementation, not switch off. Full preparation (translation + validation + WARP PSO) independently compares switch off/on:
Medians of block medians; negative paired time change means faster. 31/48 full-preparation blocks improved; lowering alone is mixed. The prior run independently showed larger-graph reductions, but the magnitude varies. No final AMD ISA or elapsed GPU gain established. Review as scoped opt-in; no default activation.
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.