rdna2spirv: extract per-lane bits for non-mask special sources in s_mov_b32 exec_hi (SHADER-EXEC-HI-SPECIAL-SRC) #1994

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

@⁠ShotTechOp on GitHub · 2026-11-25 17:43 UTC · original
ShotTechOp:fix/exec-hi-special-bits → main · +148 −4 · 3 files · 1 commits · open

Claimed in #1608 as SHADER-EXEC-HI-SPECIAL-SRC.

What and why

  • In tools/rdna2spirv.py, s_mov_b32 exec_lo, <special> falls through to Gen.dst -> Gen.exec_bit, which extracts bit (lane & 31) for every non-mask source (m0, scc/src_scc, plain-data vcc_lo/vcc_hi, etc.).
  • By contrast, the special-cased s_mov_b32 exec_hi, <src> branch only extracted per-lane bits when src["k"] == "sgpr" and otherwise passed raw self.src_u(src) straight into Gen.exec_half_write(1, val, None). Because exec_half_write tests val != 0, any non-zero bit in m0, src_scc, or plain-data vcc_lo/vcc_hi silently activated all 32 upper lanes (32..63) instead of only the lanes whose bits were set.
  • Routing non-mask sources through self.exec_bit(self.src_u(src)) while keeping lane-mask sources (self.holds_lane_mask(src)) on self.src_u(src) brings exec_hi into parity with exec_lo and hardware (both native wave64 and --wave64-emulate).
  • Updated the Constant lane masks / SHADER-1264 contract row in docs/design.md.

Testing

  • AI-assisted: yes.
  • Environment: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally).
  • New regression suite: tests/semantic/test_exec_hi_special_src.py — tests s_mov_b32 exec_hi from m0, plain-data vcc_lo, plain-data vcc_hi (native wave64 and --wave64-emulate), src_scc (0 and 1), and a lane-mask vcc_hi control while confirming exec_lo is preserved.
  • RED control on origin/main (fd33a31): tests/semantic/test_exec_hi_special_src.py fails on origin/main (proving m0, plain-data vcc_lo/vcc_hi, and src_scc = 1 turn on all 32 upper lanes instead of the set bits).
  • GREEN checks on branch:
    • python -I tests/semantic/test_exec_hi_special_src.py -v
    • python -m unittest discover -s tests/semantic -p test_exec_computed.py
    • python -m unittest discover -s tests/semantic -p test_wave64_mov_b32_cross_half.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_exec_hi_special_src.py
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_exec_hi_special_src.py
**@⁠ShotTechOp** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1994) `ShotTechOp:fix/exec-hi-special-bits` → `main` · +148 −4 · 3 files · 1 commits · open Claimed in #1608 as `SHADER-EXEC-HI-SPECIAL-SRC`. ## What and why - In `tools/rdna2spirv.py`, `s_mov_b32 exec_lo, <special>` falls through to `Gen.dst` -> `Gen.exec_bit`, which extracts bit `(lane & 31)` for every non-mask source (`m0`, `scc`/`src_scc`, plain-data `vcc_lo`/`vcc_hi`, etc.). - By contrast, the special-cased `s_mov_b32 exec_hi, <src>` branch only extracted per-lane bits when `src["k"] == "sgpr"` and otherwise passed raw `self.src_u(src)` straight into `Gen.exec_half_write(1, val, None)`. Because `exec_half_write` tests `val != 0`, any non-zero bit in `m0`, `src_scc`, or plain-data `vcc_lo`/`vcc_hi` silently activated all 32 upper lanes (`32..63`) instead of only the lanes whose bits were set. - Routing non-mask sources through `self.exec_bit(self.src_u(src))` while keeping lane-mask sources (`self.holds_lane_mask(src)`) on `self.src_u(src)` brings `exec_hi` into parity with `exec_lo` and hardware (both native wave64 and `--wave64-emulate`). - Updated the `Constant lane masks` / `SHADER-1264` contract row in `docs/design.md`. ## Testing - **AI-assisted**: yes. - **Environment**: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally). - **New regression suite**: `tests/semantic/test_exec_hi_special_src.py` — tests `s_mov_b32 exec_hi` from `m0`, plain-data `vcc_lo`, plain-data `vcc_hi` (native wave64 and `--wave64-emulate`), `src_scc` (`0` and `1`), and a lane-mask `vcc_hi` control while confirming `exec_lo` is preserved. - **RED control on `origin/main` (`fd33a31`)**: `tests/semantic/test_exec_hi_special_src.py` fails on `origin/main` (proving `m0`, plain-data `vcc_lo`/`vcc_hi`, and `src_scc = 1` turn on all 32 upper lanes instead of the set bits). - **GREEN checks on branch**: - `python -I tests/semantic/test_exec_hi_special_src.py -v` - `python -m unittest discover -s tests/semantic -p test_exec_computed.py` - `python -m unittest discover -s tests/semantic -p test_wave64_mov_b32_cross_half.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_exec_hi_special_src.py` - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_exec_hi_special_src.py`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:14:11 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-25 17:45 UTC · original

I confirmed the EXEC high-half fix on an RTX 4090, Windows 11, NVIDIA 616.64. I ran the same seven synthetic compute shaders on parent fd33a31a2 and head 37d433c79, using --wave64-emulate with 32-wide hardware subgroups. Each dispatch writes one word for each of the 64 logical lanes.

GPU check Parent Head
m0, plain-data vcc_lo and plain-data vcc_hi, six masks per source 6/18 18/18
src_scc, false and true 1/2 2/2
Compare-generated mask controls, including low-to-high copies from vcc_lo and s8 3/3 3/3

For example, writing m0 = 0x80000002 to exec_hi enabled all 32 upper lanes on the parent. On the head it enabled exactly lanes 33 and 63. Across the 23 dispatches, incorrect output words fell from 364 to zero out of 1,472. The low-half mask stayed at 0x00000003 and all 16 trailing guard words were intact on every readback. All seven shaders passed Vulkan 1.2 SPIR-V validation on both revisions.

Separately, the head passed all three CPU interpreter tests in test_exec_hi_special_src.py. Hardware coverage here is emulated wave64 on NVIDIA. AI-assisted verification with OpenAI Codex.

**@⁠ecox982745** on GitHub · 2026-11-25 17:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1994#issuecomment-7169961897) I confirmed the EXEC high-half fix on an RTX 4090, Windows 11, NVIDIA 616.64. I ran the same seven synthetic compute shaders on parent `fd33a31a2` and head `37d433c79`, using `--wave64-emulate` with 32-wide hardware subgroups. Each dispatch writes one word for each of the 64 logical lanes. | GPU check | Parent | Head | | --- | ---: | ---: | | `m0`, plain-data `vcc_lo` and plain-data `vcc_hi`, six masks per source | 6/18 | 18/18 | | `src_scc`, false and true | 1/2 | 2/2 | | Compare-generated mask controls, including low-to-high copies from `vcc_lo` and `s8` | 3/3 | 3/3 | For example, writing `m0 = 0x80000002` to `exec_hi` enabled all 32 upper lanes on the parent. On the head it enabled exactly lanes 33 and 63. Across the 23 dispatches, incorrect output words fell from **364 to zero out of 1,472**. The low-half mask stayed at `0x00000003` and all 16 trailing guard words were intact on every readback. All seven shaders passed Vulkan 1.2 SPIR-V validation on both revisions. Separately, the head passed all three CPU interpreter tests in `test_exec_hi_special_src.py`. Hardware coverage here is emulated wave64 on NVIDIA. AI-assisted verification with OpenAI Codex.
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/1994/head:github-bot/gh-1994'
git switch 'github-bot/gh-1994'

Merge

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