rdna2_decode: permlane16 op_sel and exp null match llvm-mc and shader_ir (DECODE-LLVM-PARITY) #556

Merged
quartz-heron-58 merged 1 commit from upstream-pr/556 into main 2026-11-24 08:54:01 +00:00
quartz-heron-58 commented 2026-11-24 08:00:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by quartz-heron-58 on 2026-11-24T08:00:28Z.


Claimed in the coordination issue as: DECODE-LLVM-PARITY (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7125590718)

What and why

tests/test_rdna2_decode.py test_parity_with_llvm_mc_on_shader_fixtures compares rdna2_decode.decode_bytes with llvm-mc over every runtime/test/shaders/*.asm. On main 1c93c869 with llvm-mc 21.1.8 it fails. It is red in CI on main as well: fiestorra found the same assertion in main's own stdlib-tests-linux job (run 45320704311, head ece4ba5b3; finding in #14), and that run's check and macos-python jobs are failures too.

Correction (edited): this description first said CI skips the test because those jobs have no llvm-mc. That was wrong, a conclusion I drew from reading ci.yml without looking at a run.

Two decoder mismatches, the second hidden behind the first:

  1. v_permlane16_b32 / v_permlanex16_b32 (cs_w32_permlane_fi.asm). These use op_sel bits 0 and 1 as FI and BOUND_CTRL. llvm-mc prints op_sel:[FI,BOUND_CTRL], and nothing when both are 0, whatever bits 2 and 3 hold. The decoder printed the generic [s0,s1,s2,dst] list, e.g. op_sel:[0,1,0,0] for op_sel:[0,1].
  2. exp null (ps_w64_a_discard.asm). shader_ir.parse_line reads the null export target as the special register (core not in ("null",) in its target rule). decode_bytes gave {"k": "target", "t": "null"}, so a decoded exp null did not equal its own printed line parsed back. It now gives the special register for null and a target for every other name.

No translator output changes that I can find: Gen.opsel_bits(mods, 2) reads the first two values either way, and the python disassembly backend goes through disasm_bytes text and shader_ir.parse_line. No contract-table row: no translation rule changes.

Tested

Windows 11 Home build 26300, Python 3.12.10, llvm-mc 21.1.8 (built by scripts\build_llvm_mc.ps1), SPIRV-Tools v2026.4. No game files.

  • python -I tests/test_rdna2_decode.py with LLVM_MC set: 19 tests OK (17 on main, 1 failing). Without LLVM_MC and with no llvm-mc on PATH: 19 OK, 1 skipped.
  • New test_permlane16_opsel_is_the_fi_bound_ctrl_pair: ten op_sel values for each of the two ops, hand-assembled words. Fails on main's decoder. Each expectation was also compared with llvm-mc -disassemble -mcpu=gfx1013 by hand: 20 of 20 equal.
  • New test_exp_null_target_matches_the_parsed_line: exp null and exp mrt0 words from llvm-mc's own encoding.
  • The 22 other standalone test files that import rdna2_decode or shader_disasm: all OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 465 files, 6107 tests, 1 file failed, test_image_cube_store_glc (FileNotFoundError in its llvm-mc round trip). It fails the same way on main without this change; #419 covers it.
  • python -m compileall -q make_game.py tools tests: exit 0. scripts/check_no_game_data.py on both files: exit 0.
  • Not tested: an llvm-mc other than 21.1.8. The parity check was not run against the llvm-mc the Linux CI job uses.

GPUs tested: n/a

AI-assisted: yes (Claude Code found the failure, wrote the change and ran the tests)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5468335447 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/556). Originally posted by [quartz-heron-58](https://github.com/quartz-heron-58) on 2026-11-24T08:00:28Z. --- Claimed in the coordination issue as: DECODE-LLVM-PARITY (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7125590718) ### What and why `tests/test_rdna2_decode.py` `test_parity_with_llvm_mc_on_shader_fixtures` compares `rdna2_decode.decode_bytes` with llvm-mc over every `runtime/test/shaders/*.asm`. On main 1c93c869 with llvm-mc 21.1.8 it fails. It is red in CI on main as well: `fiestorra` found the same assertion in main's own `stdlib-tests-linux` job (run 45320704311, head ece4ba5b3; [finding in #14](https://github.com/ubiquitarianism/leonida/issues/14)), and that run's `check` and `macos-python` jobs are failures too. *Correction (edited): this description first said CI skips the test because those jobs have no llvm-mc. That was wrong, a conclusion I drew from reading `ci.yml` without looking at a run.* Two decoder mismatches, the second hidden behind the first: 1. **`v_permlane16_b32` / `v_permlanex16_b32`** (`cs_w32_permlane_fi.asm`). These use `op_sel` bits 0 and 1 as FI and BOUND_CTRL. llvm-mc prints `op_sel:[FI,BOUND_CTRL]`, and nothing when both are 0, whatever bits 2 and 3 hold. The decoder printed the generic `[s0,s1,s2,dst]` list, e.g. `op_sel:[0,1,0,0]` for `op_sel:[0,1]`. 2. **`exp null`** (`ps_w64_a_discard.asm`). `shader_ir.parse_line` reads the `null` export target as the special register (`core not in ("null",)` in its target rule). `decode_bytes` gave `{"k": "target", "t": "null"}`, so a decoded `exp null` did not equal its own printed line parsed back. It now gives the special register for `null` and a target for every other name. No translator output changes that I can find: `Gen.opsel_bits(mods, 2)` reads the first two values either way, and the `python` disassembly backend goes through `disasm_bytes` text and `shader_ir.parse_line`. No contract-table row: no translation rule changes. ### Tested Windows 11 Home build 26300, Python 3.12.10, llvm-mc 21.1.8 (built by `scripts\build_llvm_mc.ps1`), SPIRV-Tools v2026.4. No game files. - `python -I tests/test_rdna2_decode.py` with `LLVM_MC` set: 19 tests OK (17 on main, 1 failing). Without `LLVM_MC` and with no llvm-mc on PATH: 19 OK, 1 skipped. - New `test_permlane16_opsel_is_the_fi_bound_ctrl_pair`: ten `op_sel` values for each of the two ops, hand-assembled words. Fails on main's decoder. Each expectation was also compared with `llvm-mc -disassemble -mcpu=gfx1013` by hand: 20 of 20 equal. - New `test_exp_null_target_matches_the_parsed_line`: `exp null` and `exp mrt0` words from llvm-mc's own encoding. - The 22 other standalone test files that import `rdna2_decode` or `shader_disasm`: all OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 465 files, 6107 tests, 1 file failed, `test_image_cube_store_glc` (`FileNotFoundError` in its llvm-mc round trip). It fails the same way on main without this change; #419 covers it. - `python -m compileall -q make_game.py tools tests`: exit 0. `scripts/check_no_game_data.py` on both files: exit 0. - Not tested: an llvm-mc other than 21.1.8. The parity check was not run against the llvm-mc the Linux CI job uses. GPUs tested: n/a AI-assisted: yes (Claude Code found the failure, wrote the change and ran the tests) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
QemmHD commented 2026-11-24 08:53:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T08:53:58Z.


Merging. Why merged: permlane16 op_sel and the exp null target now decode the same way as llvm-mc and shader_ir, fixing main's known decode-parity failure.
Why it's good: rdna2_decode is already a listed translator input; on main 1c93c86 the decode tests go from 16 passed (+1 parity failure with LLVM_MC set) to 18 passed / 0 failed (517 subtests); repo-consistency set 563/563.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7126701617 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/556#issuecomment-7126701617). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T08:53:58Z. --- Merging. Why merged: permlane16 op_sel and the exp null target now decode the same way as llvm-mc and shader_ir, fixing main's known decode-parity failure. Why it's good: rdna2_decode is already a listed translator input; on main 1c93c86 the decode tests go from 16 passed (+1 parity failure with LLVM_MC set) to 18 passed / 0 failed (517 subtests); repo-consistency set 563/563. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
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
ProjectLeonida/mandy!556
No description provided.