shader: disasm_rdna2 decodes v_fma_mix* with neg_lo/neg_hi instead of neg/abs operand modifiers #739

Closed
opened 2026-11-23 00:26:12 +00:00 by Ammmae0x · 1 comment
Ammmae0x commented 2026-11-23 00:26:12 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T00:26:12Z.


Commit or build

fd2486f (upstream/main)

Reproduction

Decode the RDNA 2 v_fma_mix_f32 instruction 0c1920cc2c26524c (w0=0xcc20190c, w1=0x4c52262c, where abs bits w0[10:8]=[1,0,0] and neg bits w1[31:29]=[0,1,0]) with tools/disasm_rdna2.py and pass it to tools/pixel_aot.py:parse_fma_mix:

python -B -c "import sys; sys.path.insert(0, 'tools'); from disasm_rdna2 import disasm_rdna2; from pixel_aot import parse_fma_mix; r = disasm_rdna2(bytes.fromhex('0c1920cc2c26524c')); print(r[0]['assembly']); parse_fma_mix(r[0]['assembly'].split(' ', 2)[2])"

Expected behavior

Per the AMD RDNA 2 ISA and tools/pixel_aot.py:1200-1267, v_fma_mix_f32, v_fma_mixlo_f16, and v_fma_mixhi_f16 repurpose VOP3P w1[31:29] as per-source neg (-src) and w0[10:8] as per-source abs (|src|) operand modifiers (op_sel and op_sel_hi retain their bit-type / half-selection roles).

disasm_rdna2 should format 0c1920cc2c26524c with inline operand modifiers (v_fma_mix_f32 v12, |s44|, -v19, v20 op_sel:[1,1,0] op_sel_hi:[1,0,0]) rather than neg_lo: / neg_hi:, so pixel_aot.parse_fma_mix accepts disassembled v_fma_mix* instructions.

Acceptance criteria:

  • In tools/disasm_rdna2.py:1477-1509, render w1[31:29] (neg) and w0[10:8] (abs) as inline - and |...| modifiers on v_fma_mix* source operands instead of emitting neg_lo:[...] / neg_hi:[...].
  • Add v_fma_mix* neg/abs disassembly and disasm_rdna2 -> pixel_aot.parse_fma_mix round-trip tests to tests/rdna2_tools_check.py.

Observed behavior

tools/disasm_rdna2.py:1481-1509 treats w1[31:29] as neg_lo and w0[10:8] as neg_hi for all VOP3P instructions, including v_fma_mix*. This misrepresents abs as neg_hi and causes pixel_aot.parse_fma_mix (tools/pixel_aot.py:1262) to reject the disassembled output:

v_fma_mix_f32 v12, s44, v19, v20 op_sel:[1,1,0] op_sel_hi:[1,0,0] neg_lo:[0,1,0] neg_hi:[1,0,0]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "tools\pixel_aot.py", line 1262, in parse_fma_mix
    raise ValueError(f"Unsupported mixed-precision modifier {mod}")
ValueError: Unsupported mixed-precision modifier neg_lo:[0,1,0]

Environment

Windows 10 Pro 24H2 (build 26100.7623), Python 3.11.15.

Checklist

  • I reproduced this on a source-built input.
  • I did not include game files, dumps, distribution links or credentials.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6549773146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/745). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T00:26:12Z. --- ### Commit or build `fd2486f` (`upstream/main`) ### Reproduction Decode the RDNA 2 `v_fma_mix_f32` instruction `0c1920cc2c26524c` (`w0=0xcc20190c`, `w1=0x4c52262c`, where `abs` bits `w0[10:8]=[1,0,0]` and `neg` bits `w1[31:29]=[0,1,0]`) with `tools/disasm_rdna2.py` and pass it to `tools/pixel_aot.py:parse_fma_mix`: ```powershell python -B -c "import sys; sys.path.insert(0, 'tools'); from disasm_rdna2 import disasm_rdna2; from pixel_aot import parse_fma_mix; r = disasm_rdna2(bytes.fromhex('0c1920cc2c26524c')); print(r[0]['assembly']); parse_fma_mix(r[0]['assembly'].split(' ', 2)[2])" ``` ### Expected behavior Per the AMD RDNA 2 ISA and `tools/pixel_aot.py:1200-1267`, `v_fma_mix_f32`, `v_fma_mixlo_f16`, and `v_fma_mixhi_f16` repurpose VOP3P `w1[31:29]` as per-source `neg` (`-src`) and `w0[10:8]` as per-source `abs` (`|src|`) operand modifiers (`op_sel` and `op_sel_hi` retain their bit-type / half-selection roles). `disasm_rdna2` should format `0c1920cc2c26524c` with inline operand modifiers (`v_fma_mix_f32 v12, |s44|, -v19, v20 op_sel:[1,1,0] op_sel_hi:[1,0,0]`) rather than `neg_lo:` / `neg_hi:`, so `pixel_aot.parse_fma_mix` accepts disassembled `v_fma_mix*` instructions. **Acceptance criteria:** - In `tools/disasm_rdna2.py:1477-1509`, render `w1[31:29]` (`neg`) and `w0[10:8]` (`abs`) as inline `-` and `|...|` modifiers on `v_fma_mix*` source operands instead of emitting `neg_lo:[...]` / `neg_hi:[...]`. - Add `v_fma_mix*` `neg`/`abs` disassembly and `disasm_rdna2` -> `pixel_aot.parse_fma_mix` round-trip tests to `tests/rdna2_tools_check.py`. ### Observed behavior `tools/disasm_rdna2.py:1481-1509` treats `w1[31:29]` as `neg_lo` and `w0[10:8]` as `neg_hi` for all VOP3P instructions, including `v_fma_mix*`. This misrepresents `abs` as `neg_hi` and causes `pixel_aot.parse_fma_mix` (`tools/pixel_aot.py:1262`) to reject the disassembled output: ```text v_fma_mix_f32 v12, s44, v19, v20 op_sel:[1,1,0] op_sel_hi:[1,0,0] neg_lo:[0,1,0] neg_hi:[1,0,0] Traceback (most recent call last): File "<string>", line 1, in <module> File "tools\pixel_aot.py", line 1262, in parse_fma_mix raise ValueError(f"Unsupported mixed-precision modifier {mod}") ValueError: Unsupported mixed-precision modifier neg_lo:[0,1,0] ``` ### Environment Windows 10 Pro 24H2 (build 26100.7623), Python 3.11.15. ### Checklist - [x] I reproduced this on a source-built input. - [x] I did not include game files, dumps, distribution links or credentials. AI-assisted.
R0Y00 commented 2026-11-24 06:48:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T01:09:04Z.


Please use LLVM 15 gfx1013 assembly and disassembly to distinguish the source sign/absolute modifiers from the packed-lane fields. Add a fixture whose operand order and signed values expose a swapped modifier, and check that the disassembled spelling goes through the normal lowerer. Keep the existing packed forms covered.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7088914358 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/745#issuecomment-7088914358). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T01:09:04Z. --- Please use LLVM 15 gfx1013 assembly and disassembly to distinguish the source sign/absolute modifiers from the packed-lane fields. Add a fixture whose operand order and signed values expose a swapped modifier, and check that the disassembled spelling goes through the normal lowerer. Keep the existing packed forms covered.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#739
No description provided.