Shaders: the DXIL backend simplifies the entry function after value numbering #24
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/ThatRecompDev--five-star-recomp!24
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/24/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?
@Sr-0w on GitHub · 2026-11-25 09:16 UTC · original
Sr-0w:shaders/dxil-simplifier→main· +508 −3 · 6 files · 1 commits · merged 2026-11-25 10:08 UTCRebased onto main after
9b01294: this is now only aSimplifierpass afterValueNumberingandDeadCode(both skipped by--no-optimize), with the parts main doesn't have:ConstantFoldingfolds what that decides;My DominatorTree/ValueKey/NumberingWalk/ConstantFolder are gone; it reuses
ConstantFolding,DominatorTreeandValueNumbering.Key(now internal).Instruction.Blockgets an internal setter since merged instructions change block. My old folder had nothing yours misses that mattered on these programs, soConstantFolding.csis unchanged.ValueNumberingSimplifierCS_RaytracingResolve(wave32)CS_ScreenProbes_ActivateProbes(wave64)Tests:
DxilSimplifierTests(WARP: same words optimized and plain, smaller module; IR: chain merge, constant branch fold, wave read shared and unread one dropped). Architecture and Shaders tests green. FourCompileBudgetTestsfail on a clean main too (8531204), unrelated.🤖 Generated with Claude Code
@ThatRecompDev on GitHub · 2026-11-25 09:34 UTC · original
thanks a lot for this! the numbers are great, especially the AMD timings. while this PR was open, main got an overlapping pass (
9b01294): constant folding in IrBuilder and a dominator-scoped ValueNumbering with entry hoisting, so the two now conflict.on the same programs yours still cuts noticeably more, mostly from the parts main doesn't have: merging block chains, folding constant and same-target branches, dropping unread wave reads (nice catch on nounwind keeping them all) and sharing wave reads within a block. could you rebase onto main and keep just those as a Simplifier pass after ValueNumbering? then your DominatorTree/ValueKey/NumberingWalk/ConstantFolder can go, and anything ConstantFolder folds that ours misses can move into Dxil/Ir/ConstantFolding.cs. happy to help with the rebase if it's a pain
@Sr-0w on GitHub · 2026-11-25 10:03 UTC · original
Rebased onto main and cut down to just those parts as a
SimplifierafterValueNumbering/DeadCode, reusing your ConstantFolding, DominatorTree and Key; description updated with fresh numbers (RaytracingResolve 1.57 -> 1.06 MB, AMD 36.5 s / 8.4 GB -> 26.2 s / 3.6 GB). Next I'd like to send a follow-up to ValueNumbering: hoisting a pure instruction to the deepest block defining its operands rather than only the entry. On ActivateProbes the formatted-load decode of one descriptor (loaded once, not in the entry) is recomputed in each of 3,281 sibling branches.@ThatRecompDev on GitHub · 2026-11-25 10:06 UTC · original
nice, that's exactly what i had in mind. the rebased version reads really clean and the AMD numbers speak for themselves (26 s / 3.6 GB vs 36.5 s / 8.4 GB). i'll merge once windows CI is green.
the hoisting follow-up sounds good, go for it. 3,281 copies of the same decode is a lot.
since you've got an AMD card and clearly know this area, here are a few more in the same category if you feel like it (no pressure, pick whatever sounds fun):
select(active, …)wave emulation. you noted this is what keeps ActivateProbes over 50 GB on AMD. a lot of those selects sit in regions where exec is known full or uniform, so they could be dropped there, or emitted once per region instead of per instruction. that's in the translator (Translation/Waves), not the backend.fivestar shader dxil --bench <list>that builds a fixed set of the heaviest programs and prints size, blocks and pipeline create time/memory, so changes like yours can be compared in one run on any card.thanks again, this is a really solid contribution!
@Sr-0w on GitHub · 2026-11-25 10:16 UTC · original
Correction on the follow-up I mentioned: I tried hoisting pure instructions to the deepest block defining their operands, and it removes the duplicated descriptor decode, but AMD likes it less. RaytracingResolve went 26.2 s / 3.6 GB -> 55.6 s / 3.7 GB, and 45 GB together with a narrower formatted-load decode, because the live ranges get longer. So I'm not sending it; nothing changes for this PR.