[PR #1990] rdna2spirv: keep plain-data VCC sources on the 64-bit data path in is_mask_op and src64_data (SHADER-SALU64-VCC-DATA-SRC) #1997

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

📋 Pull Request Information

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

Base: main ← Head: fix/salu64-vcc-data-src


📝 Commits (1)

  • 74031f0 rdna2spirv: keep plain-data VCC sources on the 64-bit data path

📊 Changes

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

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_salu64_vcc_data_src.py (+257 -0)
📝 tools/rdna2spirv.py (+6 -3)

📄 Description

Claimed in #1608 as SHADER-SALU64-VCC-DATA-SRC.

What and why

  • Gen.is_mask_op in tools/rdna2spirv.py previously returned True unconditionally whenever an operand was vcc, vcc_lo, or vcc_hi, even when lane_masks.py proved vcc holds plain scalar data (for example after s_mov_b32 vcc_lo, ... / s_mov_b32 vcc_hi, ...).
    • Gen.holds_lane_mask already returns True unconditionally for exec/exec_lo/exec_hi and returns True for vcc/vcc_lo/vcc_hi only when vcc actually holds a lane mask ("vcc" in self.cur_masks).
    • Because of the unconditional vcc branch in is_mask_op:
      1. s_not_b64, s_{and,or,xor,andn2,orn2,nand,nor,xnor}_b64, and s_cselect_b64 with a plain-data vcc source took the per-lane mask path, dropping %vcc_hi and the high dword of the paired SGPR, duplicating the low 32-bit word into both destination dwords, and voting SCC across the wave instead of testing (D.lo | D.hi) != 0.
      2. s_cmov_b64, s_quadmask_b32/s_quadmask_b64, and s_bitreplicate_b64_b32 falsely rejected plain-data vcc/vcc_lo operands as lane masks.
  • Gen.src64_data also rejected plain-data vcc operands with Unsupported("<op> source"). Adding a not self.holds_lane_mask(s) branch to load (%vcc, %vcc_hi) fixes all src64_data consumers while keeping lane-mask vcc sources rejected as Unsupported.
  • Updated the 64-bit scalar bitwise ops 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_salu64_vcc_data_src.py — covers all 9 64-bit bitwise ops in both operand orders (s_and_b64..s_xnor_b64, s_not_b64) with high-word-only non-zero SCC checks, s_cselect_b64, s_cmov_b64, s_quadmask_b64, s_bitreplicate_b64_b32, mask-to-data VCC overwrite, and lane-mask VCC preservation/rejection controls.
  • RED control on origin/main (fe15534): tests/semantic/test_salu64_vcc_data_src.py fails on origin/main (proving both silent miscompilation of the high dword / SCC in the bitwise + s_cselect_b64 ops and false Unsupported errors in s_cmov_b64 / s_quadmask_b64 / s_bitreplicate_b64_b32).
  • GREEN checks on branch:
    • python -I tests/semantic/test_salu64_vcc_data_src.py -v
    • python -m unittest discover -s tests/semantic -p test_salu64_bitwise_data.py
    • python -m unittest discover -s tests/semantic -p test_scselect_b64_data.py
    • python -m unittest discover -s tests/semantic -p test_salu_cmov_b64.py
    • python -m unittest discover -s tests/semantic -p test_salu_quadmask_bitreplicate.py
    • python -m unittest discover -s tests/semantic -p test_lane_mask_bitreplicate_flbit.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_salu64_vcc_data_src.py
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_salu64_vcc_data_src.py

🔄 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/1990 **Author:** [@ShotTechOp](https://github.com/ShotTechOp) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/salu64-vcc-data-src` --- ### 📝 Commits (1) - [`74031f0`](https://github.com/ubiquitarianism/leonida/commit/74031f03cfa39a3755a3f6b9eff731be685dbeee) rdna2spirv: keep plain-data VCC sources on the 64-bit data path ### 📊 Changes **3 files changed** (+264 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_salu64_vcc_data_src.py` (+257 -0) 📝 `tools/rdna2spirv.py` (+6 -3) </details> ### 📄 Description Claimed in #1608 as `SHADER-SALU64-VCC-DATA-SRC`. ## What and why - `Gen.is_mask_op` in `tools/rdna2spirv.py` previously returned `True` unconditionally whenever an operand was `vcc`, `vcc_lo`, or `vcc_hi`, even when `lane_masks.py` proved `vcc` holds plain scalar data (for example after `s_mov_b32 vcc_lo, ...` / `s_mov_b32 vcc_hi, ...`). - `Gen.holds_lane_mask` already returns `True` unconditionally for `exec`/`exec_lo`/`exec_hi` and returns `True` for `vcc`/`vcc_lo`/`vcc_hi` only when `vcc` actually holds a lane mask (`"vcc" in self.cur_masks`). - Because of the unconditional `vcc` branch in `is_mask_op`: 1. `s_not_b64`, `s_{and,or,xor,andn2,orn2,nand,nor,xnor}_b64`, and `s_cselect_b64` with a plain-data `vcc` source took the per-lane mask path, dropping `%vcc_hi` and the high dword of the paired SGPR, duplicating the low 32-bit word into both destination dwords, and voting `SCC` across the wave instead of testing `(D.lo | D.hi) != 0`. 2. `s_cmov_b64`, `s_quadmask_b32`/`s_quadmask_b64`, and `s_bitreplicate_b64_b32` falsely rejected plain-data `vcc`/`vcc_lo` operands as lane masks. - `Gen.src64_data` also rejected plain-data `vcc` operands with `Unsupported("<op> source")`. Adding a `not self.holds_lane_mask(s)` branch to load `(%vcc, %vcc_hi)` fixes all `src64_data` consumers while keeping lane-mask `vcc` sources rejected as `Unsupported`. - Updated the `64-bit scalar bitwise ops` 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_salu64_vcc_data_src.py` — covers all 9 64-bit bitwise ops in both operand orders (`s_and_b64`..`s_xnor_b64`, `s_not_b64`) with high-word-only non-zero SCC checks, `s_cselect_b64`, `s_cmov_b64`, `s_quadmask_b64`, `s_bitreplicate_b64_b32`, mask-to-data VCC overwrite, and lane-mask VCC preservation/rejection controls. - **RED control on `origin/main` (`fe15534`)**: `tests/semantic/test_salu64_vcc_data_src.py` fails on `origin/main` (proving both silent miscompilation of the high dword / SCC in the bitwise + `s_cselect_b64` ops and false `Unsupported` errors in `s_cmov_b64` / `s_quadmask_b64` / `s_bitreplicate_b64_b32`). - **GREEN checks on branch**: - `python -I tests/semantic/test_salu64_vcc_data_src.py -v` - `python -m unittest discover -s tests/semantic -p test_salu64_bitwise_data.py` - `python -m unittest discover -s tests/semantic -p test_scselect_b64_data.py` - `python -m unittest discover -s tests/semantic -p test_salu_cmov_b64.py` - `python -m unittest discover -s tests/semantic -p test_salu_quadmask_bitreplicate.py` - `python -m unittest discover -s tests/semantic -p test_lane_mask_bitreplicate_flbit.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_salu64_vcc_data_src.py` - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_salu64_vcc_data_src.py` --- <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#1997
No description provided.