docs: close the s_bfe width blocker from the ISA pseudocode and LLVM folding #178

Closed
github-bot wants to merge 1 commit from gh-pr/178/head into gh-pr/178/base
Owner

@⁠iseaprojects on GitHub · 2026-11-22 18:24 UTC · original
iseaprojects:docs/s-bfe-width → main · +1 −1 · 1 files · 1 commits · closed without merging

Library / area: docs/BLOCKERS.md (RDNA2 instructions held at yellow). No code change.

Exports changed (exports.txt rows): none

Source of the behaviour: the blocker asked for one of two external references; both agree with the translator as it stands:

  • AMD RDNA ISA, 25 September 2020, 12.1 SOP2, p. 110: D.u = (S0.u >> S1.u[4:0]) & ((1 << S1.u[22:16]) - 1). The width field is 7 bits, so width 0 clears the result and width 32 masks all 32 bits, leaving the shift alone.
  • LLVM AMDGPUISelLowering.cpp, constantFoldBFE: when Width + Offset >= 32 it returns Src0 >> Offset with no mask, and only masks the narrower field. SIISelLowering.cpp, knownBitsForSBFE, treats a width of 32 or more as ill-formed.

hlsl.rs already lowers that rule: s_bfe_u32 shifts when width >= 32, tb_bfe_i32 shifts when width + offset >= 32, and s_bfe_*64 clamp the width to 64. tests/isa_sweep/ops_s.rs covers widths 0, 1, 31, 32, 33, 63, 64, 65 and 127 with lane offsets, plus 0xffffffff (offset 31, width 127).

This entry is the only change: the note is replaced with the closure and its evidence. Nothing else in the section is touched; v_cvt_norm stays open because the ISA says only "supports rounding" for the (snorm)/(unorm) casts and does not settle .5 ties.

Tests (Windows 11, GTX 1650, debug):

  • TOMBOX_SWEEP_FILTER=s_bfe cargo test -p tombox-xshader --test isa_sweep isa_sweep (WARP): s_bfe_u32, s_bfe_i32, s_bfe_u64, s_bfe_i64 PASS, 11 cases and 11264 lanes each.

  • TOMBOX_EXEC_HW=1 cargo test -p tombox-xshader --test isa_sweep isa_sweep (GTX 1650): 541 mnemonics, 541 pass, 0 fail, 0 known WARP deviations, 94 compiles, 15.1 s.

  • No game or console files and no binaries included

  • No fake success; the two still-unconfirmed items in that section keep their notes

**@⁠iseaprojects** on GitHub · 2026-11-22 18:24 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/178) `iseaprojects:docs/s-bfe-width` → `main` · +1 −1 · 1 files · 1 commits · closed without merging **Library / area:** `docs/BLOCKERS.md` (RDNA2 instructions held at yellow). No code change. **Exports changed (exports.txt rows):** none **Source of the behaviour:** the blocker asked for one of two external references; both agree with the translator as it stands: - AMD RDNA ISA, 25 September 2020, 12.1 SOP2, p. 110: `D.u = (S0.u >> S1.u[4:0]) & ((1 << S1.u[22:16]) - 1)`. The width field is 7 bits, so width 0 clears the result and width 32 masks all 32 bits, leaving the shift alone. - LLVM `AMDGPUISelLowering.cpp`, `constantFoldBFE`: when `Width + Offset >= 32` it returns `Src0 >> Offset` with no mask, and only masks the narrower field. `SIISelLowering.cpp`, `knownBitsForSBFE`, treats a width of 32 or more as ill-formed. `hlsl.rs` already lowers that rule: `s_bfe_u32` shifts when `width >= 32`, `tb_bfe_i32` shifts when `width + offset >= 32`, and `s_bfe_*64` clamp the width to 64. `tests/isa_sweep/ops_s.rs` covers widths 0, 1, 31, 32, 33, 63, 64, 65 and 127 with lane offsets, plus `0xffffffff` (offset 31, width 127). This entry is the only change: the note is replaced with the closure and its evidence. Nothing else in the section is touched; `v_cvt_norm` stays open because the ISA says only "supports rounding" for the `(snorm)`/`(unorm)` casts and does not settle .5 ties. Tests (Windows 11, GTX 1650, debug): - `TOMBOX_SWEEP_FILTER=s_bfe cargo test -p tombox-xshader --test isa_sweep isa_sweep` (WARP): `s_bfe_u32`, `s_bfe_i32`, `s_bfe_u64`, `s_bfe_i64` PASS, 11 cases and 11264 lanes each. - `TOMBOX_EXEC_HW=1 cargo test -p tombox-xshader --test isa_sweep isa_sweep` (GTX 1650): 541 mnemonics, 541 pass, 0 fail, 0 known WARP deviations, 94 compiles, 15.1 s. - [x] No game or console files and no binaries included - [x] No fake success; the two still-unconfirmed items in that section keep their notes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:12:56 +00:00
github-bot closed this pull request 2026-11-26 06:12:56 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 18:28 UTC · original

Applied in 01a7018 (merged in 6ef1fea) with your authorship kept, thanks. I checked it against hlsl.rs on main: s_bfe_u32 shifts without masking when the width is 32 or more, tb_bfe_i32 shifts when width + offset is 32 or more, and width 0 gives 0. So the entry now matches the code.

**@⁠omonkeyz** on GitHub · 2026-11-22 18:28 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/178#issuecomment-7083626398) Applied in 01a7018 (merged in 6ef1fea) with your authorship kept, thanks. I checked it against hlsl.rs on main: `s_bfe_u32` shifts without masking when the width is 32 or more, `tb_bfe_i32` shifts when width + offset is 32 or more, and width 0 gives 0. So the entry now matches the code.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.