compute: lower s_bcnt1_i32_b64 on a known or runtime SGPR pair #2109

Manually merged
github merged 2 commits from gh-pr/2109/head into gh-pr/2109/base 2026-11-26 23:57:16 +00:00
Owner

@⁠Leyukaka on GitHub · 2026-11-25 00:34 UTC · original
Leyukaka:compute/s-bcnt1-i32-b64 → main · +89 −0 · 6 files · 2 commits · merged 2026-11-25 00:45 UTC

Part of #2022 (item G, s_bcnt1).

tools/compute_store_aot.py lowered only s_bcnt1_i32_b32 sD, exec_lo. s_bcnt1_i32_b64 reached the unsupported-instruction diagnostic. This adds the SGPR-pair form.

  • s_bcnt1_i32_b64 sD, s[lo:hi] writes the number of set bits in both words to sD. The pair must be even-aligned and consecutive, within s0..s105.
  • With two known words, the count is folded to a constant. With runtime words, the translator emits (countbits(lo) + countbits(hi)) and keeps the existing ALU expression size limit.
  • Both words are read before sD is written, so sD may alias either half of the pair.
  • SOP1 sets SCC to sD != 0 (AMD RDNA 2 ISA, SOP1). This compute profile has no SCC reader, and a following s_cbranch_scc1 stays refused. The test asserts that.
  • Refused: unaligned or out-of-range pairs, sD beyond s105 or pending, and source words that are not verified. exec, vcc and immediate 64-bit sources stay unsupported.

Tests

python -B tests/compute_alu_bcnt64_check.py   # passes

The check covers:

  • the folded count with sD aliasing the low word;
  • zero and 64 set bits;
  • a runtime word from the guard fixture's constant buffer;
  • each refusal, including exec, vcc and an immediate source;
  • a mutation that drops the high word, which must change the emitted count.

Registered as compute_alu_bcnt64_controls and added to the pure-Python lists in AGENTS.md and windows.yml. The existing controls in compute_store_check.py and compute_lane_mask_check.py still pass.

Negative control: against the previous tools/compute_store_aot.py, the check fails with Unsupported compute instruction: s_bcnt1_i32_b64 s4, s[4:5].

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-25 00:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2109) `Leyukaka:compute/s-bcnt1-i32-b64` → `main` · +89 −0 · 6 files · 2 commits · merged 2026-11-25 00:45 UTC Part of #2022 (item G, `s_bcnt1`). `tools/compute_store_aot.py` lowered only `s_bcnt1_i32_b32 sD, exec_lo`. `s_bcnt1_i32_b64` reached the unsupported-instruction diagnostic. This adds the SGPR-pair form. - `s_bcnt1_i32_b64 sD, s[lo:hi]` writes the number of set bits in both words to `sD`. The pair must be even-aligned and consecutive, within `s0`..`s105`. - With two known words, the count is folded to a constant. With runtime words, the translator emits `(countbits(lo) + countbits(hi))` and keeps the existing ALU expression size limit. - Both words are read before `sD` is written, so `sD` may alias either half of the pair. - SOP1 sets `SCC` to `sD != 0` (AMD RDNA 2 ISA, SOP1). This compute profile has no `SCC` reader, and a following `s_cbranch_scc1` stays refused. The test asserts that. - Refused: unaligned or out-of-range pairs, `sD` beyond `s105` or pending, and source words that are not verified. `exec`, `vcc` and immediate 64-bit sources stay unsupported. ## Tests ``` python -B tests/compute_alu_bcnt64_check.py # passes ``` The check covers: - the folded count with `sD` aliasing the low word; - zero and 64 set bits; - a runtime word from the guard fixture's constant buffer; - each refusal, including `exec`, `vcc` and an immediate source; - a mutation that drops the high word, which must change the emitted count. Registered as `compute_alu_bcnt64_controls` and added to the pure-Python lists in `AGENTS.md` and `windows.yml`. The existing controls in `compute_store_check.py` and `compute_lane_mask_check.py` still pass. Negative control: against the previous `tools/compute_store_aot.py`, the check fails with `Unsupported compute instruction: s_bcnt1_i32_b64 s4, s[4:5]`. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:57:15 +00:00
github manually merged commit 0e4342e7ed into gh-pr/2109/base 2026-11-26 23:57:16 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.