Recompiler: track SMEM register offsets as scalar reads #1540

Open
github-bot wants to merge 1 commit from github-bot/gh-1540 into main AGit
Owner

@⁠oni-swr on GitHub · 2026-11-24 17:25 UTC · original
oni-swr:recompiler/smem-offset-uses → main · +12 −1 · 1 files · 1 commits · open

SMEM's register offset has operand type OPR_SMEM_OFFSET, which sgpr_uses omitted. A register used only as SOFFSET was therefore absent from the read set; the per-lane lowering on gefydev's branch could reject such a load because its initial SGPR value was not loaded. Part of #1269.

What is in it

  • rdna2.rs: include SMEM register offsets in scalar reads; test s4, s7 and NULL offsets, preserving the destination write set.

Tested

  • RX 7800 XT, driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 Pro build 26200; Rust 1.100.0 MSVC; debug.
  • cargo test -p xcl --lib gpu::rdna2::tests::scalar_memory_register_offset_is_a_read -- --exact: on main 9e3831e with only the test added, 0 passed / 1 failed / 0 ignored. The fixed test passes in the full suite below.
  • cargo build --workspace: passed at a8683ef.
  • cargo test --workspace -- --test-threads=4 --nocapture: 777 passed / 0 failed / 41 ignored. One SKIPPED test (included in the harness's passed count): heap_window_out_of_memory_falls_back_to_the_switch_form, reason no heap windows; this is not coverage.
  • 60-second title regression runs below use the debug binary built separately from each commit.

Regression run

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 744 (PresentX 744)
presents per 2 s (last 3): 55 24 0
device removals: 0
crashes: 0
peak commit: 15435 MB
xcl-smoke v1
commit: a8683ef45d1a38e0200558e6666ec965476e5e6b
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 820 (PresentX 820)
presents per 2 s (last 3): 45 12 7
device removals: 0
crashes: 0
peak commit: 16226 MB

Not tested

  • NVIDIA, Wine, release builds. The smoke runs do not exercise the unmerged per-lane DXIL backend; they check the current runtime. No claim of title performance improvement.

AI use

  • T3 Code through Codex, gpt-6.1-sol: investigated the issue and coordination thread, wrote the fix and test, ran validation, and wrote this description.
**@⁠oni-swr** on GitHub · 2026-11-24 17:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540) `oni-swr:recompiler/smem-offset-uses` → `main` · +12 −1 · 1 files · 1 commits · open SMEM's register offset has operand type `OPR_SMEM_OFFSET`, which `sgpr_uses` omitted. A register used only as `SOFFSET` was therefore absent from the read set; the per-lane lowering on gefydev's branch could reject such a load because its initial SGPR value was not loaded. Part of #1269. **What is in it** - `rdna2.rs`: include SMEM register offsets in scalar reads; test s4, s7 and NULL offsets, preserving the destination write set. **Tested** - RX 7800 XT, driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 Pro build 26200; Rust 1.100.0 MSVC; debug. - `cargo test -p xcl --lib gpu::rdna2::tests::scalar_memory_register_offset_is_a_read -- --exact`: on main 9e3831e with only the test added, 0 passed / 1 failed / 0 ignored. The fixed test passes in the full suite below. - `cargo build --workspace`: passed at a8683ef. - `cargo test --workspace -- --test-threads=4 --nocapture`: 777 passed / 0 failed / 41 ignored. One SKIPPED test (included in the harness's passed count): `heap_window_out_of_memory_falls_back_to_the_switch_form`, reason `no heap windows`; this is not coverage. - 60-second title regression runs below use the debug binary built separately from each commit. **Regression run** ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 744 (PresentX 744) presents per 2 s (last 3): 55 24 0 device removals: 0 crashes: 0 peak commit: 15435 MB ``` ``` xcl-smoke v1 commit: a8683ef45d1a38e0200558e6666ec965476e5e6b gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 820 (PresentX 820) presents per 2 s (last 3): 45 12 7 device removals: 0 crashes: 0 peak commit: 16226 MB ``` **Not tested** - NVIDIA, Wine, release builds. The smoke runs do not exercise the unmerged per-lane DXIL backend; they check the current runtime. No claim of title performance improvement. **AI use** - T3 Code through Codex, gpt-6.1-sol: investigated the issue and coordination thread, wrote the fix and test, ran validation, and wrote this description.
SMEM SOFFSET has operand type OPR_SMEM_OFFSET, which sgpr_uses omitted. Include it so clients such as the per-lane lowering initialize the offset register. Test SGPR offsets and NULL; the test fails on main without this change.

Assisted-by: T3 Code / Codex (gpt-6.1-sol)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:55 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 18:13 UTC · original

Read the diff against the ISA tables: the scope is right. In rdna2_spec.rs the only field typed OPR_SMEM_OFFSET is SMEM's SOFFSET (all the S_LOAD / S_BUFFER_LOAD / store / atomic forms). The 21-bit immediate OFFSET is not an operand there, so this can't make an immediate look like an SGPR read. SOFFSET 0 is s0, not NULL (0x7D), so a load with an unset SOFFSET now reads s0, which is right (the same distinction as #1456's test fix). M0 (124) as SOFFSET is a read too, as it should be. I haven't run it.

AI use: Claude Code (Claude Opus 5.5) read the change and wrote this.

**@⁠upipibi** on GitHub · 2026-11-24 18:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540#issuecomment-7140336494) Read the diff against the ISA tables: the scope is right. In `rdna2_spec.rs` the only field typed `OPR_SMEM_OFFSET` is SMEM's `SOFFSET` (all the `S_LOAD` / `S_BUFFER_LOAD` / store / atomic forms). The 21-bit immediate `OFFSET` is not an operand there, so this can't make an immediate look like an SGPR read. `SOFFSET` 0 is s0, not NULL (0x7D), so a load with an unset `SOFFSET` now reads s0, which is right (the same distinction as #1456's test fix). M0 (124) as `SOFFSET` is a read too, as it should be. I haven't run it. AI use: Claude Code (Claude Opus 5.5) read the change and wrote this.
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-24 18:13 UTC · original

Independent NVIDIA and per-lane lowering test for a8683ef45d1a38e0200558e6666ec965476e5e6b.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 (32.0.16.1742), Rust 1.100.0 MSVC, DXC 1.9.2609.5, debug. cargo build --workspace --locked passed. cargo test --locked -p xcl --lib -- --exact gpu::rdna2::tests::scalar_memory_register_offset_is_a_read --test-threads=1 passed.
  • cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output reported 777 passed, 0 failed, and 41 ignored. Three reported GPU skips in that pass count: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), plus heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). The bundled title passed.
  • In a separate worktree at gefydev/xcl:direct-on-1426 revision c391dbf9dedcd87e4e6968a70c0280d5d88aa7dd, I ran cargo test --locked -p xcl --test smem_offset_probe -- --exact register_offset_reaches_per_lane_dxil --nocapture --test-threads=1 with a temporary three-instruction shader before and after applying just the PR’s production change. Before, S_LOAD_DWORD listed s0 and s1 as reads and per-lane lowering refused with s4: a mask read as a number. After, it also listed s4, validated the directly generated DXIL, and executed it on the RTX 5090. Register offsets of 0, 4, and 12 bytes selected the expected three memory words across all 32 lanes each time. Both versions listed s16 as the destination.

Not tested

Retail titles, Wine, or release builds. The per-lane run used a synthetic kernel on the pinned experimental revision with the one-line fix applied locally.

AI use

OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran the checks, and drafted this report.

**@⁠nnonno91** on GitHub · 2026-11-24 18:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540#issuecomment-7140340031) Independent NVIDIA and per-lane lowering test for `a8683ef45d1a38e0200558e6666ec965476e5e6b`. **Tested** - Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 (32.0.16.1742), Rust 1.100.0 MSVC, DXC 1.9.2609.5, debug. `cargo build --workspace --locked` passed. `cargo test --locked -p xcl --lib -- --exact gpu::rdna2::tests::scalar_memory_register_offset_is_a_read --test-threads=1` passed. - `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output` reported 777 passed, 0 failed, and 41 ignored. Three reported GPU skips in that pass count: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64), plus `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). The bundled title passed. - In a separate worktree at `gefydev/xcl:direct-on-1426` revision `c391dbf9dedcd87e4e6968a70c0280d5d88aa7dd`, I ran `cargo test --locked -p xcl --test smem_offset_probe -- --exact register_offset_reaches_per_lane_dxil --nocapture --test-threads=1` with a temporary three-instruction shader before and after applying just the PR’s production change. Before, `S_LOAD_DWORD` listed `s0` and `s1` as reads and per-lane lowering refused with `s4: a mask read as a number`. After, it also listed `s4`, validated the directly generated DXIL, and executed it on the RTX 5090. Register offsets of 0, 4, and 12 bytes selected the expected three memory words across all 32 lanes each time. Both versions listed `s16` as the destination. **Not tested** Retail titles, Wine, or release builds. The per-lane run used a synthetic kernel on the pinned experimental revision with the one-line fix applied locally. **AI use** OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran the checks, and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 19:12 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 19:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540#issuecomment-7141768038) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠vakaobr on GitHub · 2026-11-25 09:28 UTC · original

Test report from a Mac (D3DMetal), #1540 at a8683ef merged into main c4d37be.

The per-lane form refuses every kernel whose s_load_dword names an SGPR as SOFFSET that the program didn't write first: s_load_dword s4, s[2:3], s0, 0x8 and the same with s1 both give s0 / s1: a mask read as a number on main. With the same register as an s_add_u32 source, or after an s_mov_b32 writes it, it's accepted, which fits your reading (the prologue never loads a register sgpr_uses doesn't list). In my differential harness that was 995 of 1000 generated programs refused on main.

Tested

  • MacBook Pro M5 Pro (20-core GPU, 32-lane waves), macOS 27.2.1, CrossOver 26.3 with D3DMetal 3.0, Rosetta 2, Rust 1.100.0 x86_64-pc-windows-gnu, debug, DXC 1.9.2609. Each test in its own process.
  • gpu::rdna2::tests::scalar_memory_register_offset_is_a_read: 1 passed.
  • 9 single-instruction kernels through lower_dxil::kernel_split (SOFFSET s0, s1, null, s0 after s_mov_b32, and s0 / s1 as ALU sources): refused 2 on main, all 9 accepted with this PR.
  • 1000 generated programs, HLSL path against #1426's per-instruction form: 0 differences with this PR, as on main.
  • 1000 generated programs without divergent ifs, HLSL path against the per-lane form: 996 identical and 0 refused with this PR (995 refused on main). The other 4 differ in the HLSL path only; the per-lane and per-instruction forms agree with each other there (details on #1269).

Not tested

  • Windows, the whole suite, a title; compute mode (lower_dxil::compute*), where the same sgpr_uses list may decide which user SGPRs are loaded.

AI use: Claude Code, Claude Opus 5.5 found the refusals with the harness, ran the tests above on this machine and wrote this report.

**@⁠vakaobr** on GitHub · 2026-11-25 09:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540#issuecomment-7158391021) Test report from a Mac (D3DMetal), #1540 at `a8683ef` merged into `main` `c4d37be`. The per-lane form refuses every kernel whose `s_load_dword` names an SGPR as `SOFFSET` that the program didn't write first: `s_load_dword s4, s[2:3], s0, 0x8` and the same with `s1` both give `s0` / `s1`: `a mask read as a number` on `main`. With the same register as an `s_add_u32` source, or after an `s_mov_b32` writes it, it's accepted, which fits your reading (the prologue never loads a register `sgpr_uses` doesn't list). In my differential harness that was 995 of 1000 generated programs refused on `main`. **Tested** - MacBook Pro M5 Pro (20-core GPU, 32-lane waves), macOS 27.2.1, CrossOver 26.3 with D3DMetal 3.0, Rosetta 2, Rust 1.100.0 `x86_64-pc-windows-gnu`, debug, DXC 1.9.2609. Each test in its own process. - `gpu::rdna2::tests::scalar_memory_register_offset_is_a_read`: 1 passed. - 9 single-instruction kernels through `lower_dxil::kernel_split` (`SOFFSET` `s0`, `s1`, null, `s0` after `s_mov_b32`, and `s0` / `s1` as ALU sources): refused 2 on `main`, all 9 accepted with this PR. - 1000 generated programs, HLSL path against #1426's per-instruction form: 0 differences with this PR, as on `main`. - 1000 generated programs without divergent `if`s, HLSL path against the per-lane form: 996 identical and 0 refused with this PR (995 refused on `main`). The other 4 differ in the HLSL path only; the per-lane and per-instruction forms agree with each other there (details on #1269). **Not tested** - Windows, the whole suite, a title; compute mode (`lower_dxil::compute*`), where the same `sgpr_uses` list may decide which user SGPRs are loaded. AI use: Claude Code, Claude Opus 5.5 found the refusals with the harness, ran the tests above on this machine and wrote this report.
Author
Owner

@⁠throny on GitHub · 2026-11-25 10:28 UTC · original

Test report for exact head a8683ef.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 MSVC; DXC 1.9.2602.17; tests in debug, title runs in release.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on a8683ef as it is (its own base): 777 passed, 0 failed, 41 ignored. SKIPPED: 3 lines (no wave64 on this adapter, and the like).
  • scripts/smoke.ps1, the retail title, 60 s, release builds, main 568e7db first, then this head. Both runs started without the preload list newer builds leave behind (used-pipelines.txt in the DXIL cache), which makes builds on an older base run out of memory at start:

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14538 MB

PR:

xcl-smoke v1
commit: a8683ef45d1a38e0200558e6666ec965476e5e6b
gpu: NVIDIA GeForce RTX 4080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1597 (PresentX 1597)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14763 MB

Not tested: AMD, the head merged onto current main, a world load.

AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.

**@⁠throny** on GitHub · 2026-11-25 10:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540#issuecomment-7159746424) Test report for exact head `a8683ef`. **Tested** - Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 MSVC; DXC 1.9.2602.17; tests in debug, title runs in release. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` on `a8683ef` as it is (its own base): **777 passed, 0 failed, 41 ignored**. `SKIPPED`: 3 lines (no wave64 on this adapter, and the like). - `scripts/smoke.ps1`, the retail title, 60 s, release builds, `main` `568e7db` first, then this head. Both runs started without the preload list newer builds leave behind (`used-pipelines.txt` in the DXIL cache), which makes builds on an older base run out of memory at start: main: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1608 (PresentX 1608) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14538 MB ``` PR: ``` xcl-smoke v1 commit: a8683ef45d1a38e0200558e6666ec965476e5e6b gpu: NVIDIA GeForce RTX 4080 title: retail-title seconds: 60 exit: 0x0 frames shown: 1597 (PresentX 1597) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14763 MB ``` **Not tested:** AMD, the head merged onto current `main`, a world load. AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
Author
Owner

@⁠ClosetPie107 on GitHub · 2026-11-26 06:48 UTC · original

AMD RDNA4 / Linux (Proton Experimental) test report on head a8683ef4 (merged cleanly onto main b49be183):

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv b540c8a2 + relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu

Isolated unit tests (main b49be183 + #1540 a8683ef4, debug, --test-threads=1):

  • xcl.exe gpu::rdna2:: -- --test-threads=1: 19 passed, 0 failed, 0 ignored (0 skipped).

Combined 300 s retail sanity run (release, main b49be183 + #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressing A past menus):

  • Completed full 300 s (exit=0), 0 crashes, 0 device removals, 2,014 PresentX frames, 131,072 translated draws, 660,943 dispatches (44,546 chained split-compute dispatches), 102,631 Opus packets (0 errors).

Not tested

  • Native Windows, full workspace test suite, or #1540 alone in a retail run.

AI use

  • T3 Code / Antigravity (Gemini 4 Neon) merged #1540 onto main, ran the Proton unit tests and combined retail run on this machine, and drafted this report.
**@⁠ClosetPie107** on GitHub · 2026-11-26 06:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/1540#issuecomment-7184809053) AMD RDNA4 / Linux (Proton Experimental) test report on head `a8683ef4` (merged cleanly onto `main` `b49be183`): **Hardware & environment** - AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux - Proton Experimental (`experimental-11.0-20261112`), `vkd3d-proton` `master` `ec207194` (3.2.0) + `dxil-spirv` `b540c8a2` + relaxed-vtable patch (`-Db_ndebug=true`), DXVK `v3.1.1-209`, DXC `1.9.2609.5`, Rust `x86_64-pc-windows-gnu` **Isolated unit tests** (`main` `b49be183` + #1540 `a8683ef4`, debug, `--test-threads=1`): - `xcl.exe gpu::rdna2:: -- --test-threads=1`: **19 passed, 0 failed, 0 ignored** (0 skipped). **Combined 300 s retail sanity run** (release, `main` `b49be183` + #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressing `A` past menus): - Completed full **300 s (`exit=0`)**, **0 crashes**, **0 device removals**, `2,014` `PresentX` frames, `131,072` translated draws, `660,943` dispatches (`44,546` chained split-compute dispatches), `102,631` Opus packets (0 errors). **Not tested** - Native Windows, full workspace test suite, or #1540 alone in a retail run. **AI use** - T3 Code / Antigravity (Gemini 4 Neon) merged #1540 onto `main`, ran the Proton unit tests and combined retail run on this machine, and drafted this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1540/head:github-bot/gh-1540'
git switch 'github-bot/gh-1540'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1540'
git switch 'github-bot/gh-1540'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1540'
git switch 'github-bot/gh-1540'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1540'
git switch 'main'
git merge --squash 'github-bot/gh-1540'
git switch 'main'
git merge --ff-only 'github-bot/gh-1540'
git switch 'main'
git merge 'github-bot/gh-1540'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.