fix(shader): match half-wave reductions over relatively addressed vector registers #4162
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4162"
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 Celegans12 on 2026-10-12T00:15:50Z.
What
Since #3856, a program that uses
v_movrels_b32orv_movreld_b32keeps its vector registers from the lowest relatively addressed one up in a per-invocation window array, so plain register accesses becomeLoadVectorWindow/StoreVectorWindow. The half-wave reduction matcher (#2449-#2451) only follows SSA values, so a wave64 scan,v_permlanex16_b32join and lane 31/63 read through that array still throws that lane 63 is outside the 32-lane host subgroup.v_movreld_b32at a runtime M0) or a store in another block stops the forwarding, and the read still throws.Among PPSA26344's wave64 graphics programs, 38 of 39 lane 32-63 reads already match on
main; the remaining one is this shape, in a pixel program.#4120 keeps registers in SSA only for programs without indexed writes, so it does not cover this case, and these tests use
v_movreld_b32so they keep testing the window path.Tested
Based on
mainbca7a29d. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, full build, --target libs, ctest.log_macros,agc_write_tracking,agc_driver_prepared_shaders_registered_workgroup_syncandguest_kernel_stack_protectfail the same way onmainmainbca7a29d: 920/923 pass; the 3 failures also fail onmain43bc17f7.agc_driver_pixel_wave_reductionalso passes on Windows lavapipeagc_shader_memorychecks a UMin scan through av_movreld_b32window (subgroup UMin on 32 lanes, correct halves on 64) and keeps the runtime-M0 refusal;agc_driver_pixel_wave_reductionruns each of its five reductions through a window too, per wave. Both fail on main with the lane-63 refusal.Not tested: console behaviour.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T01:09:20Z.
The body's own claim that this doesn't conflict with #4120 holds, and it's worth stating why precisely: #4120 only changes which registers route through the window on the read side (
GetVectorReg); every windowed register still always gets aStoreVectorWindowon write regardless of #4120's flag. Since this PR'sStoredWindowValueonly ever looks atStoreVectorWindow/LoadVectorWindowinstructions and never touches #4120's flag, the merge order between the two genuinely doesn't matter — unlike #4057, which edits the same function #4120 does and predates its change.The backward-walk terminates safely: each step in
Resolved()'s new loop moves to a value defined strictly earlier in program order (same block, lower position, or a dominating block), and builder IR can't hold the self-referential store that would be needed to cycle, so there's no infinite-loop risk despite no explicit visited set.One wording note for the body, not a functional issue: it describes
0x7e008514(v_movreld_b32) as the thing that stores to the constant slot the matcher reads — it isn't; that instruction's own destination index is a computed (runtime) value, and it's only in the test to make the whole register file windowed. The actual constant-slot stores the matcher forwards through come from ordinary writes to windowed registers elsewhere in the fixture. And0x7ef80500(v_readfirstlane_b32 m0, v0) is correctly load-bearing for the "runtime M0 stops forwarding" case — without it,M0would resolve to an immediate 0 and the walk would fold straight through instead of refusing.Worth naming as a known scope limit, not a defect: the forwarding only looks within the load's own basic block, so a store in a predecessor block still isn't found and the refusal persists there. The PR's "the remaining one is this shape" claim quietly assumes that pixel program's scan and read live in one block — true for the fixture tested, but not something this diff can confirm in general.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-12T02:08:20Z.
A second title for this: Astro's Playroom (PPSA01325) stops 10 s after start on
maind371ed307(Linux, RTX 5080), in a wave64 stage-2 program:With this PR merged onto that
mainthe line is gone. On a local branch that also has the other open PRs the title needs it gets back into gameplay in its first level, as it did before the window change. Onmainplus only this PR one run then segfaulted in the title at 158 s, before its title screen; I have not looked into that and can't say it is related. I kept the dumped request (shader_5000ca100.req) if it is useful for a test.