rdna2spirv: s_bitreplicate_b64_b32 into VCC, s_flbit_i32_b64 of a lane mask (SHADER-LANEMASK-BITREP-FLBIT) #593

Merged
Tyrannys merged 1 commit from upstream-pr/593 into main 2026-11-25 02:33:48 +00:00
Tyrannys commented 2026-11-24 09:25:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-24T09:25:34Z.


Item: SHADER-LANEMASK-BITREP-FLBIT (claimed in #14).

Two lane-mask forms the translator refused, both in pipeline-library compute programs that the retail boot creates through slot 67:

  • s_bitreplicate_b64_b32 with a VCC destination. RDNA2 ISA SOP1: D[2i+1] = D[2i] = S0[i], so lane L's bit is S0 bit L // 2. EXEC already took this path (6ecd922d9); VCC now does the same and stores the lane's bit the way mov64 stores a mask into VCC (0xFFFFFFFF / 0). Other lane-mask sources and destinations stay Unsupported.
  • s_flbit_i32_b64 of a lane mask (EXEC, VCC, a mask pair). It now reads the wave's whole mask as real bits through wave_mask, as s_ff1_i32_b64 already does: 63 minus the last active lane, -1 when none. s_flbit_i32_i64 of a mask stays Unsupported.

Tests (synthetic programs only):

  • new tests/semantic/test_lane_mask_bitreplicate_flbit.py: both ops on every lane of a wave64 in spirv_mini_interp.run_workgroup; bitreplicate into VCC for 6 constants, flbit of EXEC for 6 masks and of a compare VCC for 5 lane counts.
  • tests/semantic/test_salu_flbit_64.py: the old "lane mask is rejected" case now checks s_flbit_i32_i64, which stays rejected.
  • docs/design.md: both contract rows updated, with how they are confirmed.

Full suite: python -I scripts/run_semantic_tests.py tests/semantic on this branch: 466 files, 6,111 tests, 1 file fails, test_image_cube_store_glc, which fails the same on main (7430f59b2) without this change.

Effect on the 1.0.2.1 boot (local work folder, RTX 4070 SUPER, Windows 11): 2 of the compute programs the title asked for and lacked (one per form) now translate and pass spirv-val.

AI-assisted (Claude Code). CPU-only checks; no GPU test run for this change.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5469484665 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/593). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-24T09:25:34Z. --- Item: SHADER-LANEMASK-BITREP-FLBIT (claimed in #14). Two lane-mask forms the translator refused, both in pipeline-library compute programs that the retail boot creates through slot 67: - `s_bitreplicate_b64_b32` with a **VCC** destination. RDNA2 ISA SOP1: D[2i+1] = D[2i] = S0[i], so lane L's bit is S0 bit L // 2. EXEC already took this path (6ecd922d9); VCC now does the same and stores the lane's bit the way `mov64` stores a mask into VCC (0xFFFFFFFF / 0). Other lane-mask sources and destinations stay `Unsupported`. - `s_flbit_i32_b64` of a **lane mask** (EXEC, VCC, a mask pair). It now reads the wave's whole mask as real bits through `wave_mask`, as `s_ff1_i32_b64` already does: 63 minus the last active lane, -1 when none. `s_flbit_i32_i64` of a mask stays `Unsupported`. Tests (synthetic programs only): - new `tests/semantic/test_lane_mask_bitreplicate_flbit.py`: both ops on every lane of a wave64 in `spirv_mini_interp.run_workgroup`; bitreplicate into VCC for 6 constants, flbit of EXEC for 6 masks and of a compare VCC for 5 lane counts. - `tests/semantic/test_salu_flbit_64.py`: the old "lane mask is rejected" case now checks `s_flbit_i32_i64`, which stays rejected. - `docs/design.md`: both contract rows updated, with how they are confirmed. Full suite: `python -I scripts/run_semantic_tests.py tests/semantic` on this branch: 466 files, 6,111 tests, 1 file fails, `test_image_cube_store_glc`, which fails the same on `main` (7430f59b2) without this change. Effect on the 1.0.2.1 boot (local work folder, RTX 4070 SUPER, Windows 11): 2 of the compute programs the title asked for and lacked (one per form) now translate and pass `spirv-val`. AI-assisted (Claude Code). CPU-only checks; no GPU test run for this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
qhukz13 commented 2026-11-24 11:46:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-24T11:46:50Z.

Review: COMMENTED


Reviewed on head 1ea2ffbca (Linux, no GPU: CPU interpreter only). It is based on 7430f59b2 and merges cleanly with current main (21625bca8).

Checked:

  • bitreplicate into VCC: lane L's bit index L >> 1 is 0..31, which _scalar_word_lane_bit's & 31 keeps, and the 0xFFFFFFFF / 0 store matches how a mask is stored into VCC. flbit of a b64 lane mask goes through wave_mask, as s_ff1_i32_b64 does; _i64 still refuses.
  • Pass: test_lane_mask_bitreplicate_flbit.py, test_salu_flbit_64.py, test_salu_flbit_lane_mask.py, test_salu_quadmask_bitreplicate.py.
  • Three hand-written logic mutations against the new file, all caught: no >> 1 in the bitreplicate lane index (4 failures), the wave_mask halves swapped (8), and this lane's mask_src bit in place of the wave's mask (8).

Two cases the description covers but the test does not, both correct on this head in the same run_workgroup harness:

  • s_flbit_i32_b64 of an EXEC of 0 gives 0xffffffff (-1);
  • of a mask held in an SGPR pair (v_cmp_gt_u32_e32 vcc, 5, v1, s_mov_b64 s[8:9], vcc, s_flbit_i32_b64 s10, s[8:9]) gives 0x3b, the model's value.

Adding them would pin the "-1 when none" path and the "mask pair" form named in the description.

Looks good to me.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6038619273 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/593#pullrequestreview-6038619273). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-24T11:46:50Z. **Review:** COMMENTED --- Reviewed on head 1ea2ffbca (Linux, no GPU: CPU interpreter only). It is based on 7430f59b2 and merges cleanly with current `main` (21625bca8). Checked: - bitreplicate into VCC: lane L's bit index `L >> 1` is 0..31, which `_scalar_word_lane_bit`'s `& 31` keeps, and the 0xFFFFFFFF / 0 store matches how a mask is stored into VCC. flbit of a b64 lane mask goes through `wave_mask`, as `s_ff1_i32_b64` does; `_i64` still refuses. - Pass: `test_lane_mask_bitreplicate_flbit.py`, `test_salu_flbit_64.py`, `test_salu_flbit_lane_mask.py`, `test_salu_quadmask_bitreplicate.py`. - Three hand-written logic mutations against the new file, all caught: no `>> 1` in the bitreplicate lane index (4 failures), the `wave_mask` halves swapped (8), and this lane's `mask_src` bit in place of the wave's mask (8). Two cases the description covers but the test does not, both correct on this head in the same `run_workgroup` harness: - `s_flbit_i32_b64` of an EXEC of 0 gives 0xffffffff (-1); - of a mask held in an SGPR pair (`v_cmp_gt_u32_e32 vcc, 5, v1`, `s_mov_b64 s[8:9], vcc`, `s_flbit_i32_b64 s10, s[8:9]`) gives 0x3b, the model's value. Adding them would pin the "-1 when none" path and the "mask pair" form named in the description. Looks good to me.
SweatierKey commented 2026-11-24 15:58:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by SweatierKey on 2026-11-24T15:58:02Z.

Review: APPROVED


Independent verification on origin/main@1504c1af6 (LEONIDA_REQUIRE_SPIRV_TOOLS=1):

  • tests/semantic/test_lane_mask_bitreplicate_flbit.py: 3/3 PASS (test_bitreplicate_into_vcc, test_flbit_of_exec, test_flbit_of_vcc).
  • tests/semantic/test_salu_flbit_64.py: 5/5 PASS (confirms s_flbit_i32_i64 on lane mask remains rejected while b64 reads the wave mask).
  • scripts/check_no_game_data.py: clean.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6042757440 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/593#pullrequestreview-6042757440). Originally posted by [SweatierKey](https://github.com/SweatierKey) on 2026-11-24T15:58:02Z. **Review:** APPROVED --- Independent verification on `origin/main@1504c1af6` (`LEONIDA_REQUIRE_SPIRV_TOOLS=1`): - `tests/semantic/test_lane_mask_bitreplicate_flbit.py`: `3/3` PASS (`test_bitreplicate_into_vcc`, `test_flbit_of_exec`, `test_flbit_of_vcc`). - `tests/semantic/test_salu_flbit_64.py`: `5/5` PASS (confirms `s_flbit_i32_i64` on lane mask remains rejected while `b64` reads the wave mask). - `scripts/check_no_game_data.py`: clean. AI-assisted: yes
Snooozs commented 2026-11-24 16:54:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-24T16:54:48Z.


Independent check (Windows 10 19045, CPython 3.12.10, CPU only, no game files): merged cleanly onto main 82a2aabcc, test_lane_mask_bitreplicate_flbit.py 3 OK and test_salu_flbit_64.py 5 OK; with main's tools the new file has 17 errors. Both result models in the test match the ISA text in its header as I read it. Semantic interpreter only, no GPU run. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7138399786 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/593#issuecomment-7138399786). Originally posted by [Snooozs](https://github.com/Snooozs) on 2026-11-24T16:54:48Z. --- Independent check (Windows 10 19045, CPython 3.12.10, CPU only, no game files): merged cleanly onto `main` 82a2aabcc, `test_lane_mask_bitreplicate_flbit.py` 3 OK and `test_salu_flbit_64.py` 5 OK; with `main`'s tools the new file has 17 errors. Both result models in the test match the ISA text in its header as I read it. Semantic interpreter only, no GPU run. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!593
No description provided.