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

Open
opened 2026-11-26 21:19:39 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1983
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/mov64-vcc-data-and-null


📝 Commits (1)

  • 8ad6efc rdna2spirv: fix plain-data VCC source and null operands in Gen.mov64

📊 Changes

3 files changed (+173 additions, -4 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_mov64_vcc_data_and_null.py (+158 -0)
📝 tools/rdna2spirv.py (+14 -3)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1983 **Author:** [@ShotTechOp](https://github.com/ShotTechOp) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/mov64-vcc-data-and-null` --- ### 📝 Commits (1) - [`8ad6efc`](https://github.com/ubiquitarianism/leonida/commit/8ad6efc6a103e7dd88db3a8ada7107087bbd1ac2) rdna2spirv: fix plain-data VCC source and null operands in Gen.mov64 ### 📊 Changes **3 files changed** (+173 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_mov64_vcc_data_and_null.py` (+158 -0) 📝 `tools/rdna2spirv.py` (+14 -3) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1990
No description provided.