Repository navigation
rdna2_decode: v_permlane16/x16_b32 op_sel is two bits, not four - #6036
abilliontokens wants to merge 1 commit into
Conversation
VOP3 v_permlane16_b32 and v_permlanex16_b32 carry only FI and BOUND_CTRL in op_sel[1:0] (docs/design.md SHADER-74; rdna2spirv reads them via opsel_bits(mods, 2)). The decoder printed the generic VOP3 shape [s0,s1,s2,dst], e.g. op_sel:[0,1,0,0], while llvm-mc prints op_sel:[0,1]. Emit two bits for opcodes 0x377/0x378 so decode_bytes matches llvm-mc. Verified: new unit test fails on main (4 subtests, op_sel:[0,1,0,0] vs [0,1]) and passes with the fix; tests/test_rdna2_decode.py parity vs llvm-mc 23.1.0 now passes cs_w32_permlane_fi.asm (the remaining ps_sdwa_f16_const.asm failure is the known llvm-mc disasm quirk covered by open PR ItsNotRexed#5013).
|
One decoder parity case remains at For example, run these commands from the checkout root with LLVM 21.1.8 and CPython 3.14.7: '0x0a 0x20 0x77 0xd7 0x02 0x09 0x14 0x00' | llvm-mc -triple=amdgcn -mcpu=gfx1013 --disassemble
py -3.14 -I -c "import sys; sys.path.insert(0,'tools'); import rdna2_decode as d; print(d.decode_bytes(bytes.fromhex('0a2077d702091400'))['insns'][0]['mods'])"LLVM prints I checked both opcodes with selector values 0, 1, 2, 3, 4 and 8. The first four agree with LLVM. Values 4 and 8 give the difference above on both opcodes. With AI-assisted. |
|
Checked the retail reach of both the fix and the remaining synthetic parity case at I decoded the recorded instruction bytes with the parent and PR decoder and compared each instruction to the corresponding LLVM listing, ignoring whitespace. The parent disagreed on 362 instructions, all in the selector. The PR agreed on all 9,021, including every instance where LLVM omitted the selector. Thus the still-open CPU only, CachyOS, AI-assisted. Only counts are included. |
|
Independent CPU verification on Windows 11 (Python 3.14.0a4, head
Clean fix and ready to land. AI-assisted. |
|
Tested A full decoder-vs-llvm-mc scan of every
On 21.1.8 the only remaining difference is |
|
Tested
AI-assisted (OpenCode / DeepSeek V4.1 Flash + GLM-5.3): the agent ran the suite sandboxed on the toolchain above. |
|
Tested |
|
Tested
Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047. |
|
Checked
#8044 fixes the same mismatch for |
What
tools/rdna2_decode.pyprinted VOP3v_permlane16_b32/v_permlanex16_b32op_selwith the generic VOP3 width —op_sel:[s0,s1,s2,dst](4 bits) — whilellvm-mcprintsop_sel:[s0,s1](2 bits). These two ops carry only FI and BOUND_CTRL inop_sel[1:0](docs/design.md SHADER-74;rdna2spirvreads them viaopsel_bits(mods, 2)), so the extra two bits were noise that broke decode parity.Example on
runtime/test/shaders/cs_w32_permlane_fi.asm:Fix
Emit 2
op_selbits for opcodes0x377/0x378(v_permlane16_b32,v_permlanex16_b32); all other VOP3/VOPC ops keep the existingnsrc/nsrc+1rule. New unit testtest_vop3_permlane_opsel_is_two_bitscovers both ops, bothop_selvalues, and the no-modifier case, using encodings assembled withllvm-mc -mcpu=gfx1013.Verification (Windows 11, python 3.12, LLVM 23.1.0 at C:/Users/james/AppData/Local/Leonida/llvm-mc)
main561b65a8→ 4 subtests FAIL (op_sel:[0,1,0,0]vs[0,1]).python -I tests/test_rdna2_decode.py→ the permlane parity failure is gone;cs_w32_permlane_fi.asmnow matches llvm-mc on every instruction.ps_sdwa_f16_const.asm(llvm-mc's assembler/disassembler disagree on an SDWA literal word) — that defect is already covered by open PR rdna2_decode parity: skip llvm-mc's SDWA inline-constant disassembly quirk #5013 and is untouched here.AI-assisted (omp orchestrator). Item claimed in the coordination thread (#5934 comment 7101670067). No game data.