rdna2spirv: preserve %vcc_hi on plain-data s_mov_b64 from vcc and support null operands (SHADER-MOV64-VCC-DATA-AND-NULL) #1983

Open
github-bot wants to merge 1 commit from github-bot/gh-1983 into main AGit
Owner

@⁠ShotTechOp on GitHub · 2026-11-25 17:23 UTC · original
ShotTechOp:fix/mov64-vcc-data-and-null → main · +173 −4 · 3 files · 1 commits · open

Claimed in #1608 as SHADER-MOV64-VCC-DATA-AND-NULL.

What and why

In Gen.mov64() (tools/rdna2spirv.py), s_mov_b64 had two gaps:

  1. Silent high-word corruption on s_mov_b64 s[D:D+1], vcc when vcc holds plain 64-bit scalar data:
    • mov64() unconditionally duplicated %vcc into both halves (lo = hi = OpLoad %uint %vcc), assuming vcc always held a per-lane mask.
    • When vcc holds plain 64-bit scalar data (not self.holds_lane_mask(s), e.g. written via s_mov_b32 vcc_lo, ...; s_mov_b32 vcc_hi, ...), s_mov_b64 s[6:7], vcc silently overwrote s7 with %vcc instead of %vcc_hi.
  2. null source / destination rejected:
    • s_mov_b64 s[6:7], null raised Unsupported("s_mov_b64 source") instead of writing (0, 0), and s_mov_b64 null, <src> raised Unsupported("s_mov_b64 destination") instead of validating the source and discarding the write (matching s_not_b64 / dst64_data(..., allow_null=True)).

Changes

  • tools/rdna2spirv.py:
    • In Gen.mov64(), check self.holds_lane_mask(s) when s is vcc: keep lo = hi = OpLoad %uint %vcc for lane masks, and load both %vcc and %vcc_hi when vcc holds plain scalar data.
    • Accept null as a source ((0, 0), also seeding sgpr_imm with 0) and as a discard destination (after validating the source operand).
  • docs/design.md:
    • Documented the s_mov_b64 null and plain-data vcc contract in the Null mask source row.
  • tests/semantic/test_mov64_vcc_data_and_null.py:
    • Covers s_mov_b64 s[6:7], vcc with plain 64-bit data in both wave64 and FSPX wave32, vcc transitioning from a lane mask to plain data, s_mov_b64 s[6:7], null, s_mov_b64 null, <valid> + invalid source rejection, and a real lane-mask vcc control.

Verification

  • AI-assisted: yes.
  • Environment: Windows 11 (Python 3.12.10, CPU-only / spirv_mini_interp; no GPU, LLVM, or SPIRV-Tools installed locally).
  • Tests run (all GREEN):
    • python -I tests/semantic/test_mov64_vcc_data_and_null.py -v
    • python -m unittest discover -s tests/semantic -p test_salu64_bitwise_data.py
    • python -m unittest discover -s tests/semantic -p test_fspx_wave_size.py
    • python -m unittest discover -s tests/semantic -p test_salu_b32_lane_masks.py
    • python -m unittest discover -s tests -p "test_docs_*.py"
    • python -I tests/test_text_write_line_endings.py
    • python -m compileall -q tools/rdna2spirv.py tests/semantic/test_mov64_vcc_data_and_null.py
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_mov64_vcc_data_and_null.py
    • git diff --check
  • Negative control against origin/main (tools/rdna2spirv.py at fe15534): tests/semantic/test_mov64_vcc_data_and_null.py fails on origin/main across all 3 bug tests (s_mov_b64 s[6:7], vcc returns [lo, lo] instead of [lo, hi] across all 12 wave64/wave32/transition subtests, and s_mov_b64 s[6:7], null raises Unsupported: s_mov_b64 source), while the lane-mask control passes.
**@⁠ShotTechOp** on GitHub · 2026-11-25 17:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1983) `ShotTechOp:fix/mov64-vcc-data-and-null` → `main` · +173 −4 · 3 files · 1 commits · open Claimed in #1608 as `SHADER-MOV64-VCC-DATA-AND-NULL`. ### What and why In `Gen.mov64()` (`tools/rdna2spirv.py`), `s_mov_b64` had two gaps: 1. **Silent high-word corruption on `s_mov_b64 s[D:D+1], vcc` when `vcc` holds plain 64-bit scalar data**: - `mov64()` unconditionally duplicated `%vcc` into both halves (`lo = hi = OpLoad %uint %vcc`), assuming `vcc` always held a per-lane mask. - When `vcc` holds plain 64-bit scalar data (`not self.holds_lane_mask(s)`, e.g. written via `s_mov_b32 vcc_lo, ...; s_mov_b32 vcc_hi, ...`), `s_mov_b64 s[6:7], vcc` silently overwrote `s7` with `%vcc` instead of `%vcc_hi`. 2. **`null` source / destination rejected**: - `s_mov_b64 s[6:7], null` raised `Unsupported("s_mov_b64 source")` instead of writing `(0, 0)`, and `s_mov_b64 null, <src>` raised `Unsupported("s_mov_b64 destination")` instead of validating the source and discarding the write (matching `s_not_b64` / `dst64_data(..., allow_null=True)`). ### Changes - **`tools/rdna2spirv.py`**: - In `Gen.mov64()`, check `self.holds_lane_mask(s)` when `s` is `vcc`: keep `lo = hi = OpLoad %uint %vcc` for lane masks, and load both `%vcc` and `%vcc_hi` when `vcc` holds plain scalar data. - Accept `null` as a source (`(0, 0)`, also seeding `sgpr_imm` with `0`) and as a discard destination (after validating the source operand). - **`docs/design.md`**: - Documented the `s_mov_b64` `null` and plain-data `vcc` contract in the `Null mask source` row. - **`tests/semantic/test_mov64_vcc_data_and_null.py`**: - Covers `s_mov_b64 s[6:7], vcc` with plain 64-bit data in both wave64 and FSPX wave32, `vcc` transitioning from a lane mask to plain data, `s_mov_b64 s[6:7], null`, `s_mov_b64 null, <valid>` + invalid source rejection, and a real lane-mask `vcc` control. ### Verification - **AI-assisted**: yes. - **Environment**: Windows 11 (Python 3.12.10, CPU-only / `spirv_mini_interp`; no GPU, LLVM, or SPIRV-Tools installed locally). - **Tests run (all GREEN)**: - `python -I tests/semantic/test_mov64_vcc_data_and_null.py -v` - `python -m unittest discover -s tests/semantic -p test_salu64_bitwise_data.py` - `python -m unittest discover -s tests/semantic -p test_fspx_wave_size.py` - `python -m unittest discover -s tests/semantic -p test_salu_b32_lane_masks.py` - `python -m unittest discover -s tests -p "test_docs_*.py"` - `python -I tests/test_text_write_line_endings.py` - `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_mov64_vcc_data_and_null.py` - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_mov64_vcc_data_and_null.py` - `git diff --check` - **Negative control against `origin/main` (`tools/rdna2spirv.py` at `fe15534`)**: `tests/semantic/test_mov64_vcc_data_and_null.py` fails on `origin/main` across all 3 bug tests (`s_mov_b64 s[6:7], vcc` returns `[lo, lo]` instead of `[lo, hi]` across all 12 wave64/wave32/transition subtests, and `s_mov_b64 s[6:7], null` raises `Unsupported: s_mov_b64 source`), while the lane-mask control passes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:13:47 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1983/head:github-bot/gh-1983'
git switch 'github-bot/gh-1983'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1983'
git switch 'github-bot/gh-1983'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1983'
git switch 'github-bot/gh-1983'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1983'
git switch 'main'
git merge --squash 'github-bot/gh-1983'
git switch 'main'
git merge --ff-only 'github-bot/gh-1983'
git switch 'main'
git merge 'github-bot/gh-1983'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.