Recompiler: Em::scratch treats GFX10.30 SADDR == 0x7F (ST mode) as VADDR, adding v0 to fixed-offset spills #1361
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1361
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@microwave805 on GitHub · 2026-11-24 15:12 UTC · original
Checked on
main(930e8b4).Problem
Em::scratch(crates/xcl/src/gpu/recomp/emit.rs:3845-3853) treatsSADDR == 0x7Fidentically toSADDR == 0x7D, usingv[ADDR](which is encoded as0, i.e.,v0) as the base address:On RDNA2 / GFX10.30 (
HasFlatScratchSTMode),SADDR == 0x7D(NULL) selects VADDR-only mode (vaddr + offset; seetests/data/llvm-amdgpu/gfx10_flat.txt:793:scratch_load_dword v1, v2, off→SADDR=0x7d, ADDR=2), whereasSADDR == 0x7Fselects ST (immediate-only,off, off) mode where bothvaddrandsaddrare disabled (ADDR=0) and the effective address is purely0 + offset(seetests/data/llvm-amdgpu/gfx1030_new.txt:174, 177, 240, e.g.,scratch_store_dword off, v2, off offset:2047→[0xff,0x47,0x70,0xdc,0x00,0x02,0x7f,0x00]).Minimal trigger
Any GFX10.30 shader with constant-offset VGPR spills:
scratch_store_dword off, v2, off offset:16(SADDR=0x7F, ADDR=0, OFFSET=16)v0scratch_load_dword v2, off, off offset:16XCL emits
uint t_a = v0 + 0x10u;for both instead of0x10u, silently corrupting private scratch slots and reloading garbage wheneverv0changes between store and load (or initially holds non-zero values likeSV_VertexID/ PS barycentrics).Suggested fix
Split
0x7Fand0x7DinEm::scratch:(Note: the existing test in
crates/xcl/src/gpu/recomp/tests.rsaroundgpu_more_atomics_sub_dword_scratch_valucurrently encodes VADDR mode withSADDR=0x7F, ADDR=2and should be updated to use0x7Dfor VADDR mode alongside a test of0x7FST mode.)AI use: Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on
930e8b4before opening.github-bot referenced this issue2026-11-26 04:52:03 +00:00
@tiagonogueiraa-bit on GitHub · 2026-11-24 15:14 UTC · original
claiming:
Em::scratchtakesSADDR = 0x7F(ST mode) as address0 + offsetand keeps0x7Das VADDR + offset. I checked both againstllvm-mc -mcpu=gfx1030:scratch_load_dword v1, v2, offencodesSADDR=0x7d, ADDR=2, andscratch_load_dword v1, off, off offset:16encodesSADDR=0x7f, ADDR=0. The existing test's VADDR case moves to0x7D, and an ST-mode test is added. PR within the hour.Written with Claude Code (Claude Opus 5.5).
@Rednaxeh on GitHub · 2026-11-24 15:23 UTC · original · edited 2026-11-24 15:48 UTC
Withdrawn: @tiagonogueiraa-bit claimed this nine minutes before my comment and #1365 is already up; my search predated both. The reference-data pointers above still apply to that PR (
gfx10_flat.txt:793,gfx1030_new.txt:240). Since #1365 has no GPU run yet, I will post one from RDNA3 there.Written with Claude Code (Claude Fable 5.1).