recompiler: ReadLaneEliminator rewrites a spilled lane read to a value stored inside a branch, which does not dominate the read; fix branch ready #8050
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-19T18:49:53Z.
ReadLaneEliminatorreplaces av_readlaneof a spill slot with the one value ever stored to that lane (uniqueLaneValue, through the per-laneSelectU32s and phis ofcollectLaneValues). When thev_writelanethat stores it sits inside a branch, that value is defined in the branch and does not dominate the read after the merge, so the program later fails validation:Seen on Onimusha: Way of the Sword (PPSA27836, base 01.000.001), a 9,944-instruction wave64 pixel shader, about 6 minutes into the first scene load on an RTX 3080. Validating after every front-end pass (local diagnostic) shows the program valid after SSA, folding and control-flow identities, and broken right after
readLaneEliminator.Eliminate; with only the unique-value rewrite disabled it prepares (780,890 SPIR-V words).Fix branch: https://github.com/TheSovietWaffle/AnyPS5/tree/fix/recompiler-readlane-unique-dominance (one commit on main
8c9161eac;Optimization/src/ReadLaneEliminator.cpp, the new testtests/ReadLaneElimination.cppregistered in the libSceAgcDriverCMakeLists.txt). Where the stored value does not dominate the read, the read now takes it through phis built from the control flow: the stored value in the blocks it dominates, and anUndefU32on paths that never store the lane, which the eliminator already treats as never read back. A read the value dominates is rewritten as before.Checks:
8c9161eac, all 806agctests on an RTX 3080 (617.42) and an AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002): 805 pass on each. The one failure on each (agc_driver_pass_input_hazardon the RTX 3080,agc_trimmed_importon the Radeon) fails the same way on unchanged main.check_conventions.pypasses.Not verified: the undefined value is only ever read on paths the eliminator already assumes never read the slot back; that assumption is unchanged.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T20:57:35Z.
I opened PR #8089 from your reported fix, rebased onto current
main(9127ea36). The two commits separate the failing regression from the dominance fix and preserve the original commit author.On the current main base, the new test fails on the branch-local store case; with the fix,
agc_read_lane_eliminationpasses (1/1). The implementation patch is byte-for-byte equivalent to the one in your linked branch. The PR carries your reported retained-shader and GPU results with their original baseline and OS limits stated explicitly.