[PR #2360] rdna2spirv: handle mixed mask pairs, wave32 VCC, and mask bit indices in s_bitcmp0/1_b32/b64 (SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS) #2362

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

📋 Pull Request Information

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

Base: main ← Head: fix/bitcmp64-mixed-and-special-srcs


📝 Commits (1)

  • c26efd2 rdna2spirv: handle mixed mask pairs, wave32 VCC, and mask bit indices in s_bitcmp0/1_b32/b64 (SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS)

📊 Changes

3 files changed (+290 additions, -16 deletions)

View changed files

📝 docs/design.md (+1 -0)
➕ tests/semantic/test_bitcmp64_mixed_and_special.py (+262 -0)
📝 tools/rdna2spirv.py (+27 -16)

📄 Description

Item ID: SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS

Summary

Fixes Gen.bitcmp (s_bitcmp0/1_b32 and s_bitcmp0/1_b64) in tools/rdna2spirv.py for five broken lane-mask operand combinations (matching the per-dword word-materialization model used by s_cmp_eq/lg_u64):

  1. Mixed mask/data SGPR pairs in s_bitcmp0/1_b64: when one dword of s[r:r+1] holds a lane mask and the other holds plain scalar data, holds_lane_mask returned False, so the mask dword was loaded raw (0 / 0xFFFFFFFF per lane) instead of materializing the wave's 32-bit mask word.
  2. Wave32 (mask, -1) (EITHER) pairs in s_bitcmp0/1_b64: holds_lane_mask returned True and called wave_mask(s[r:r+1]), which returned (lo, 0) in wave32 and dropped the high -1 word to 0.
  3. Swapped or duplicated wave64 half-mask SGPR pairs in s_bitcmp0/1_b64 (e.g. s10 = vcc_hi, s11 = vcc_lo): holds_lane_mask returned True and wave_mask collapsed them to canonical (lo, hi). Now only canonical wave64 (MASK_LO, MASK_HI) keeps a single wave_mask; all other SGPR pairs materialize each dword independently (lane_mask_word when tracked as a mask, else load_reg).
  4. Wave32 FSPX s_bitcmp0/1_b64 vcc, bit: in wave32, vcc is {vcc_hi, vcc_lo} where vcc_lo can hold a lane mask while vcc_hi holds scalar data (or a separate mask). Previously wave_mask(vcc) zeroed bits 32..63; now vcc_lo and vcc_hi are materialized independently.
  5. Lane-mask bit-index operand a[1] on s_bitcmp0/1_b32 and s_bitcmp0/1_b64: previously self.src_u(a[1]) read per-lane 0 / 0xFFFFFFFF instead of self.lane_mask_word(a[1]).

Also simplifies _b32 to use self.lane_mask_word(src0) and replaces the non-mask 64-bit fallback self.mask_src(src0) with self.src_u(src0). Updates the contract table in docs/design.md and adds tests/semantic/test_bitcmp64_mixed_and_special.py.

Verification

  • AI-assisted: yes
  • Environment: Windows 11, Python 3.12.10 (CPU semantic interpreter spirv_mini_interp; no local GPU/Vulkan/spirv-val installed)
  • GREEN checks:
    • python -I tests/semantic/test_bitcmp64_mixed_and_special.py -v -> 6/6 OK (wave32, FSPX wave32, native wave64, --wave64-emulate)
    • python -I tests/semantic/test_scalar_bitcmp.py -> 23/23 OK
    • python -I tests/test_text_write_line_endings.py -> 3/3 OK
    • python -m compileall -q tools/rdna2spirv.py tests/semantic/test_bitcmp64_mixed_and_special.py -> exit 0
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_bitcmp64_mixed_and_special.py docs/design.md -> exit 0
    • git diff --check -> clean
  • RED control against origin/main (tools/ extracted from origin/main):
    • tests/semantic/test_bitcmp64_mixed_and_special.py fails 5 of 6 tests (6 failures across wave32, FSPX wave32, native wave64, and --wave64-emulate; test_wave64_bitcmp32_high_half_mask is a parity regression guard).

🔄 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/2360 **Author:** [@ShotTechOp](https://github.com/ShotTechOp) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/bitcmp64-mixed-and-special-srcs` --- ### 📝 Commits (1) - [`c26efd2`](https://github.com/ubiquitarianism/leonida/commit/c26efd297e76e2664d0d81de9b8df18b5fd7a9db) rdna2spirv: handle mixed mask pairs, wave32 VCC, and mask bit indices in s_bitcmp0/1_b32/b64 (SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS) ### 📊 Changes **3 files changed** (+290 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) ➕ `tests/semantic/test_bitcmp64_mixed_and_special.py` (+262 -0) 📝 `tools/rdna2spirv.py` (+27 -16) </details> ### 📄 Description Item ID: `SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS` ## Summary Fixes `Gen.bitcmp` (`s_bitcmp0/1_b32` and `s_bitcmp0/1_b64`) in `tools/rdna2spirv.py` for five broken lane-mask operand combinations (matching the per-dword word-materialization model used by `s_cmp_eq/lg_u64`): 1. **Mixed mask/data SGPR pairs in `s_bitcmp0/1_b64`**: when one dword of `s[r:r+1]` holds a lane mask and the other holds plain scalar data, `holds_lane_mask` returned `False`, so the mask dword was loaded raw (`0` / `0xFFFFFFFF` per lane) instead of materializing the wave's 32-bit mask word. 2. **Wave32 `(mask, -1)` (`EITHER`) pairs in `s_bitcmp0/1_b64`**: `holds_lane_mask` returned `True` and called `wave_mask(s[r:r+1])`, which returned `(lo, 0)` in wave32 and dropped the high `-1` word to `0`. 3. **Swapped or duplicated wave64 half-mask SGPR pairs in `s_bitcmp0/1_b64`** (e.g. `s10 = vcc_hi`, `s11 = vcc_lo`): `holds_lane_mask` returned `True` and `wave_mask` collapsed them to canonical `(lo, hi)`. Now only canonical wave64 `(MASK_LO, MASK_HI)` keeps a single `wave_mask`; all other SGPR pairs materialize each dword independently (`lane_mask_word` when tracked as a mask, else `load_reg`). 4. **Wave32 FSPX `s_bitcmp0/1_b64 vcc, bit`**: in wave32, `vcc` is `{vcc_hi, vcc_lo}` where `vcc_lo` can hold a lane mask while `vcc_hi` holds scalar data (or a separate mask). Previously `wave_mask(vcc)` zeroed bits 32..63; now `vcc_lo` and `vcc_hi` are materialized independently. 5. **Lane-mask bit-index operand `a[1]` on `s_bitcmp0/1_b32` and `s_bitcmp0/1_b64`**: previously `self.src_u(a[1])` read per-lane `0` / `0xFFFFFFFF` instead of `self.lane_mask_word(a[1])`. Also simplifies `_b32` to use `self.lane_mask_word(src0)` and replaces the non-mask 64-bit fallback `self.mask_src(src0)` with `self.src_u(src0)`. Updates the contract table in `docs/design.md` and adds `tests/semantic/test_bitcmp64_mixed_and_special.py`. ## Verification - **AI-assisted**: yes - **Environment**: Windows 11, Python 3.12.10 (CPU semantic interpreter `spirv_mini_interp`; no local GPU/Vulkan/`spirv-val` installed) - **GREEN checks**: - `python -I tests/semantic/test_bitcmp64_mixed_and_special.py -v` -> 6/6 OK (wave32, FSPX wave32, native wave64, `--wave64-emulate`) - `python -I tests/semantic/test_scalar_bitcmp.py` -> 23/23 OK - `python -I tests/test_text_write_line_endings.py` -> 3/3 OK - `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_bitcmp64_mixed_and_special.py` -> exit 0 - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_bitcmp64_mixed_and_special.py docs/design.md` -> exit 0 - `git diff --check` -> clean - **RED control against `origin/main` (`tools/` extracted from `origin/main`)**: - `tests/semantic/test_bitcmp64_mixed_and_special.py` fails 5 of 6 tests (6 failures across wave32, FSPX wave32, native wave64, and `--wave64-emulate`; `test_wave64_bitcmp32_high_half_mask` is a parity regression guard). --- <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#2362
No description provided.