Shaders: compress replaced phi chains in remove_trivial_phis #1371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1371"
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?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:38:32Z.
Fixes #950.
Summary
findinsideir::remove_trivial_phisso deep chains of trivial phis eliminated in reverse block order do not repeatedly walkO(N)chains (O(N^2)total) during the fixed-point and operand-rewrite passes.Verification
cargo test --workspace,cargo clippy --workspace --all-targets --all-features, andcargo xtask policy: passed.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:42:43Z.
Review: APPROVED
remove_trivial_phis find() gains path compression (two-pass iterative, no recursion): the replaced[] union-find no longer degrades to O(chain^2) on long trivial-phi chains. Semantics unchanged — compression only shortcuts lookups; the three new ir.rs tests verify identical SSA results on 4096-layer forward/reverse diamonds, a <100k step bound, and that non-trivial phis keep correct representatives. All run on macOS. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p <crate> --locked. Shader execution tests (valu_tests/host/diff_tests) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 99 passed, 0 failed.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:50:18Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 99 passed, 0 failed. Hardware/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers structure/lowering unit tests.remove_trivial_phis now compresses replaced phi chains with a bounded step budget (find() with steps) instead of one pass per phi; three tests cover reverse-order diamond chains, bounded compression, and non-trivial phi preservation. +3 macOS tests (99 total).
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:48:23Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
5c44562ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 123, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).