[PR #1906] wave64_emulate_opt: model s_bitset0/1_b32/b64 as read-modify-write and SCC-less (SHADER-W64-EMU-BITSET-RMW) #1915

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

📋 Pull Request Information

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

Base: main ← Head: contrib/w64-emu-bitset-rmw


📝 Commits (1)

  • e11c001 wave64_emulate_opt: model s_bitset0/1_b32/b64 as read-modify-write and SCC-less (SHADER-W64-EMU-BITSET-RMW)

📊 Changes

3 files changed (+69 additions, -3 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_wave64_emulate_opt.py (+65 -0)
📝 tools/wave64_emulate_opt.py (+3 -2)

📄 Description

Claimed in the coordination issue as: SHADER-W64-EMU-BITSET-RMW

Depends on: none (note: open PR #1735 also edits tools/wave64_emulate_opt.py in separate hunks and docs/design.md; rebase if #1735 lands first)

What and why

tools/wave64_emulate_opt.py previously treated s_bitset0_b32, s_bitset1_b32, s_bitset0_b64, and s_bitset1_b64 as ordinary full-overwrite scalar ops that also clobber SCC. On RDNA2 (SOPK encoding), s_bitset* performs an in-place read-modify-write preserving all other bits of the target SGPR(s) and leaves SCC untouched:

  1. Added "s_bitset" to _SCALAR_NO_SCC_PREFIXES (tools/wave64_emulate_opt.py:153) so writes_scc() does not suppress live SCC across bitset instructions.
  2. Added s_bitset0_b32, s_bitset1_b32, s_bitset0_b64, and s_bitset1_b64 to the _RW_SOPK_RW branch of _get_op_meta() (tools/wave64_emulate_opt.py:252-254) so _scalar_rw() models both the read and may/must-write across the full 32-bit or 64-bit SGPR destination, keeping prior lane-local definitions live and preventing unsound s_cbranch_execz folding.
  3. Added LocalExecFoldTests.test_bitset_rmw_keeps_scalar_live_out_of_lane_local_execz_fold in tests/semantic/test_wave64_emulate_opt.py (covering _scalar_rw, writes_scc, SPIR-V binary assembly, and 64- and 128-thread emulated workgroup execution via spirv_mini_interp) and updated the Wave64 emulation (\--wave64-emulate`)contract row indocs/design.md`.

Tested

  • python -I scripts/check_no_game_data.py tools/wave64_emulate_opt.py tests/semantic/test_wave64_emulate_opt.py docs/design.md -> exit 0
  • python -I tests/semantic/test_wave64_emulate_opt.py -> Ran 34 tests in 8.295s OK
  • python -I tests/semantic/test_wave64_emulate_barriers.py -> Ran 13 tests in 1.430s OK
  • python -I tests/test_wave64_emulate_opt_cfg.py -> Ran 26 tests in 0.001s OK
  • python -I -m compileall -q make_game.py tools tests -> exit 0
  • python -I make_game.py --help -> exit 0
  • python -I tests/test_text_write_line_endings.py (3 OK), tests/test_report_paths.py (22 tests, 1 skipped, OK), tests/test_docs_design_rows.py (5 OK), tests/test_docs_repo_paths.py (3 OK), tests/test_docs_repeated_lines.py (2 OK), tests/test_ci_registration.py (16 OK)
  • Pre-rebase (3f81d46ac): python -I scripts/run_semantic_tests.py tests/semantic -> 487 files, 6280 tests, 0 files failed in 207 s
  • No local GPU hardware run (llvm-mc with AMDGPU target and VULKAN_SDK not installed locally); spirv_asm.assemble(..., target_env="vulkan1.2") verified valid SPIR-V binaries for all generated modules.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🔄 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/1906 **Author:** [@JordanWebDev](https://github.com/JordanWebDev) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `contrib/w64-emu-bitset-rmw` --- ### 📝 Commits (1) - [`e11c001`](https://github.com/ubiquitarianism/leonida/commit/e11c0017cae0d1938e4710e34b9666e603308657) wave64_emulate_opt: model s_bitset0/1_b32/b64 as read-modify-write and SCC-less (SHADER-W64-EMU-BITSET-RMW) ### 📊 Changes **3 files changed** (+69 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_wave64_emulate_opt.py` (+65 -0) 📝 `tools/wave64_emulate_opt.py` (+3 -2) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-W64-EMU-BITSET-RMW Depends on: none (note: open PR #1735 also edits tools/wave64_emulate_opt.py in separate hunks and docs/design.md; rebase if #1735 lands first) ### What and why `tools/wave64_emulate_opt.py` previously treated `s_bitset0_b32`, `s_bitset1_b32`, `s_bitset0_b64`, and `s_bitset1_b64` as ordinary full-overwrite scalar ops that also clobber `SCC`. On RDNA2 (SOPK encoding), `s_bitset*` performs an in-place read-modify-write preserving all other bits of the target SGPR(s) and leaves `SCC` untouched: 1. Added `"s_bitset"` to `_SCALAR_NO_SCC_PREFIXES` (`tools/wave64_emulate_opt.py:153`) so `writes_scc()` does not suppress live `SCC` across bitset instructions. 2. Added `s_bitset0_b32`, `s_bitset1_b32`, `s_bitset0_b64`, and `s_bitset1_b64` to the `_RW_SOPK_RW` branch of `_get_op_meta()` (`tools/wave64_emulate_opt.py:252-254`) so `_scalar_rw()` models both the read and may/must-write across the full 32-bit or 64-bit SGPR destination, keeping prior lane-local definitions live and preventing unsound `s_cbranch_execz` folding. 3. Added `LocalExecFoldTests.test_bitset_rmw_keeps_scalar_live_out_of_lane_local_execz_fold` in `tests/semantic/test_wave64_emulate_opt.py` (covering `_scalar_rw`, `writes_scc`, SPIR-V binary assembly, and 64- and 128-thread emulated workgroup execution via `spirv_mini_interp`) and updated the `Wave64 emulation (\`--wave64-emulate\`)` contract row in `docs/design.md`. ### Tested - `python -I scripts/check_no_game_data.py tools/wave64_emulate_opt.py tests/semantic/test_wave64_emulate_opt.py docs/design.md` -> exit 0 - `python -I tests/semantic/test_wave64_emulate_opt.py` -> Ran 34 tests in 8.295s OK - `python -I tests/semantic/test_wave64_emulate_barriers.py` -> Ran 13 tests in 1.430s OK - `python -I tests/test_wave64_emulate_opt_cfg.py` -> Ran 26 tests in 0.001s OK - `python -I -m compileall -q make_game.py tools tests` -> exit 0 - `python -I make_game.py --help` -> exit 0 - `python -I tests/test_text_write_line_endings.py` (3 OK), `tests/test_report_paths.py` (22 tests, 1 skipped, OK), `tests/test_docs_design_rows.py` (5 OK), `tests/test_docs_repo_paths.py` (3 OK), `tests/test_docs_repeated_lines.py` (2 OK), `tests/test_ci_registration.py` (16 OK) - Pre-rebase (`3f81d46ac`): `python -I scripts/run_semantic_tests.py tests/semantic` -> 487 files, 6280 tests, 0 files failed in 207 s - No local GPU hardware run (`llvm-mc` with AMDGPU target and `VULKAN_SDK` not installed locally); `spirv_asm.assemble(..., target_env="vulkan1.2")` verified valid SPIR-V binaries for all generated modules. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. --- <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#1915
No description provided.