pixel_aot: lower s_bfm_b32 #596

Closed
opened 2026-11-26 22:04:31 +00:00 by github-bot · 1 comment
Owner

@⁠JB2WIN on GitHub · 2026-11-22 14:51 UTC · original

tools/pixel_aot.py does not yet lower the scalar bitfield-mask instructions s_bfm_b32 and s_bfm_b64 (SOP2, both in docs/coverage/gfx1013.tsv). #436 covers the vector v_bfm_b32, not these.

I'm taking this, unless someone has it in progress. Plan:

  • Lower s_bfm_b32 as ((1u << (S0 & 31)) - 1u) << (S1 & 31), and s_bfm_b64 likewise on 64 bits with 6-bit counts, written into an SGPR pair. Both go through the existing SALU table and helpers, next to the other SOP2 bit operations. They don't write SCC.
  • Source: LLVM selects S_BFM_B32 for (shl (add (shl 1, a), -1), b) (SIInstructions.td, BFMPatterns). The 5-/6-bit count masking follows the usual SOP2 convention. I can't check it against the ISA PDF, so the tests and docs record it as an assumption.
  • Tests: static lowering checks, integer-export draws, rejections and an LLVM 15 round-trip fixture. The draws cover counts 0, 1, 31 and 32, plus a negative control that drops the count mask. Also scanner support and docs.

AI-assisted.

**@⁠JB2WIN** on GitHub · 2026-11-22 14:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/596) `tools/pixel_aot.py` does not yet lower the scalar bitfield-mask instructions `s_bfm_b32` and `s_bfm_b64` (SOP2, both in `docs/coverage/gfx1013.tsv`). #436 covers the vector `v_bfm_b32`, not these. I'm taking this, unless someone has it in progress. Plan: - Lower `s_bfm_b32` as `((1u << (S0 & 31)) - 1u) << (S1 & 31)`, and `s_bfm_b64` likewise on 64 bits with 6-bit counts, written into an SGPR pair. Both go through the existing SALU table and helpers, next to the other SOP2 bit operations. They don't write SCC. - Source: LLVM selects `S_BFM_B32` for `(shl (add (shl 1, a), -1), b)` (`SIInstructions.td`, `BFMPatterns`). The 5-/6-bit count masking follows the usual SOP2 convention. I can't check it against the ISA PDF, so the tests and docs record it as an assumption. - Tests: static lowering checks, integer-export draws, rejections and an LLVM 15 round-trip fixture. The draws cover counts 0, 1, 31 and 32, plus a negative control that drops the count mask. Also scanner support and docs. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:04:31 +00:00
Author
Owner

@⁠JB2WIN on GitHub · 2026-11-22 15:02 UTC · original

Correction to the issue text: s_bfm_b64 is already lowered on main (SALU_HELPERS["s_bfm_b64"], since d8bf0c0). I missed it because my search only matched the b32 spelling. Only s_bfm_b32 is missing. The PR will cover just that and add a draw that checks it alongside the existing b64 lowering.

This comment is AI-assisted.

**@⁠JB2WIN** on GitHub · 2026-11-22 15:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/596#issuecomment-7080995319) Correction to the issue text: `s_bfm_b64` is already lowered on `main` (`SALU_HELPERS["s_bfm_b64"]`, since `d8bf0c0`). I missed it because my search only matched the b32 spelling. Only `s_bfm_b32` is missing. The PR will cover just that and add a draw that checks it alongside the existing b64 lowering. This comment is AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#596
No description provided.