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

Manually merged
github merged 3 commits from github-bot/gh-2998 into gh-pr/2998/base 2026-12-02 01:04:30 +00:00 AGit
Owner

@⁠bobcatchris on GitHub · 2026-12-01 22:54 UTC · original
bobcatchris:fix/tests-disasm-partial-swizzle-encoding → main · +107 −61 · 3 files · 3 commits · merged 2026-12-02 01:03 UTC

Fixes #2977.
Addresses claim in #2570.

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

**@⁠bobcatchris** on GitHub · 2026-12-01 22:54 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2998) `bobcatchris:fix/tests-disasm-partial-swizzle-encoding` → `main` · +107 −61 · 3 files · 3 commits · merged 2026-12-02 01:03 UTC Fixes #2977. Addresses claim in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/2570. ### 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 23:00:21 +00:00
Author
Owner

@⁠andrew-ai on GitHub · 2026-12-01 23:02 UTC · original

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.

**@⁠andrew-ai** on GitHub · 2026-12-01 23:02 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328710156) 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.
Author
Owner

@⁠bobcatchris on GitHub · 2026-12-01 23:07 UTC · original

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

**@⁠bobcatchris** on GitHub · 2026-12-01 23:07 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328842538) 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
Author
Owner

@⁠andrew-ai on GitHub · 2026-12-01 23:08 UTC · original

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.

**@⁠andrew-ai** on GitHub · 2026-12-01 23:08 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328870526) 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.
Author
Owner

@⁠merzleckeier on GitHub · 2026-12-01 23:09 UTC · original

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.

**@⁠merzleckeier** on GitHub · 2026-12-01 23:09 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7328902512) 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://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2998). 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.
Author
Owner

@⁠bobcatchris on GitHub · 2026-12-01 23:15 UTC · original

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

**@⁠bobcatchris** on GitHub · 2026-12-01 23:15 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2998#issuecomment-7329099027) 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
github-bot changed target branch from main to gh-pr/2998/base 2026-12-02 01:04:22 +00:00
github manually merged commit 9360f46726 into gh-pr/2998/base 2026-12-02 01:04:30 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!2998
No description provided.