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

Merged
Leyukaka merged 2 commits from upstream-pr/2109 into main 2026-11-25 00:45:42 +00:00
Leyukaka commented 2026-11-25 00:34:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T00:34:41Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594367442 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2109). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-25T00:34:41Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:01:44 +00:00
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
R0Y00/Xbox2Windows!2102
No description provided.