OLD-7866: restore old upstream PR 7866 - tests/semantic: buffer_load_short_d16_hi keeps both halves in inactive lanes #711

Manually merged
github merged 1 commit from gh-pr/711/head into gh-pr/711/base 2026-11-26 09:17:32 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 12:35 UTC · original
aslan2142:semantic-d16-hi-inactive-lane → main · +95 −0 · 2 files · 1 commits · merged 2026-11-25 22:30 UTC

Claimed in the coordination issue as: OLD-7866 #14

Restoration of my original pull request, old upstream PR 7866 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c; the commit applied unchanged (two new files, no conflicts, no old numbers in it).

What and why

  • A guard, not a fix: main already gets this right. In Gen.buffer_sub (tools/rdna2spirv.py, the end of the function) the loaded half goes in with OpBitFieldInsert and self.dst writes it to active lanes only.
  • The gap: no test checked an inactive lane for a d16 buffer load. test_buffer_sub_dword.py checks an inactive lane only for a store.
  • The fixture: tests/semantic/fixtures/cs_buffer_load_d16_hi_exec.asm is hand-written, wave32.
    • Every lane puts its own value in v5, then EXEC is cut to 0x5AC3A50F.
    • Each lane runs buffer_load_short_d16_hi into v5, then stores v5 from all lanes.
  • The test: tests/semantic/test_buffer_load_d16_hi_exec.py checks:
    • the 16 active lanes get the loaded word in the high half and keep their low half;
    • the 16 inactive lanes keep both halves;
    • the expected values worked out by hand, and that the fixture matches the file.
  • The contract it pins is the existing docs/design.md row "8/16-bit MUBUF d16 loads and stores": "Inactive lanes neither load nor store". No translator rule changes.

Tested

Linux, Python 3.14.10, CPU only (spirv_mini_interp), hand-written fixtures; no game files.

  • python -m unittest discover -s tests/semantic -p test_buffer_load_d16_hi_exec.py: 3 tests OK on this branch. With only these two files copied onto main the result is the same, since main already behaves this way.
  • Mutation check: with the d16 load's result written to every lane (store_reg in place of self.dst, ignoring EXEC), this test fails in all 16 inactive lanes. test_buffer_sub_dword.py still passes with that change, so this is the only test that catches it.
  • python -I scripts/run_semantic_tests.py tests/semantic:
    • main: 465 files, 6 108 tests, 0 failed;
    • this branch: 466 files, 6 111 tests, 0 failed.
  • python -m compileall -q tools tests, git diff --check and python -I scripts/check_no_game_data.py on both new files: clean.

GPUs tested: n/a

AI-assisted: yes

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 rule changes)

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

**@⁠aslan2142** on GitHub · 2026-11-24 12:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/711) `aslan2142:semantic-d16-hi-inactive-lane` → `main` · +95 −0 · 2 files · 1 commits · merged 2026-11-25 22:30 UTC Claimed in the coordination issue as: OLD-7866 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Restoration of my original pull request, old upstream PR 7866 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31; the commit applied unchanged (two new files, no conflicts, no old numbers in it). ### What and why - **A guard, not a fix:** `main` already gets this right. In `Gen.buffer_sub` (`tools/rdna2spirv.py`, the end of the function) the loaded half goes in with `OpBitFieldInsert` and `self.dst` writes it to active lanes only. - **The gap:** no test checked an inactive lane for a d16 buffer *load*. `test_buffer_sub_dword.py` checks an inactive lane only for a store. - **The fixture:** `tests/semantic/fixtures/cs_buffer_load_d16_hi_exec.asm` is hand-written, wave32. - Every lane puts its own value in `v5`, then EXEC is cut to `0x5AC3A50F`. - Each lane runs `buffer_load_short_d16_hi` into `v5`, then stores `v5` from all lanes. - **The test:** `tests/semantic/test_buffer_load_d16_hi_exec.py` checks: - the 16 active lanes get the loaded word in the high half and keep their low half; - the 16 inactive lanes keep both halves; - the expected values worked out by hand, and that the fixture matches the file. - The contract it pins is the existing `docs/design.md` row "8/16-bit MUBUF d16 loads and stores": "Inactive lanes neither load nor store". No translator rule changes. ### Tested Linux, Python 3.14.10, CPU only (`spirv_mini_interp`), hand-written fixtures; no game files. - `python -m unittest discover -s tests/semantic -p test_buffer_load_d16_hi_exec.py`: 3 tests OK on this branch. With only these two files copied onto `main` the result is the same, since `main` already behaves this way. - **Mutation check:** with the d16 load's result written to every lane (`store_reg` in place of `self.dst`, ignoring EXEC), this test fails in all 16 inactive lanes. `test_buffer_sub_dword.py` still passes with that change, so this is the only test that catches it. - `python -I scripts/run_semantic_tests.py tests/semantic`: - `main`: 465 files, 6 108 tests, 0 failed; - this branch: 466 files, 6 111 tests, 0 failed. - `python -m compileall -q tools tests`, `git diff --check` and `python -I scripts/check_no_game_data.py` on both new files: clean. GPUs tested: n/a AI-assisted: yes ### 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 rule changes) AI-assisted (Claude Code, Claude Opus 5.5).
A hand-written wave32 fixture gives every lane its own value in v5, cuts EXEC to 0x5AC3A50F and loads a 16-bit
word per lane into the high half of v5. The 16 active lanes must get the loaded word in the high half and keep
their low half; the 16 inactive lanes must keep both halves. test_buffer_sub_dword.py checked an inactive lane only
for a store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:29 +00:00
github manually merged commit cd92de745f into gh-pr/711/base 2026-11-26 09:17:32 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 12:37 UTC · original · approved these changes

Reviewed and verified OLD-7866. Hand-written fixture \cs_buffer_load_d16_hi_exec.asm\ and semantic test \ est_buffer_load_d16_hi_exec.py\ accurately verify that \uffer_load_short_d16_hi\ updates only the high 16-bits of destination registers in active EXEC lanes while preserving both halves in inactive lanes. Fully clean-room compliant and executable via \spirv_mini_interp. Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 12:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/711#pullrequestreview-6039313448) · **approved these changes** Reviewed and verified OLD-7866. Hand-written fixture \cs_buffer_load_d16_hi_exec.asm\ and semantic test \ est_buffer_load_d16_hi_exec.py\ accurately verify that \uffer_load_short_d16_hi\ updates only the high 16-bits of destination registers in active EXEC lanes while preserving both halves in inactive lanes. Fully clean-room compliant and executable via \spirv_mini_interp\. Approved.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 12:42 UTC · original

Ran cd92de745 on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against main d42773d07:

  • tests/semantic/test_buffer_load_d16_hi_exec.py: 3 tests OK at this head.
  • The same file plus tests/semantic/fixtures/cs_buffer_load_d16_hi_exec.asm on main also passes 3/3, so this restores coverage of behaviour main already has rather than fixing a bug there. Useful as a guard; no GPU run needed (interpreter fixture).

Synthetic fixtures only, no game data. AI-assisted.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 12:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/711#issuecomment-7131806531) Ran `cd92de745` on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against `main` `d42773d07`: - `tests/semantic/test_buffer_load_d16_hi_exec.py`: 3 tests OK at this head. - The same file plus `tests/semantic/fixtures/cs_buffer_load_d16_hi_exec.asm` on `main` also passes 3/3, so this restores coverage of behaviour `main` already has rather than fixing a bug there. Useful as a guard; no GPU run needed (interpreter fixture). Synthetic fixtures only, no game data. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:30 UTC · original

Merged: tests/semantic: buffer_load_short_d16_hi keeps both halves in inactive lanes.

  • Changed since review: Nothing; it merges cleanly with main. As the review noted, main already behaves this way, so this is a regression guard, not a fix.
  • Tested: tests/semantic/test_buffer_load_d16_hi_exec.py passes on main + this head (Linux, CPython 3.14).
  • Checked on main 04221201c + cd92de745: the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 22:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/711#issuecomment-7176443563) Merged: tests/semantic: `buffer_load_short_d16_hi` keeps both halves in inactive lanes. - **Changed since review:** Nothing; it merges cleanly with `main`. As the review noted, `main` already behaves this way, so this is a regression guard, not a fix. - **Tested:** `tests/semantic/test_buffer_load_d16_hi_exec.py` passes on `main` + this head (Linux, CPython 3.14). - **Checked on `main` `04221201c` + `cd92de745`:** the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.