Recompiler: align S_LOAD address components before addition #1230

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

@⁠rison1337 on GitHub · 2026-11-24 13:25 UTC · original
rison1337:codex/smem-component-alignment → main · +50 −4 · 3 files · 1 commits · open

S_LOAD aligns the sum of its address components, allowing discarded low bits to carry into bit 2 and read the next dword. Align each component before addition, as specified by RDNA2 ISA 7.2.1, preserving signed negative immediates.

What is in it

  • gpu/recomp/emit.rs: correct single-window and multi-window S_LOAD addresses.
  • gpu/recomp/tests.rs: synthetic GPU regression covering all five load widths, four base alignments, independent offsets, negative immediates and a null-offset control. It fails on unchanged main (0xCAFE0001 instead of 0xCAFE0000) and passes with the fix. README names the corrected rule.

Tested

  • RTX 4060 8 GB, driver 32.0.16.2101; Ryzen 5 7500F; Windows 11 26300; Rust 1.100.0, x86_64-pc-windows-msvc, release; DXC 1.9.2609.5.
  • cargo build --locked --release --workspace --target x86_64-pc-windows-msvc -j4: succeeded.
  • cargo test --locked --release --workspace --target x86_64-pc-windows-msvc -j4 --no-fail-fast -- --test-threads=4 --nocapture: 742 passed, 0 failed, 41 ignored. Four bodies reported SKIPPED: two native-wave64 tests and two requiring the absent D3D12 debug layer; these returns are included in Cargo's passed count.
  • 60 s, no input, 2 DXC threads. An earlier cold-DXIL comparison showed 1535 frames on main and 1287 with the fix. The warm-DXIL comparison below shows 1521 and 1449; the PR run was repeated after push. All ended at 30 presents/s. These counts include startup and compilation; no FPS improvement is claimed.

Regression run
Main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 4060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1521 (PresentX 1521)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14578 MB

This commit:

xcl-smoke v1
commit: 1a447e60a4138993f3d73332942fbfa9c839097b
gpu: NVIDIA GeForce RTX 4060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1449 (PresentX 1449)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14635 MB

Not tested

  • AMD/native wave64, D3D12 debug layer, or XCL_SAMPLE_* inputs.
  • Retail world loading and whether the title executes this misalignment case. These smoke runs remain at the first-run screens.

AI use

  • OpenAI Codex with GPT-6.1 Sol: implementation, test, description and local validation commands. The user reviews and publishes manually.
**@⁠rison1337** on GitHub · 2026-11-24 13:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230) `rison1337:codex/smem-component-alignment` → `main` · +50 −4 · 3 files · 1 commits · open S_LOAD aligns the sum of its address components, allowing discarded low bits to carry into bit 2 and read the next dword. Align each component before addition, as specified by [RDNA2 ISA 7.2.1](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture), preserving signed negative immediates. **What is in it** - `gpu/recomp/emit.rs`: correct single-window and multi-window S_LOAD addresses. - `gpu/recomp/tests.rs`: synthetic GPU regression covering all five load widths, four base alignments, independent offsets, negative immediates and a null-offset control. It fails on unchanged main (0xCAFE0001 instead of 0xCAFE0000) and passes with the fix. README names the corrected rule. **Tested** - RTX 4060 8 GB, driver 32.0.16.2101; Ryzen 5 7500F; Windows 11 26300; Rust 1.100.0, x86_64-pc-windows-msvc, release; DXC 1.9.2609.5. - `cargo build --locked --release --workspace --target x86_64-pc-windows-msvc -j4`: succeeded. - `cargo test --locked --release --workspace --target x86_64-pc-windows-msvc -j4 --no-fail-fast -- --test-threads=4 --nocapture`: 742 passed, 0 failed, 41 ignored. Four bodies reported SKIPPED: two native-wave64 tests and two requiring the absent D3D12 debug layer; these returns are included in Cargo's passed count. - 60 s, no input, 2 DXC threads. An earlier cold-DXIL comparison showed 1535 frames on main and 1287 with the fix. The warm-DXIL comparison below shows 1521 and 1449; the PR run was repeated after push. All ended at 30 presents/s. These counts include startup and compilation; no FPS improvement is claimed. **Regression run** Main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 4060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1521 (PresentX 1521) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14578 MB ``` This commit: ``` xcl-smoke v1 commit: 1a447e60a4138993f3d73332942fbfa9c839097b gpu: NVIDIA GeForce RTX 4060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1449 (PresentX 1449) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14635 MB ``` **Not tested** - AMD/native wave64, D3D12 debug layer, or XCL_SAMPLE_* inputs. - Retail world loading and whether the title executes this misalignment case. These smoke runs remain at the first-run screens. **AI use** - OpenAI Codex with GPT-6.1 Sol: implementation, test, description and local validation commands. The user reviews and publishes manually.
The RDNA2 ISA 7.2.1 ignores each S_LOAD address component's low two
bits. Truncating only their sum lets discarded bits carry into bit 2
and makes a scalar load read the next dword. Align the base, signed
immediate and unsigned scalar offset before adding them in both memory
window modes. Preserve sign extension for negative immediates.

The synthetic GPU regression fails on unchanged main (0xCAFE0001 read
instead of 0xCAFE0000) and passes with the fix. It covers all five load
widths, all four base alignments, independently unaligned offsets,
negative immediates, a null-offset control and both window modes.

Validated on RTX 4060 / Windows 11: release workspace build succeeds;
workspace tests: 742 passed, 0 failed, 41 ignored. Four GPU test bodies
skip for missing native wave64 or the D3D12 debug layer.

Assisted-by: OpenAI Codex (GPT-6.1 Sol)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:52 +00:00
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 13:28 UTC · original

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@47efa2e (baseline 741 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
742 passed; 0 failed; 41 ignored   (exit 0)

One more passing test than the baseline; the S_LOAD address-component alignment rule ships its case and runs green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

**@⁠dcastell1** on GitHub · 2026-11-24 13:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230#issuecomment-7132879782) Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@47efa2e` (baseline **741 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 742 passed; 0 failed; 41 ignored (exit 0) ``` One more passing test than the baseline; the S_LOAD address-component alignment rule ships its case and runs green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:39 UTC · original

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

  • cargo test -p xcl --lib recomp: 190 passed, 0 failed, 18 ignored (new GPU checks included).

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 13:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230#issuecomment-7133144109) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib recomp`: 190 passed, 0 failed, 18 ignored (new GPU checks included). Thanks!
Author
Owner

@⁠bjarngard on GitHub · 2026-11-24 13:47 UTC · original

Test report for head 1a447e6 (AMD, native wave64)

Tested

  • AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, no SKIPPED
  • With XCL_REQUIRE_GPU=wave64: gpu_smem_aligns_each_address_component passed

Not tested: retail titles, RDNA3/RDNA4.

AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.

**@⁠bjarngard** on GitHub · 2026-11-24 13:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230#issuecomment-7133351812) Test report for head `1a447e6` (AMD, native wave64) **Tested** - AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug - `XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4`: 742 passed, 0 failed, 41 ignored, no SKIPPED - With `XCL_REQUIRE_GPU=wave64`: `gpu_smem_aligns_each_address_component` passed **Not tested:** retail titles, RDNA3/RDNA4. **AI use:** the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-25 08:26 UTC · original

Test report for head 1a447e6 as pushed (not merged onto current main) – NVIDIA, wave32.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (Ampere, 32-lane waves only), driver 32.0.16.2124; AMD Ryzen 5 7500F; Windows NT 10.0.26300; Rust 1.100.0 (stable-x86_64-pc-windows-msvc); debug; DXC 1.9.2609.5
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests on this adapter: 2 (no wave64)
  • this PR's tests: gpu_smem_aligns_each_address_component ran and passed
  • no XCL_SAMPLE_* data set (game-data tests not run)

Not tested

  • AMD / native wave64; release build; a smoke run on a title; the head merged onto current main

AI use

  • Claude (Claude Opus 5.5) wrote the script that ran the suite on my PC, read the log and wrote this report; the run is mine.
**@⁠xpatfussy69x** on GitHub · 2026-11-25 08:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230#issuecomment-7157024771) Test report for head `1a447e6` as pushed (not merged onto current `main`) – NVIDIA, wave32. **Tested** - NVIDIA GeForce RTX 3060 12 GB (Ampere, 32-lane waves only), driver 32.0.16.2124; AMD Ryzen 5 7500F; Windows NT 10.0.26300; Rust 1.100.0 (stable-x86_64-pc-windows-msvc); debug; DXC 1.9.2609.5 - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 742 passed, 0 failed, 41 ignored - SKIPPED GPU tests on this adapter: 2 (no wave64) - this PR's tests: `gpu_smem_aligns_each_address_component` ran and passed - no `XCL_SAMPLE_*` data set (game-data tests not run) **Not tested** - AMD / native wave64; release build; a smoke run on a title; the head merged onto current `main` **AI use** - Claude (Claude Opus 5.5) wrote the script that ran the suite on my PC, read the log and wrote this report; the run is mine.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:17 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 04:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230#issuecomment-7182462433) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Author
Owner

@⁠pvfreis on GitHub · 2026-11-24 14:41 UTC · original · reviewed

Review of 1a447e6 (merge base 47efa2e), by reading the code against AMD's RDNA2 ISA guide (section 7.2.1, scalar memory addressing); nothing was built or run here. The s_load change matches that section, which has each address component (base, instruction offset, SGPR/M0 offset) drop its two low bits before they are added; the test checks fixed expected values. No defect in this PR.

A question outside the PR: the same section describes s_buffer_load differently. There the instruction offset and SGPR offset are added as they are and only the final address is dword-aligned, which matches the unchanged branch, but the low two bits of the V# base are also ignored. The s_buffer_load branch adds the V# base unmasked (({d0} + {t}_off) & ~3u, emit.rs:1497-1505; unchanged since the first commit). Is that deliberate, e.g. something a title relies on, or would masking {d0} first fit the spec? It only matters for a V# base with low bits set.

Review by Claude Code (written by Claude Opus 5.5, checked against the ISA guide by Claude Opus 5.5); each point checked by a person before posting.

**@⁠pvfreis** on GitHub · 2026-11-24 14:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1230#pullrequestreview-6041311761) · **reviewed** Review of `1a447e6` (merge base `47efa2e`), by reading the code against AMD's RDNA2 ISA guide (section 7.2.1, scalar memory addressing); nothing was built or run here. The `s_load` change matches that section, which has each address component (base, instruction offset, SGPR/M0 offset) drop its two low bits before they are added; the test checks fixed expected values. No defect in this PR. A question outside the PR: the same section describes `s_buffer_load` differently. There the instruction offset and SGPR offset are added as they are and only the final address is dword-aligned, which matches the unchanged branch, but the low two bits of the V# base are also ignored. The `s_buffer_load` branch adds the V# base unmasked (`({d0} + {t}_off) & ~3u`, `emit.rs:1497-1505`; unchanged since the first commit). Is that deliberate, e.g. something a title relies on, or would masking `{d0}` first fit the spec? It only matters for a V# base with low bits set. Review by Claude Code (written by Claude Opus 5.5, checked against the ISA guide by Claude Opus 5.5); each point checked by a person before posting.
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/1230/head:github-bot/gh-1230'
git switch 'github-bot/gh-1230'

Merge

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