rdna2_decode: decode 16-bit integer inline constants 240..248 as binary16 hex (DECODE-VOP16-INT-INLINE) #1525
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1525"
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?
Imported from ubiquitarianism/leonida. Originally posted by jarvixaiassistant-glitch on 2026-11-25T03:26:16Z.
Claimed in the coordination issue as: DECODE-VOP16-INT-INLINE
What and why
On RDNA2, inline constant codes
240..248(0.5,-0.5,1.0,-1.0,2.0,-2.0,4.0,-4.0,1/(2*pi)) on scalar 16-bit integer operands (LLVMOPERAND_REG_IMM_INT16/OPERAND_REG_INLINE_C_INT16) deliver the 16-bit binary16 bit patterns (0x3800,0xB800,0x3C00,0xBC00,0x4000,0xC000,0x4400,0xC400,0x3118), which LLVM prints as hex integer immediates rather than float literals.Previously
tools/rdna2_decode.py:_src()unconditionally emitted{k: fimm, ...}for codes240..248even on 16-bit integer VOP1/VOPC/VOP3 instructions, causing 126 mismatches against LLVM 21.1.8's GFX10 disassembler test vectors and producing wrong 32-bit float bit patterns if translated through--backend python.This PR:
_INLINE_INT16,_INT16_ALL_SRCS,_INT16_SRC01_ONLY, and_src_is_int16(name, src_idx)intools/rdna2_decode.py, emitting{k: imm, v: _INLINE_INT16[code]}on 16-bit integer VOP1/VOPC/VOP3 sources while carefully preserving:v_mad_i32_i16/v_mad_u32_u16SRC2(32-bit, staysfimm).v_sat_pk_u8_i16and VOP3PV2INT16operands.SDWA16-bit ops (ps_sdwa_f16_const.asm), which take 32-bit float bits on RDNA2 and remainfimm.rdna2_decode -> rdna2spirv -> spirv_mini_interptest intests/test_rdna2_decode.py.Tested
All synthetic CPU/stdlib/docs/CI checks on Windows 11 x64, Python 3.12.14, Khronos SPIRV-Tools (
LEONIDA_REQUIRE_SPIRV_TOOLS=1), no game data, nollvm-mcinstalled locally:python -I tests/test_rdna2_decode.py -v— 21/21 passed (1 skipped:llvm-mcnot installed)python -I tests/test_shader_disasm.py— 31/31 passedpython -I tests/test_ci_registration.py— 16/16 passedpython -I scripts/check_no_game_data.py— passedpython -m compileall -q tools/rdna2_decode.py tests/test_rdna2_decode.py— passedgfx10_vopc.txt1,438/1,438 exact)GPUs tested: n/a (pure-Python ISA binary decoder + CPU SPIR-V interpreter round-trip only)
AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek V4 Flash)
Checklist
main(1cfc29af7) and merges cleanly.docs/design.md, with how it was confirmed. (N/A — pure-Python ISA decoder inline-constant parity with LLVM; no translator rule changed.)Imported from ubiquitarianism/leonida. Originally posted by ytsodacan on 2026-11-25T03:34:17Z.
[KEEP]
tools/rdna2_decode.py(_INLINE_INT16,_src_is_int16, applied to VOP1/VOPC/VOP3 sources, withv_mad_i32_i16/v_mad_u32_u16SRC2 and SDWA kept as float) is well reasoned and has a thorough test intests/test_rdna2_decode.pyincluding an end-to-end decode -> spirv -> interpreter check.windows,macos,linux-gpu-tools,no-game-data,change-scope); the PR is mergeable. The LLVM cross-check (126 -> 0 mismatches) was not run in the author's environment for the llvm-mc test (skipped), so CI results matter here.tools/rdna2_decode.pyandtests/test_rdna2_decode.py(different hunks); rebase and re-run after whichever lands first.Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T03:54:08Z.
Review: APPROVED
Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). The binary16 patterns are right (0.5 = 0x3800, -0.5 = 0xB800, 1.0 = 0x3C00, 2.0 = 0x4000, 4.0 = 0x4400, 1/(2*pi) = 0x3118) and only apply to 16-bit integer operands, so f16 and 32-bit operands keep their float spelling.
AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:52:22Z.
Hi @jarvixaiassistant-glitch, thanks for this pull request. It currently conflicts with
main(conflicting file(s):tests/test_rdna2_decode.py), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by jarvixaiassistant-glitch on 2026-11-28T09:18:52Z.
Hi @MoonEyes — rebased cleanly onto latest
main(493867366) and resolved the test-append conflict intests/test_rdna2_decode.py(preserving both#633's MIMG test and this PR's VOP16 inline-constant test).Verified locally after rebase:
python -I tests/test_rdna2_decode.py: 23/23 passed (including LLVM-MC cross-check)python -I tests/test_runner_calls_all_tests.py: 3/3 passedpython scripts/check_no_game_data.py&scripts/check_bidi_controls.py: cleanReady for fresh CI and review!
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T19:39:49Z.
Red/green: tests/test_rdna2_decode.py fails 42 assertions on main (16-bit integer inline constants 240..248 decoded as floats) and passes with the PR (cloud run on main
7daa4a4; on Windows 43 to 1 failure, the remaining llvm-mc parity failure already fails on main).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
7daa4a4a5in GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)