rdna2_decode: align MIMG addr, atomic TFE/cmpswap, and r128 widths with LLVM (DECODE-MIMG-PARITY) #633
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!633
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/633/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?
@jarvixaiassistant-glitch on GitHub · 2026-11-24 10:30 UTC · original
jarvixaiassistant-glitch:fix/decode-mimg-llvm-parity→main· +109 −44 · 2 files · 1 commits · merged 2026-11-25 21:21 UTCClaimed in the coordination issue as: DECODE-MIMG-PARITY
What and why
Fixes 72 MIMG disassembly mismatches in the pure-Python RDNA2 decoder (
tools/rdna2_decode.py) uncovered by cross-checking against all 291image_*test vectors in upstream LLVM's official GFX10/GFX1030 disassembler suites (gfx10_mimg.txt,gfx10_mimg_features.txt,gfx1030_new.txt) andAMDGPU::getAddrSizeMIMGOp(llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp):_mimg_addr_count()— matches LLVMAMDGPU::getAddrSizeMIMGOpon GFX10:image_bvh_intersect_ray/image_bvh64_intersect_ray: return8/9VGPRs whena16=True(previously always11/12).image_msaa_load: no longer falsely matches"_l"inside"_load", removing a spurious+1address VGPR (and spurious trailingv0in NSA lists).image_load_mip_pck,image_load_mip_pck_sgn,image_store_mip_pck,*_mip_pck2/4,*_mip_by2/4: include the mip VGPR (previously only exactimage_load_mip/image_store_mipmatched).image_load_by2/by4/image_store_by2/by4: no longer falsely match"_b"as bias.image_sample_*cd*(all 16 coarse-derivative opcodes): tokenize underscore-delimited suffixes (parts = set(name.split("_")[2:])) so"cd"is counted as derivatives instead of falsely triggering z-compare"c"and dropping all derivative VGPRs.image_sample_*_g16(all 16 G16 opcodes): recognize"cl"and"o"before"g16", and pack 16-bit gradients asalignTo<2>(grad_coords)((grad_coords + 1) & ~1:2 / 2 / 4VGPRs for 1D / 2D / 3D instead of2 / 4 / 6).image_get_lod: respectsa16coordinate packing.a16packing: computes(coords + has_lod_or_cl_or_mip + 1) // 2(LLVMdivideCeil(AddrComponents, 2)) instead of(coords + 1) // 2 + extra, fixing 1D/3D/2D-array/cube +lod/cl/mipovercounts by 1 VGPR._mimg_data_count()— atomictfeandcmpswapdmask:0x1:+ (1 if tfe else 0)onimage_atomic_*instead of returning early before TFE (fixing all 26image_atomic_* ... tfevectors ingfx10_mimg_features.txt).image_atomic_cmpswap/image_atomic_fcmpswapreturn2VGPRs fordmask:0x1(and0x3) and4fordmask:0xf, matching LLVM (which has no 1-VGPRcmpswapvariant).r128resource width (rsrc_w):4SGPRs (SReg_128_XNULL) only forimage_bvh*_intersect_rayand8SGPRs (SReg_256_XNULL) for all non-BVH MIMG instructions even whenr128is set, matchingMIMGInstructions.tdandgfx10_mimg.txt.Adds
test_mimg_addr_data_and_rsrc_widths_match_llvmintests/test_rdna2_decode.pycovering all fixed categories with hand-encoded GFX10/GFX1030 words (zero game data), round-trip checked through bothdecode_bytes()anddisasm_bytes()→shader_ir.parse_line().Tested
All synthetic CPU/stdlib/docs/CI checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files, no
llvm-mcinstalled locally):python -I tests/test_rdna2_decode.py -v— 20/20 passed (1 skipped:llvm-mcnot installed)gfx1030_new.txt: 12/12 PASS (was 5/12, 7 mismatches)gfx10_mimg.txt: 253/253 PASS (was 214/253, 39 mismatches)gfx10_mimg_features.txt: 26/26 PASS (was 0/26, 26 mismatches)python -I tests/test_ci_registration.py— 15/15 passedpython -I tests/test_runtime_paths.py— 5/5 passedpython -I scripts/check_no_game_data.py— passed (0 forbidden tracked extensions)python -m compileall -q make_game.py tools tests— passedpython -I tests/test_text_write_line_endings.py,tests/test_report_paths.py,tests/test_i18n_index.py, and alltests/test_docs_*.py— passednode --test tests/test_viewer_streaming.cjs— passedGPUs tested: n/a (pure-Python ISA binary decoder / unit tests only)
AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (N/A — binary ISA decoder parity with LLVMllvm-mconly; no SPIR-V shader-translator rule changed.)Cross-checking tools/rdna2_decode.py against all 291 GFX10/GFX1030 image_* vectors in LLVM's disassembler suite (gfx10_mimg.txt, gfx10_mimg_features.txt, gfx1030_new.txt) found 72 mismatches across three areas: 1. _mimg_addr_count(): - Handle a16 on image_bvh_intersect_ray (8 VGPRs) and image_bvh64_intersect_ray (9 VGPRs), and on image_get_lod. - Stop substring-matching _l inside image_msaa_load, _b inside image_{load,store}_by{2,4}, and _c/_d inside image_sample_*cd*. - Include the mip VGPR for all *_mip* load/store variants (image_load_mip_pck, image_load_mip_pck_sgn, image_store_mip_pck, etc.). - Parse sample/gather modifiers as underscore-delimited tokens so _cl and _o before _g16 are seen, and pack _g16 gradients as alignTo<2>(grad_coords) matching LLVM AMDGPU::getAddrSizeMIMGOp. - Pack (coords + lod/cl/mip) under a16 as (packable + 1) // 2 so odd-coord dims (1D/3D/2D_ARRAY/CUBE) do not overcount by 1 VGPR. 2. _mimg_data_count(): - Add +1 VGPR for tfe on image_atomic_* instead of returning early. - Return 2 VGPRs for image_atomic_{f,}cmpswap with dmask:0x1 (LLVM has no 1-VGPR cmpswap variant). 3. MIMG rsrc_w: - Keep 8 SGPRs (SReg_256_XNULL) for non-BVH MIMG instructions even with r128; only image_bvh*_intersect_ray use 4 SGPRs (SReg_128_XNULL). All 291/291 LLVM GFX10/GFX1030 MIMG vectors now decode with 0 mismatches. AI-assisted: yes (JARVIX: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B).@thesubtleties on GitHub · 2026-11-24 20:30 UTC · original
CPU check of
450cd8105merged onto main3aa97542, with thellvm-mcrun you didn't have (23.1.5). Random MIMG words, kept only where LLVM's text reassembles to the same bytes:test_rdna2_decode.py: 20 passed.run_semantic_tests.py tests/semantic: 470 files / 6,168 tests, 0 failed. Not tested: GPU, game corpus. AI-assisted (Claude Code)@aslan2142 on GitHub · 2026-11-25 21:21 UTC · original
Merged, thanks! The new test fails on
mainand passes with this. With #637 too, the translator suite passes.mainf5bc25cdc+450cd8105: the semantic suite passes (491 files, 6,312 tests, 0 files failed);test_rdna2_decodepass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 2 changed files.AI-assisted (Claude Code, Claude Opus 5.5).