TESTS-DISASM-PARTIAL-SWIZZLE-ENCODING: include gfx1013 encodings in cs_w64x_partial_swizzle disasm fixture #2998

Merged
bobcatchris merged 3 commits from upstream-pr/2998 into main 2026-12-02 01:03:54 +00:00
bobcatchris commented 2026-12-01 22:54:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T22:54:12Z.


Fixes #2977.
Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7328374450.

Cause

runtime/test/shaders/cs_w64x_partial_swizzle.asm carried the regen_fixtures.py marker, which only generates un-encoded straight-line .s listings. Because it contains s_cbranch_execz 9, tools/rdna2spirv.py rejected tests/semantic/fixtures/disasm/cs_w64x_partial_swizzle.s with Unsupported: branch without encoding when running run_gpu_tests.py --disasm-dir tests/semantic/fixtures/disasm.

Fix

  • Remove the straight-line-only ; regen_fixtures: marker from runtime/test/shaders/cs_w64x_partial_swizzle.asm (matching branching fixtures ps_far_branch.asm and ps_pops_wait_loop.asm).
  • Regenerate tests/semantic/fixtures/disasm/cs_w64x_partial_swizzle.s with llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize64,-wavefrontsize32 -show-encoding so every instruction includes its ; encoding: bytes.
  • Add test_disasm_fixture_matches_asm_and_translates in tests/semantic/test_w64x_partial_swizzle.py verifying mnemonic parity with .asm, translation in both native wave64 and --wave64-emulate, check_absent_lane_ub, and emulated execution output [508, 523, 0, 0, 528, 0, 531, 0].

Verification

  • Red -> Green: With the unpatched .s fixture, test_disasm_fixture_matches_asm_and_translates fails with rdna2spirv.Unsupported: branch without encoding (RED_EXIT=1); with the fix, test_w64x_partial_swizzle.py passes (4 passed).
  • tests/semantic/regen_fixtures.py --check, tests/semantic/test_fixtures.py (1 passed), tests/test_regen_fixtures.py (11 passed), tests/test_semantic_translator_use.py (3 passed), and scripts/check_no_game_data.py all pass.
  • Independent read-only code review (including byte-for-byte verification against LLVM 21 llvm-mc and translation across all fixtures/disasm/*.s): approved.

AI-assisted

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5596117557 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2998). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T22:54:12Z. --- Fixes #2977. Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7328374450. ### Cause `runtime/test/shaders/cs_w64x_partial_swizzle.asm` carried the `regen_fixtures.py` marker, which only generates un-encoded straight-line `.s` listings. Because it contains `s_cbranch_execz 9`, `tools/rdna2spirv.py` rejected `tests/semantic/fixtures/disasm/cs_w64x_partial_swizzle.s` with `Unsupported: branch without encoding` when running `run_gpu_tests.py --disasm-dir tests/semantic/fixtures/disasm`. ### Fix - Remove the straight-line-only `; regen_fixtures:` marker from `runtime/test/shaders/cs_w64x_partial_swizzle.asm` (matching branching fixtures `ps_far_branch.asm` and `ps_pops_wait_loop.asm`). - Regenerate `tests/semantic/fixtures/disasm/cs_w64x_partial_swizzle.s` with `llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize64,-wavefrontsize32 -show-encoding` so every instruction includes its `; encoding:` bytes. - Add `test_disasm_fixture_matches_asm_and_translates` in `tests/semantic/test_w64x_partial_swizzle.py` verifying mnemonic parity with `.asm`, translation in both native wave64 and `--wave64-emulate`, `check_absent_lane_ub`, and emulated execution output `[508, 523, 0, 0, 528, 0, 531, 0]`. ### Verification - **Red -> Green**: With the unpatched `.s` fixture, `test_disasm_fixture_matches_asm_and_translates` fails with `rdna2spirv.Unsupported: branch without encoding` (`RED_EXIT=1`); with the fix, `test_w64x_partial_swizzle.py` passes (`4 passed`). - `tests/semantic/regen_fixtures.py --check`, `tests/semantic/test_fixtures.py` (`1 passed`), `tests/test_regen_fixtures.py` (`11 passed`), `tests/test_semantic_translator_use.py` (`3 passed`), and `scripts/check_no_game_data.py` all pass. - Independent read-only code review (including byte-for-byte verification against LLVM 21 `llvm-mc` and translation across all `fixtures/disasm/*.s`): approved. AI-assisted
andrew-ai commented 2026-12-01 23:02:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T23:02:53Z.


Independently assembled the source at 4058dc897 with LLVM 20.1.8 using the gfx1013 wave64 flags in the fixture header. All 58 per-instruction byte sequences match the listing, 304 bytes in total. SHA-256 of the concatenated instruction bytes is be55c9b3553890c9bb72b70483e6e2c6fc774a6e969ee8e51bed5712b0b73e3b.

One coverage detail: all four test_w64x_partial_swizzle.py tests passed on the committed file and also after changing just the branch's encoding from [0x09,0x00,0x88,0xbf] to [0x08,0x00,0x88,0xbf], keeping its printed operand at 9. The current fixture is correct. If the intent is to detect stale encodings too, an optional assembler-backed byte comparison would catch this discrepancy. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328710156 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328710156). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T23:02:53Z. --- Independently assembled the source at 4058dc897 with LLVM 20.1.8 using the gfx1013 wave64 flags in the fixture header. All 58 per-instruction byte sequences match the listing, 304 bytes in total. SHA-256 of the concatenated instruction bytes is be55c9b3553890c9bb72b70483e6e2c6fc774a6e969ee8e51bed5712b0b73e3b. One coverage detail: all four test_w64x_partial_swizzle.py tests passed on the committed file and also after changing just the branch's encoding from [0x09,0x00,0x88,0xbf] to [0x08,0x00,0x88,0xbf], keeping its printed operand at 9. The current fixture is correct. If the intent is to detect stale encodings too, an optional assembler-backed byte comparison would catch this discrepancy. Codex-assisted.
bobcatchris commented 2026-12-01 23:07:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T23:07:08Z.


Updated in fast-forward commit ef4100f54 to address the coverage gap flagged by @andrew-ai:

  • test_disasm_fixture_matches_asm_and_translates in tests/semantic/test_w64x_partial_swizzle.py now parses every instruction's ; encoding: bytes (checking 4/8-byte instruction lengths), verifies s_cbranch_execz's encoded 16-bit signed displacement matches its printed operand (9) and spans the exact byte offset (36 bytes) to s_mov_b64 exec, s[6:7], and cross-checks all instruction encodings against llvm-mc when present on PATH.
  • Verified with PATH="" (no llvm-mc) that changing just s_cbranch_execz's encoding to [0x08,0x00,0x88,0xbf] while leaving operand 9 intact now fails (RED_STALE_DISP=1), and passes with [0x09,0x00,0x88,0xbf] (4 passed).

AI-assisted

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328842538 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328842538). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T23:07:08Z. --- Updated in fast-forward commit `ef4100f54` to address the coverage gap flagged by @andrew-ai: - `test_disasm_fixture_matches_asm_and_translates` in `tests/semantic/test_w64x_partial_swizzle.py` now parses every instruction's `; encoding:` bytes (checking 4/8-byte instruction lengths), verifies `s_cbranch_execz`'s encoded 16-bit signed displacement matches its printed operand (`9`) and spans the exact byte offset (`36` bytes) to `s_mov_b64 exec, s[6:7]`, and cross-checks all instruction encodings against `llvm-mc` when present on `PATH`. - Verified with `PATH=""` (no `llvm-mc`) that changing just `s_cbranch_execz`'s encoding to `[0x08,0x00,0x88,0xbf]` while leaving operand `9` intact now fails (`RED_STALE_DISP=1`), and passes with `[0x09,0x00,0x88,0xbf]` (`4 passed`). AI-assisted
andrew-ai commented 2026-12-01 23:08:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T23:08:03Z.


Rechecked ef4100f54 on Windows without llvm-mc on PATH. All four tests passed with the committed listing. Repeating the original one-byte change now fails with "8 != 9 : encoded branch displacement must match printed operand". That closes the reported branch-displacement gap even without LLVM installed. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328870526 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328870526). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T23:08:03Z. --- Rechecked ef4100f54 on Windows without llvm-mc on PATH. All four tests passed with the committed listing. Repeating the original one-byte change now fails with "8 != 9 : encoded branch displacement must match printed operand". That closes the reported branch-displacement gap even without LLVM installed. Codex-assisted.
merzleckeier commented 2026-12-01 23:09:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T23:09:03Z.


The pre-disassembled GPU case is fixed, but the new optional byte check fails with LLVM 23.1.5.

At ef4100f54 merged onto 913b88b90, python -m unittest discover -s tests/semantic -p test_w64x_partial_swizzle.py passes 4/4 with no llvm-mc on PATH. With LLVM 23.1.5 it passes 3/4 and fails at listing bytes diverged from llvm-mc. The branch still encodes displacement 9 in both outputs. The two v_mbcnt instructions and v_cmp_gt_u32_e64 each have 02 as their last byte in LLVM 23 output where the listing has 00. LLVM 20.1.8 was reported to match exactly. A version-pinned byte check would keep this comparison reproducible across environments.

Separately, I ran the public run_gpu_tests.py --disasm-dir tests/semantic/fixtures/disasm --filter cs_w64x_partial_swizzle with a fresh native Vulkan harness. The original fixture on 002bd88f8 failed translation with branch without encoding in all four lanes. On the current PR all four lanes pass spirv-val. RTX 4070 SUPER (620.73.04) with emulation and Radeon Raphael (RADV 26.3.1) with native and emulated wave64 each read [508, 523, 0, 0, 528, 0, 531, 0]. NVIDIA native dispatch skips as expected because it has no 64-wide compute subgroup. On RADV the separately assembled LLVM 23 path produced byte-identical SPIR-V and the same readback as the fixture in both modes. Synthetic test only. AI-assisted with OpenAI Codex and independent raw-log verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7328902512 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328902512). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T23:09:03Z. --- The pre-disassembled GPU case is fixed, but the new optional byte check fails with LLVM 23.1.5. At `ef4100f54` merged onto `913b88b90`, `python -m unittest discover -s tests/semantic -p test_w64x_partial_swizzle.py` passes 4/4 with no `llvm-mc` on `PATH`. With LLVM 23.1.5 it passes 3/4 and fails at `listing bytes diverged from llvm-mc`. The branch still encodes displacement 9 in both outputs. The two `v_mbcnt` instructions and `v_cmp_gt_u32_e64` each have `02` as their last byte in LLVM 23 output where the listing has `00`. LLVM 20.1.8 was [reported to match exactly](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328710156). A version-pinned byte check would keep this comparison reproducible across environments. Separately, I ran the public `run_gpu_tests.py --disasm-dir tests/semantic/fixtures/disasm --filter cs_w64x_partial_swizzle` with a fresh native Vulkan harness. The original fixture on `002bd88f8` failed translation with `branch without encoding` in all four lanes. On the current PR all four lanes pass `spirv-val`. RTX 4070 SUPER (620.73.04) with emulation and Radeon Raphael (RADV 26.3.1) with native and emulated wave64 each read `[508, 523, 0, 0, 528, 0, 531, 0]`. NVIDIA native dispatch skips as expected because it has no 64-wide compute subgroup. On RADV the separately assembled LLVM 23 path produced byte-identical SPIR-V and the same readback as the fixture in both modes. Synthetic test only. AI-assisted with OpenAI Codex and independent raw-log verification.
bobcatchris commented 2026-12-01 23:15:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T23:15:10Z.


Updated in fast-forward commit 9360f4672 per @merzleckeier's LLVM 23.1.5 report:

  • Removed the optional llvm-mc whole-bytes comparison (encodings(mc_lines) == encs), keeping the deterministic pure-Python encoding-length, signed displacement (enc_disp == printed_disp), and branch target byte-offset checks so the test stays independent of host LLVM version encoding differences in unused OPSEL/VGPR_HI bits while still failing (RED_STALE_DISP=1) if the branch displacement byte diverges from 9.
  • Re-verified test_w64x_partial_swizzle.py (4 passed), test_semantic_translator_use.py (3 passed), and check_no_game_data.py.

AI-assisted

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7329099027 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7329099027). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T23:15:10Z. --- Updated in fast-forward commit `9360f4672` per @merzleckeier's LLVM 23.1.5 report: - Removed the optional `llvm-mc` whole-bytes comparison (`encodings(mc_lines) == encs`), keeping the deterministic pure-Python encoding-length, signed displacement (`enc_disp == printed_disp`), and branch target byte-offset checks so the test stays independent of host LLVM version encoding differences in unused OPSEL/VGPR_HI bits while still failing (`RED_STALE_DISP=1`) if the branch displacement byte diverges from `9`. - Re-verified `test_w64x_partial_swizzle.py` (`4 passed`), `test_semantic_translator_use.py` (`3 passed`), and `check_no_game_data.py`. AI-assisted
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!2998
No description provided.