Recompiler: use SGPR masks for scalar-load availability invalidation #2747

Open
opened 2026-11-26 11:14:36 +00:00 by github-bot · 0 comments
Owner

@⁠KOLESNiii on GitHub · 2026-11-26 09:50 UTC · original

Part of #2088 and #2508. Related to #2746 and #2479. Reviewed on main at b49be18.

reload::analyze checks every tracked load address after an instruction changes any scalar register. For each address it tries up to 128 register numbers to test whether the instruction touched the base pair or offset register. It repeats this during the fixed-point iteration and again when recording load reuse. The ordinary direct DXIL path consumes the result. Address components · Invalidation and iteration · Ordinary emitter

Precompute one u128 dependency mask per tracked address and invalidate it when the mask intersects changes()'s existing register mask. This gives the same test for the base, base+1, and offset, including the current handling of the offset sentinel. Keep memory clobbers, transfer order, and instruction effects as they are. This is independent of #2479's instruction-effect corrections and #2746's proposal to skip the analysis when compact emission discards it.

A standalone Linux probe with Rust 1.100.0 -O on a Ryzen AI 7 350 ran the main analyzer and a copy with only this predicate changed. Three synthetic CFGs each had 32,769 decoded instructions and 8,193 reachable blocks. The medians over five runs per variant were:

Distinct load addresses Main Precomputed mask
16 99.1 ms 4.3 ms
128 743.7 ms 7.3 ms
256 1,468.7 ms 11.9 ms

Every reported slot and availability decision agreed. A separate eight-load fixture also agreed on reuse, invalidation by a base register write, a barrier, an overlapping offset register write, and an unrelated write that preserved reuse. These are analyzer timings. Windows, total translation time and retail loading remain unmeasured.

For the upstream change, keep the existing analysis tests and verify that the ordinary translator emits identical DXIL for a fixed synthetic corpus. Measure translation with cold XCL caches before extrapolating to a title.

AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static analysis, the standalone Linux probe, and drafting.

**@⁠KOLESNiii** on GitHub · 2026-11-26 09:50 UTC · [original](https://github.com/xcl-dev/xcl/issues/2747) Part of #2088 and #2508. Related to #2746 and #2479. Reviewed on `main` at `b49be18`. `reload::analyze` checks every tracked load address after an instruction changes any scalar register. For each address it tries up to 128 register numbers to test whether the instruction touched the base pair or offset register. It repeats this during the fixed-point iteration and again when recording load reuse. The ordinary direct DXIL path consumes the result. [Address components](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/reload.rs#L75-L87) · [Invalidation and iteration](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/reload.rs#L181-L253) · [Ordinary emitter](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/dxil/kernel.rs#L346-L378) Precompute one `u128` dependency mask per tracked address and invalidate it when the mask intersects `changes()`'s existing register mask. This gives the same test for the base, base+1, and offset, including the current handling of the offset sentinel. Keep memory clobbers, transfer order, and instruction effects as they are. This is independent of #2479's instruction-effect corrections and #2746's proposal to skip the analysis when compact emission discards it. A standalone Linux probe with Rust 1.100.0 `-O` on a Ryzen AI 7 350 ran the main analyzer and a copy with only this predicate changed. Three synthetic CFGs each had 32,769 decoded instructions and 8,193 reachable blocks. The medians over five runs per variant were: | Distinct load addresses | Main | Precomputed mask | | --- | ---: | ---: | | 16 | 99.1 ms | 4.3 ms | | 128 | 743.7 ms | 7.3 ms | | 256 | 1,468.7 ms | 11.9 ms | Every reported slot and availability decision agreed. A separate eight-load fixture also agreed on reuse, invalidation by a base register write, a barrier, an overlapping offset register write, and an unrelated write that preserved reuse. These are analyzer timings. Windows, total translation time and retail loading remain unmeasured. For the upstream change, keep the existing analysis tests and verify that the ordinary translator emits identical DXIL for a fixed synthetic corpus. Measure translation with cold XCL caches before extrapolating to a title. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static analysis, the standalone Linux probe, and drafting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:14:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.