Recompiler: in compute programs an S# set before a branch samples through sampler-heap entry 0 #2835

Open
opened 2026-11-26 17:02:09 +00:00 by github-bot · 0 comments
Owner

@⁠pvfreis on GitHub · 2026-11-26 16:57 UTC · original

A plan before a PR, for the part 82e4a9bb (on nvidia-dev, in #2572) leaves out: compute programs. On main (b49be183; the code is
the same at 8b957bec) constant_samplers forgets S# constants at every block start, so a sample after a branch falls back to
SamplerDescriptorHeap[S#.word3 & 0x7FF]. For an S# built in code those are the low bits of the border-colour pointer, usually 0
(RDNA2 ISA §8.2.7; a branch writes only the PC, §4.2, §12.5). 82e4a9bb follows the constants in vertex and pixel programs only. In 60
compute programs of one retail title (a set picked for another measurement) that is 162 of 5,629 samples, in 15 of the 49 programs that
sample; in a 1-in-10 sample of its shader pack, 308 of 11,481 in 47 of 178. All of them have index 0.

  • Follow S# constants across blocks for kernel and compute programs in the shared helper (HLSL and direct DXIL): a register is a constant
    at a block's start only when every block that leads there leaves the same one; a program with a branch whose target is not known is
    read block by block as today; s_movreld forgets everything.
  • Unit and GPU tests that fail on main and pass with it, including the cases that must keep the heap lookup (other words on one path,
    s_load, s_movreld, an S# from memory).
  • Base: main, about 100 changed lines outside tests. If #2572 lands first it becomes: 82e4a9bb's follow also on for kernel and compute,
    the s_movreld case, the tests, and 82e4a9bb's assertion that other programs stay block by block changed (its test fails with this, as
    it should). I can send that form to nvidia-dev instead.
  • The symptom 82e4a9bb names for compute (2,055 ExecuteIndirect counts out of range in 75 s, then a device hang): not reproduced, cause
    still unknown. nvidia-dev af2cecc4 + the second form, one title run on an RTX 3060 (empty DXIL cache, XCL_PREPARE=0, the
    ExecuteIndirect guard at its default): 0 counts out of range (the log does not show how many the guard checked), no device removal; no
    present after 282 s, stopped by our memory guard at 450 s (37 GiB private). The same tree without it, one run, 465 s: none either.
    On that title this makes the same samples static as fbfac4d0 did (the two functions on the same instructions: no difference in the 60
    programs or in the 269 of the pack sample), so it does not avoid the symptom by finding fewer.

Overlaps #1573 (rewrites the same loop on main) and #2572 (carries 82e4a9bb).

AI use: Claude Code (Claude Opus 5.5) wrote the change and the tests, ran the counts and the title runs, and wrote this; Claude Fable 5.2 rechecked it.

**@⁠pvfreis** on GitHub · 2026-11-26 16:57 UTC · [original](https://github.com/xcl-dev/xcl/issues/2835) A plan before a PR, for the part 82e4a9bb (on `nvidia-dev`, in #2572) leaves out: **compute programs**. On `main` (`b49be183`; the code is the same at `8b957bec`) `constant_samplers` forgets S# constants at every block start, so a sample after a branch falls back to `SamplerDescriptorHeap[S#.word3 & 0x7FF]`. For an S# built in code those are the low bits of the border-colour pointer, usually 0 (RDNA2 ISA §8.2.7; a branch writes only the PC, §4.2, §12.5). 82e4a9bb follows the constants in vertex and pixel programs only. In 60 compute programs of one retail title (a set picked for another measurement) that is 162 of 5,629 samples, in 15 of the 49 programs that sample; in a 1-in-10 sample of its shader pack, 308 of 11,481 in 47 of 178. All of them have index 0. - Follow S# constants across blocks for kernel and compute programs in the shared helper (HLSL and direct DXIL): a register is a constant at a block's start only when every block that leads there leaves the same one; a program with a branch whose target is not known is read block by block as today; `s_movreld` forgets everything. - Unit and GPU tests that fail on `main` and pass with it, including the cases that must keep the heap lookup (other words on one path, `s_load`, `s_movreld`, an S# from memory). - Base: `main`, about 100 changed lines outside tests. If #2572 lands first it becomes: 82e4a9bb's `follow` also on for kernel and compute, the `s_movreld` case, the tests, and 82e4a9bb's assertion that other programs stay block by block changed (its test fails with this, as it should). I can send that form to `nvidia-dev` instead. - The symptom 82e4a9bb names for compute (2,055 ExecuteIndirect counts out of range in 75 s, then a device hang): not reproduced, cause still unknown. `nvidia-dev` `af2cecc4` + the second form, one title run on an RTX 3060 (empty DXIL cache, `XCL_PREPARE=0`, the ExecuteIndirect guard at its default): 0 counts out of range (the log does not show how many the guard checked), no device removal; no present after 282 s, stopped by our memory guard at 450 s (37 GiB private). The same tree without it, one run, 465 s: none either. On that title this makes the same samples static as fbfac4d0 did (the two functions on the same instructions: no difference in the 60 programs or in the 269 of the pack sample), so it does not avoid the symptom by finding fewer. Overlaps #1573 (rewrites the same loop on `main`) and #2572 (carries 82e4a9bb). AI use: Claude Code (Claude Opus 5.5) wrote the change and the tests, ran the counts and the title runs, and wrote this; Claude Fable 5.2 rechecked it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 17:02:09 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.