[PR #212] rdna2spirv: s_bfe_u64 / s_bfe_i64 on the dword pair, with no Int64 (SHADER-930) #264

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/212
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9947


📝 Commits (1)

  • eb9199f rdna2spirv: s_bfe_u64 / s_bfe_i64 on the dword pair, with no Int64 (SHADER-930)

📊 Changes

3 files changed (+53 additions, -37 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_salu_bfe_64.py (+20 -5)
📝 tools/rdna2spirv.py (+32 -31)

📄 Description

Carried over from old PR 9947 by fromthemoonx in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9947, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
fromthemoonx: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Item: SHADER-930 (translator part; claimed in #9677). The gfx1036 hardware measurement in the row stays up for grabs.
Depends on: nothing

What. s_bfe_u64 / s_bfe_i64 were the last 64-bit scalar data ops that built a %ulong and set uses_psb (Int64). The others in the row (s_brev_b64, s_bitset*_b64, s_flbit_i32_*64) already use 32-bit ops only. The extract is now lowered on the (lo, hi) dword pair:

  • Shift the pair right by the offset with 32-bit shifts only. The bits coming down from the high dword are written (b << 1) << (31 - s), so no shift amount reaches 32 and s = 0 needs no select.
  • Extract min(w, 32) bits of the low dword and w - 32 of the high one with OpBitField[U|S]Extract. A count of 0 extracts 0, so width 0 still gives D = 0 and SCC = 0.
  • s_bfe_i64 with w ≤ 32 sign-fills the high dword from the low field's top bit.
  • The semantics are unchanged: offset = S1[5:0], width = S1[22:16], cut at bit 63 (LLVM constantFoldBFE), SCC = D ≠ 0.

Tests (Linux, CPU).

  • test_salu_bfe_64.py: the two emission tests no longer pin %ulong / %long; they assert no 64-bit type and uses_psb False (both fail on main, as intended). A new test checks every offset 0-63 × widths 0, 1, 2, 15, 16, 31-34, 47, 62-65, 127 × both ops × a value with the top bit set and one with it clear, against the file's reference model: 3,840 cases, all pass.
  • All 17 test_salu*64* files pass, including test_salu64_fixture.py. The translated cs_w32_salu64 passes spirv-val --target-env vulkan1.2. That module still declares Int64 for its buffer addressing, not for s_bfe.
  • Full semantic suite: 6,047 tests. 3 files fail on main as well, unchanged by this PR: test_exec_computed (SHADER-1264), test_image_atomics_guard and test_int32_to_f64.
  • docs/design.md: the 64-bit scalar data ops row says how they are lowered and how that was checked.

GPU. cs_w32_salu64 (it runs s_bfe_u64 and s_bfe_i64 against the hardware-verified words in the row) on an NVIDIA RTX 3060 / Windows 11: result to follow in a comment.

AI-assisted (Claude).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FXR27ZYP9qtZtN8SG7QPWW


🔄 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/212 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9947` --- ### 📝 Commits (1) - [`eb9199f`](https://github.com/ubiquitarianism/leonida/commit/eb9199fdb65a4ee06d10a63e3f22c0551d8ff413) rdna2spirv: s_bfe_u64 / s_bfe_i64 on the dword pair, with no Int64 (SHADER-930) ### 📊 Changes **3 files changed** (+53 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_salu_bfe_64.py` (+20 -5) 📝 `tools/rdna2spirv.py` (+32 -31) </details> ### 📄 Description > Carried over from **old PR 9947** by `fromthemoonx` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9947`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `fromthemoonx`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Item: SHADER-930 (translator part; claimed in `#9677`). The gfx1036 hardware measurement in the row stays up for grabs. Depends on: nothing **What.** `s_bfe_u64` / `s_bfe_i64` were the last 64-bit scalar data ops that built a `%ulong` and set `uses_psb` (Int64). The others in the row (`s_brev_b64`, `s_bitset*_b64`, `s_flbit_i32_*64`) already use 32-bit ops only. The extract is now lowered on the (lo, hi) dword pair: - Shift the pair right by the offset with 32-bit shifts only. The bits coming down from the high dword are written `(b << 1) << (31 - s)`, so no shift amount reaches 32 and s = 0 needs no select. - Extract `min(w, 32)` bits of the low dword and `w - 32` of the high one with `OpBitField[U|S]Extract`. A count of 0 extracts 0, so width 0 still gives D = 0 and SCC = 0. - `s_bfe_i64` with w ≤ 32 sign-fills the high dword from the low field's top bit. - The semantics are unchanged: offset = S1[5:0], width = S1[22:16], cut at bit 63 (LLVM `constantFoldBFE`), SCC = D ≠ 0. **Tests (Linux, CPU).** - `test_salu_bfe_64.py`: the two emission tests no longer pin `%ulong` / `%long`; they assert no 64-bit type and `uses_psb` False (both fail on main, as intended). A new test checks **every offset 0-63** × widths 0, 1, 2, 15, 16, 31-34, 47, 62-65, 127 × both ops × a value with the top bit set and one with it clear, against the file's reference model: 3,840 cases, all pass. - All 17 `test_salu*64*` files pass, including `test_salu64_fixture.py`. The translated `cs_w32_salu64` passes `spirv-val --target-env vulkan1.2`. That module still declares Int64 for its buffer addressing, not for `s_bfe`. - Full semantic suite: 6,047 tests. 3 files fail on main as well, unchanged by this PR: `test_exec_computed` (SHADER-1264), `test_image_atomics_guard` and `test_int32_to_f64`. - `docs/design.md`: the 64-bit scalar data ops row says how they are lowered and how that was checked. **GPU.** `cs_w32_salu64` (it runs `s_bfe_u64` and `s_bfe_i64` against the hardware-verified words in the row) on an NVIDIA RTX 3060 / Windows 11: result to follow in a comment. AI-assisted (Claude). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FXR27ZYP9qtZtN8SG7QPWW --- <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#264
No description provided.