Repository navigation
Shaders: the DXIL backend simplifies the entry function after value numbering - #24
Conversation
|
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 |
…umbering A Simplifier pass after ValueNumbering and DeadCode: block chains reached only by an unconditional branch merge, branches on a constant or to one block twice become unconditional, phis of one value are that value and ConstantFolding folds what that decides. Wave and quad reads are nounwind, so nothing removed them: unread ones go, and one equal to an earlier one in its block with no effect between is shared. Reuses ConstantFolding, DominatorTree and ValueNumbering.Key from main. RaytracingResolve 1.57 -> 1.06 MB of DXIL, AMD pipeline 36.5 s / 8.4 GB -> 26.2 s / 3.6 GB; ActivateProbes 9.98 -> 8.50 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SKtJsfjasPuTLtS3mEXFru
846f363 to
ef74563
Compare
|
Rebased onto main and cut down to just those parts as a |
|
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):
thanks again, this is a really solid contribution! |
|
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. |
Rebased onto main after 9b01294: this is now only a
Simplifierpass 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
https://claude.ai/code/session_01SKtJsfjasPuTLtS3mEXFru