pixel_aot: lower s_bfm_b32 #590

Closed
opened 2026-11-22 14:51:50 +00:00 by JB2WIN · 1 comment
JB2WIN commented 2026-11-22 14:51:50 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T14:51:50Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543803477 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/596). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T14:51:50Z. --- `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 commented 2026-11-24 06:48:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T15:02:25Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7080995319 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/596#issuecomment-7080995319). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T15:02:25Z. --- 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.
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#590
No description provided.