Recompiler: direct DXIL drops phi groups that pass one value around #1938
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1938
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1938"
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?
@mastrr9 on GitHub · 2026-11-24 23:43 UTC · original
mastrr9:feat/dxil-drop-redundant-phi-sccs→main· +325 −2 · 1 files · 1 commits · draftModule::optimizeonly removes a phi that is trivial on its own, so loops leave cycles of phis that name each other plus one value. This removes such groups with Tarjan SCCs over the phi operand graph (Braun et al., CC 2013).XCL_DXIL_NO_OPT=sccskips the step.No
TRANSLATOR_VERSIONchange: #1947 hashes thegpu/dxilsources into the translation cache's identity.Draft: the head commit
0fda14f(rebased onto main568e7db) has only been type-checked; Windows tests, GPU verification and the regression run are still to do.What is in it
gpu/dxil/module/opt.rs: the pass, run after trivial phis and again after CSE, with four tests on hand-built IRTested
These runs are from before the final rebase, on a combined branch (
01db80a, based on maine9e94ce; it holds this change plus four other changes), not on this PR's head commit. On the head commit,cargo check --locked --workspace --all-targets --target x86_64-pc-windows-msvcon macOS (Rust 1.100.0, the C compiler for one dependency stubbed out) finished with no errors; nothing was run.cargo testdebug build. Driver, CPU and Rust versions were not recorded.cargo test -p xcl --lib gpu::dxil::module::opt -- --test-threads=1: 4 passed, 0 failed.direct_dxil_size_report(a synthetic size report that is on that branch, not in this PR), pass off (XCL_DXIL_NO_OPT=scc) → on, totals: phis 194 → 173, instructions 4027 → 4000, selects 191 → 185, bytecode 120800 B → 120640 B. The tree also had a lane-bit folding change, on in both runs.gpu/dxil/module/is unchanged betweene9e94ceandf5136a6. The rebase onto568e7dbleaves the pass and its tests as they were; the tests now share onemod testswith a test thatmainadded toopt.rs.Regression run
Not run: there are no
xcl-smokeblocks for this change.Not tested
cargo test --workspacewas not run for this change on its own.opt.rsare expected with #1818, #1906 and #1930; whichever lands later needs a rebase.AI use
`Module::optimize` replaces a phi only when it is trivial on its own (every incoming value the phi itself or one other value). A loop whose body sets a register back to the value it had before the loop (a copy, a constant, or two copies of one expression that CSE merges) leaves a cycle of phis that name each other plus that one value: the loop header's phi takes the value and the join's phi, the join's phi takes the header's phi and the value. Neither is trivial alone, so both were written, with their uses. Remove such groups as Braun et al. ("Simple and Efficient Construction of Static Single Assignment Form", CC 2013) do: Tarjan's strongly connected components over the phi operand graph, operands first; a component whose operands outside it are all one value becomes that value; a component with several outside values is a real merge, and the phis in it that name only its members are searched again for such a group. The step runs after the trivial phis (so CSE sees the replacements) and once more after CSE (groups whose definitions CSE merged). `XCL_DXIL_NO_OPT=scc` skips it. No TRANSLATOR_VERSION change: the translation cache's identity includes a hash of the `gpu/dxil` sources (#1947). Tests build the IR by hand: a redundant two-phi loop cycle, the same loop with a real second value (kept), a redundant inner group inside a real outer merge, and a cycle that is redundant only after CSE.@raylitebull on GitHub · 2026-11-25 01:08 UTC · original
Diff audit on draft
47170bf(redundant_phi_sccsTarjan SCC removal before and after CSE, plus sub-SCC handling and tests) looks clean.When ready to undraft: rebase onto
main(dropping the manualTRANSLATOR_VERSION = 8bump inkernel.rs, as#1947now auto-hashesgpu/dxilsources), add thexcl-smokeblock forPR description, and add AMD + NVIDIA verification.@DavidM1911 on GitHub · 2026-11-25 02:41 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@DavidM1911 on GitHub · 2026-11-26 00:42 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.