fix: refuse a FLAT offset with bit 11 set instead of reading it as negative #242
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!242
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/242/head"
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?
@lcg007xd-c on GitHub · 2026-11-25 20:55 UTC · original
lcg007xd-c:fix/flat-offset-bit11→main· +53 −4 · 3 files · 1 commits · merged 2026-11-25 21:46 UTCChange
The reference interpreter (
rdna2_exec_memory._flat) and the HLSL recompiler (rdna2_hlsl_memory._flat) sign-extend the 12-bit offset of every FLAT/GLOBAL/SCRATCH instruction. For the FLAT segment (SEG = 0) that gives a negative offset when bit 11 is set, and the disassembler of this repository disagrees with it:Sources:
llvm-mc -triple=amdgcn -mcpu=gfx1030rejectsflat_load_dword v0, v[1:2] offset:2048andoffset:-1with "expected a 11-bit unsigned offset", and acceptsglobal_load_dword … offset:-1.Neither source says what the hardware does with bit 11 set on FLAT, so following rule 3 both paths now refuse it by name (
Untranslated/Untranslatable: "FLAT offset with bit 11 set (the ISA requires a positive offset)") instead of guessing. FLAT offsets 0-2047 are unchanged. GLOBAL and SCRATCH keep the 12-bit signed offset. The newrdna2_exec_memory.flat_offset(family, word)is shared by the interpreter and HLSL.Linked issue: none. VIctory reads the same field as 11-bit unsigned (Marvisak/VIctory#1636, "GFX10 FLAT offsets ignore bit 11"). That PR gives no measurement, so this PR refuses the case rather than copying the mask; it is a one-line change if you prefer masking.
Verification
Linux (Arch, Python 3.14.10), no C++ runtime, no GPU (runtime and GPU tests skip), rebased on
main400e590:The suite is green on this machine since #237 and #238 merged.
Not run: the Windows CI job and GPU/WARP. The HLSL change is only a refusal: the text generated for valid offsets is unchanged, and the existing GPU tests use GLOBAL.
Oracle and test data
test_flat_offset_is_unsigned_and_bit_11_is_refused(tests/test_rdna2_exec_memory.py):flat_load_dwordwith offset0x7FCloads from base + 2044;Untranslated) and byrdna2_hlsl.translate(Untranslatable);global_load_dwordwith offset −4 still loads from base − 4.mainthe test fails with "DID NOT RAISEUntranslated": the interpreter loaded from base − 2048.Checklist
E_NOTIMPL), never a fake success. (The undocumented case is now refused instead of guessed.)test_readme_sync.pychecks it). (No README change.)Made with AI assistance (Claude Code).
🤖 Generated with Claude Code