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

Closed
Andretuta wants to merge 1 commit from upstream-pr/212 into main
Andretuta commented 2026-11-24 02:45:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:45:20Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465107004 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/212). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:45:20Z. --- > 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
MoonEyes commented 2026-11-27 23:36:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T23:36:25Z.


Thanks a lot for carrying this over, @Andretuta. #224, also carried over for SHADER-930, lowers the same two operations (s_bfe_u64, s_bfe_i64) on the dword pair without Int64 and also brings GPU fixtures, an int_hw_probe change and test_salu64_2x32.py. Only one of the two lowerings can land. This draft has one thing #224 lacks: test_every_offset_dword_pair, which checks every offset 0-63 and passes on #224's code. Whoever takes #224 over, please bring that test along (both drafts conflict with main); this draft can be closed then. cc @fromthemoonx (original author).

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230269597 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/212#issuecomment-7230269597). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T23:36:25Z. --- Thanks a lot for carrying this over, @Andretuta. #224, also carried over for SHADER-930, lowers the same two operations (`s_bfe_u64`, `s_bfe_i64`) on the dword pair without Int64 and also brings GPU fixtures, an `int_hw_probe` change and `test_salu64_2x32.py`. Only one of the two lowerings can land. This draft has one thing #224 lacks: `test_every_offset_dword_pair`, which checks every offset 0-63 and passes on #224's code. Whoever takes #224 over, please bring that test along (both drafts conflict with `main`); this draft can be closed then. cc @fromthemoonx (original author). AI-assisted (Claude Code, Claude Opus 5.5)
aslan2142 commented 2026-12-01 11:48:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:48:39Z.


Closing this carried-over draft in favor of #224 for SHADER-930 (s_bfe_u64 / s_bfe_i64 lowered to 2x32-bit without Int64).

Side-by-side comparison:

  • #212 (draft, conflicting, cancelled CI): lowers only s_bfe_u64 / s_bfe_i64 across 3 files (+53/-37) with semantic tests (test_salu_bfe_64.py), and includes no GPU fixtures or hardware-probe coverage.
  • #224 (draft, conflicting, cancelled CI): lowers the same s_bfe_u64 / s_bfe_i64 ops to 2x32-bit without Int64 (using explicit %int signed types for OpBitFieldSExtract / OpShiftRightArithmetic) and additionally brings two GPU shader fixtures (cs_w32_salu64_bfe.asm, cs_w32_salu64_bits.asm), semantic disasm fixtures, tests/semantic/test_salu64_2x32.py (+227 lines), tools/int_hw_probe.py support, and run_gpu_tests.py / check.py wiring (11 files, +566/-39).

We have noted on #224 to bring over this draft's test_every_offset_dword_pair check when #224 is rebased onto main. Thanks to @fromthemoonx and @Andretuta for the work.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310175946 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/212#issuecomment-7310175946). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:48:39Z. --- Closing this carried-over draft in favor of **#224** for `SHADER-930` (`s_bfe_u64` / `s_bfe_i64` lowered to 2x32-bit without `Int64`). **Side-by-side comparison:** - **#212** (draft, conflicting, cancelled CI): lowers only `s_bfe_u64` / `s_bfe_i64` across 3 files (`+53/-37`) with semantic tests (`test_salu_bfe_64.py`), and includes no GPU fixtures or hardware-probe coverage. - **#224** (draft, conflicting, cancelled CI): lowers the same `s_bfe_u64` / `s_bfe_i64` ops to 2x32-bit without `Int64` (using explicit `%int` signed types for `OpBitFieldSExtract` / `OpShiftRightArithmetic`) and additionally brings two GPU shader fixtures (`cs_w32_salu64_bfe.asm`, `cs_w32_salu64_bits.asm`), semantic disasm fixtures, `tests/semantic/test_salu64_2x32.py` (`+227` lines), `tools/int_hw_probe.py` support, and `run_gpu_tests.py` / `check.py` wiring (`11` files, `+566/-39`). We have noted on **#224** to bring over this draft's `test_every_offset_dword_pair` check when #224 is rebased onto `main`. Thanks to `@fromthemoonx` and `@Andretuta` for the work. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 11:49:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:49:59Z.

Review: COMMENTED


Draft review note: carried over from old PR 9947 for SHADER-930 (s_bfe_u64/s_bfe_i64 2x32 lowering). Currently conflicts with main, CI was cancelled, and overlaps #224 (which also targets SHADER-930 with broader 64-bit scalar lowering). Only one SHADER-930 implementation can land; if continuing with this one, please rebase onto main, run CI to green, and mark ready for review.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130658536 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/212#pullrequestreview-6130658536). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:49:59Z. **Review:** COMMENTED --- Draft review note: carried over from old PR 9947 for `SHADER-930` (`s_bfe_u64`/`s_bfe_i64` 2x32 lowering). Currently conflicts with `main`, CI was cancelled, and overlaps `#224` (which also targets `SHADER-930` with broader 64-bit scalar lowering). Only one `SHADER-930` implementation can land; if continuing with this one, please rebase onto `main`, run CI to green, and mark ready for review. *(AI-assisted review.)*

Pull request closed

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!212
No description provided.