shader: cover four multiply-high and bit-count lowerings that no draw observed #677

Merged
Leyukaka merged 2 commits from upstream-pr/683 into main 2026-11-22 22:54:39 +00:00
Leyukaka commented 2026-11-22 19:56:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T19:56:08Z.


Change

This closes four coverage gaps in the scalar multiply-high and bit-count lowering of tools/pixel_aot.py. Each was a one-line mutation that passed every WARP test on main. Only tests/pixel_aot_check.py changes; the translator does not.

New input Mutation it covers
s_mul_hi_i32 with (1, 0) (result 0) sign correction applied when b is 0
s_bcnt0_i32_b32 of 0xfffffffe (count 1) SCC set only for counts above 1
s_bcnt1_i32_b32 of 1 (count 1) SCC set only for counts above 1
s_bcnt1_i32_b64 of 0x0000000100000001 (count 2) 64-bit SCC ignores bit 1 of the count

The rows are added in front of the existing ones, so each mismatch control still reads the last row it was written for.

After review, two more rows were added (af36232): (0xffffffff, 1) in mul_hi, whose signed high half is 0xffffffff and unsigned high half is 0, and 0xfffffffeffffffff in 64-bit bit count, with 63 bits set. They are not tied to a mutation.

Verification

On af36232 (branch on 0a9cc04), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, WARP:

ctest --preset dev --no-tests=error -j 4

All 297 tests pass.

Each mutation was applied to tools/pixel_aot.py one at a time, and all WARP tests were run. On main, all of them passed for each mutation. On the same harness, a control that changed the 64-bit s_flbit result (63u to 62u) was caught by pixel_aot_predicate_rounding_warp, so the run does detect a broken translator. On this branch, each of the four mutations fails pixel_aot_predicate_rounding_warp.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6547026492 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/683). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T19:56:08Z. --- ## Change This closes four coverage gaps in the scalar multiply-high and bit-count lowering of `tools/pixel_aot.py`. Each was a one-line mutation that passed every WARP test on `main`. Only `tests/pixel_aot_check.py` changes; the translator does not. | New input | Mutation it covers | |---|---| | `s_mul_hi_i32` with `(1, 0)` (result 0) | sign correction applied when `b` is 0 | | `s_bcnt0_i32_b32` of `0xfffffffe` (count 1) | SCC set only for counts above 1 | | `s_bcnt1_i32_b32` of `1` (count 1) | SCC set only for counts above 1 | | `s_bcnt1_i32_b64` of `0x0000000100000001` (count 2) | 64-bit SCC ignores bit 1 of the count | The rows are added in front of the existing ones, so each mismatch control still reads the last row it was written for. After review, two more rows were added (af36232): `(0xffffffff, 1)` in `mul_hi`, whose signed high half is `0xffffffff` and unsigned high half is 0, and `0xfffffffeffffffff` in 64-bit bit count, with 63 bits set. They are not tied to a mutation. ## Verification On `af36232` (branch on `0a9cc04`), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, WARP: ```text ctest --preset dev --no-tests=error -j 4 ``` All 297 tests pass. Each mutation was applied to `tools/pixel_aot.py` one at a time, and all WARP tests were run. On `main`, all of them passed for each mutation. On the same harness, a control that changed the 64-bit `s_flbit` result (`63u` to `62u`) was caught by `pixel_aot_predicate_rounding_warp`, so the run does detect a broken translator. On this branch, each of the four mutations fails `pixel_aot_predicate_rounding_warp`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:18 +00:00
Leyukaka commented 2026-11-24 06:48:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T21:04:56Z.


Thanks for the run on RDNA4.

Each row was chosen for one translator mutation that every WARP test passed before:

  • (1, 0) in mul_hi: a signed correction that treats b == 0 as negative ((asint(b) <= 0 ? a : 0u) instead of ((b >> 31) != 0u ? a : 0u)) returns 0xffffffff instead of 0. The earlier rows all have b != 0.
  • (1, 1) in 64-bit bit count: as you say, it adds nothing for the count itself. It is there for SCC: its count is 2, so an SCC that ignores bit 1 of the count ((salu & ~2u) != 0u) reads false. No earlier 64-bit row has a count of 2.

s_mul_hi_* only returns the high half, so there is no low half to export; channel 3 is fixed to 0 by design.

Your two rows are added in af36232: (0xffffffff, 1), with a signed high half of 0xffffffff and an unsigned high half of 0, and 0xfffffffeffffffff, with 63 bits set. Both come before the rows the mismatch controls reuse. ctest --preset dev --no-tests=error -j 4: 297 of 297 pass on WARP.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7085770909 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/683#issuecomment-7085770909). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T21:04:56Z. --- Thanks for the run on RDNA4. Each row was chosen for one translator mutation that every WARP test passed before: - `(1, 0)` in `mul_hi`: a signed correction that treats `b == 0` as negative (`(asint(b) <= 0 ? a : 0u)` instead of `((b >> 31) != 0u ? a : 0u)`) returns `0xffffffff` instead of 0. The earlier rows all have `b != 0`. - `(1, 1)` in 64-bit bit count: as you say, it adds nothing for the count itself. It is there for SCC: its count is 2, so an SCC that ignores bit 1 of the count (`(salu & ~2u) != 0u`) reads false. No earlier 64-bit row has a count of 2. `s_mul_hi_*` only returns the high half, so there is no low half to export; channel 3 is fixed to 0 by design. Your two rows are added in af36232: `(0xffffffff, 1)`, with a signed high half of `0xffffffff` and an unsigned high half of 0, and `0xfffffffeffffffff`, with 63 bits set. Both come before the rows the mismatch controls reuse. `ctest --preset dev --no-tests=error -j 4`: 297 of 297 pass on WARP. AI-assisted.
thepatrickworld commented 2026-11-24 06:48:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T20:52:58Z.


Verification: #683 shader: cover four multiply-high and bit-count lowerings that no draw observed

Head 1b810b6e, merged with main. One file, tests/pixel_aot_check.py, +8/−3. No translator
change: coverage only.

What it adds

Rows to two existing scalar fixtures:

  • check_scalar_bit_count_draw: 32-bit 0xfffffffe and 1, plus 64-bit (1, 1) — that is
    0x100000001, two set bits across the pair.
  • check_scalar_mul_hi_draw: (1, 0), a case where the high product is zero for a reason other
    than both operands being zero.

Environment

Windows 11 25H2 build 26200.9711, MSVC 19.44.35230, DXC 1.9.2602.17, RX 9070 XT (RDNA4), driver
32.0.32029.2010.

Commands and output

ctest --preset dev --no-tests=error -R "^pixel_aot_"
100% tests passed out of 22

Negative control: I inverted the bcnt1_i32_b32 lowering from countbits({0}) to
32u - countbits({0}) and re-ran ^pixel_aot_hardware$:

0% tests passed, 1 tests failed out of 1

The reserve

Neither added row introduces a shape the fixture was missing.

(1, 0) in mul_hi: both expected high halves are 0, exactly like the existing
(0, 0x80000000) row, so nothing about the sign is added. Worse, the fixture never exports the low
half at all — v_mov_b32_e32 v15, 0 hardcodes the fourth channel to zero — so "the low half is zero"
is not even what gets measured.

(1, 1) in bit count: my first reading was that every previous 64-bit row had a zero or all-ones high
word. That is wrong — (0x1234abcd, 0x5678ef90) has hi = 0x5678ef90. For a
countbits(lo) + countbits(hi) lowering, (1, 1) changes nothing; it is just a sparse mixed case.

What I would add

For mul_hi, replace (1, 0) with (0xffffffff, 1): the signed high half is 0xffffffff while the
unsigned one is 0, and the low word is 0xffffffff. That is the one absent shape — a non-zero
product whose unsigned high half is zero — and it separates the two modes on something other than a
high-bit tail.

For bit count, replace (1, 1) with (0xffffffff, 0xfffffffe): the word becomes
0xfffffffeffffffff, so ones = 63 and zeros = 1, testing 64u - countbits right next to the
all-ones case. Today the only row with zeros = 0 is 0xffffffff twice.

What this does not prove

  • Nothing about the multiply-high forms beyond the low half being zero in one new row.
  • Nothing about 64-bit bit-count when both words are zero, which is the only case a lazy helper
    could get wrong.

Merge note: this head, #679 and #687 branch from the same blob (11f47701) on the same file. Their hunks are disjoint, so no conflict today, but each will need a rebase after the first one lands.

AI-assisted; runs executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7085617706 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/683#issuecomment-7085617706). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-22T20:52:58Z. --- **Verification: #683 `shader: cover four multiply-high and bit-count lowerings that no draw observed`** Head `1b810b6e`, merged with `main`. One file, `tests/pixel_aot_check.py`, +8/−3. No translator change: coverage only. ### What it adds Rows to two existing scalar fixtures: - `check_scalar_bit_count_draw`: 32-bit `0xfffffffe` and `1`, plus 64-bit `(1, 1)` — that is `0x100000001`, two set bits across the pair. - `check_scalar_mul_hi_draw`: `(1, 0)`, a case where the high product is zero for a reason other than both operands being zero. ### Environment Windows 11 25H2 build 26200.9711, MSVC 19.44.35230, DXC 1.9.2602.17, RX 9070 XT (RDNA4), driver 32.0.32029.2010. ### Commands and output ``` ctest --preset dev --no-tests=error -R "^pixel_aot_" 100% tests passed out of 22 ``` Negative control: I inverted the `bcnt1_i32_b32` lowering from `countbits({0})` to `32u - countbits({0})` and re-ran `^pixel_aot_hardware$`: ``` 0% tests passed, 1 tests failed out of 1 ``` ### The reserve Neither added row introduces a shape the fixture was missing. `(1, 0)` in `mul_hi`: both expected high halves are `0`, exactly like the existing `(0, 0x80000000)` row, so nothing about the sign is added. Worse, the fixture never exports the low half at all — `v_mov_b32_e32 v15, 0` hardcodes the fourth channel to zero — so "the low half is zero" is not even what gets measured. `(1, 1)` in bit count: my first reading was that every previous 64-bit row had a zero or all-ones high word. That is wrong — `(0x1234abcd, 0x5678ef90)` has `hi = 0x5678ef90`. For a `countbits(lo) + countbits(hi)` lowering, `(1, 1)` changes nothing; it is just a sparse mixed case. ### What I would add For `mul_hi`, replace `(1, 0)` with `(0xffffffff, 1)`: the signed high half is `0xffffffff` while the unsigned one is `0`, and the low word is `0xffffffff`. That is the one absent shape — a non-zero product whose unsigned high half is zero — and it separates the two modes on something other than a high-bit tail. For bit count, replace `(1, 1)` with `(0xffffffff, 0xfffffffe)`: the word becomes `0xfffffffeffffffff`, so `ones = 63` and `zeros = 1`, testing `64u - countbits` right next to the all-ones case. Today the only row with `zeros = 0` is `0xffffffff` twice. ### What this does not prove - Nothing about the multiply-high forms beyond the low half being zero in one new row. - Nothing about 64-bit bit-count when both words are zero, which is the only case a lazy helper could get wrong. Merge note: this head, #679 and #687 branch from the same blob (`11f47701`) on the same file. Their hunks are disjoint, so no conflict today, but each will need a rebase after the first one lands. _AI-assisted; runs executed locally._
thepatrickworld commented 2026-11-24 06:48:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T21:40:19Z.


Hardware run on af36232 — you were right on both rows.

mul_hi (1, 0): I applied your mutation in mul_hi_i32 (((b >> 31) != 0u ? a : 0u) → (asint(b) <= 0 ? a : 0u)) and ran the suite.

6/22 Test #249: pixel_aot_predicate_rounding_hardware ...***Failed   18.98 sec
17/22 Test #277: pixel_aot_predicate_rounding_warp .......***Failed   8.56 sec
91% tests passed, 2 tests failed out of 22

pixel_aot_hardware stays green on its own — that draw lives in predicate_rounding, and my first pass filtered on ^pixel_aot_hardware$, so I saw nothing and called the row redundant. Your row does kill that mutation. My mistake, and a filter mistake rather than a reading of the code.

s_mul_hi_*: agreed, there is no low half to export. I was reading the fixture as a full 32×32→64 multiply when the instruction only produces the high half; channel 3 at 0 is the only thing it could be. Withdrawn.

64-bit bit count (1, 1): your SCC argument checks out against the fixture — the SCC is sampled right after s_bcnt via s_cselect, and 2 is the only count among the 64-bit rows with bit 1 set. That is a real distinction I had not looked for.

Hardware result on af36232:

ctest --preset dev --no-tests=error -R "^pixel_aot_"
100% tests passed out of 22

RDNA4 (RX 9070 XT, vendor 1002 device 7550, driver 32.0.32029.2010), Windows 11 25H2 build 26200.9711, MSVC 19.44.35230, DXC 1.9.2602.17. Both new rows pass, (0xffffffff, 1) and 0xfffffffeffffffff.

Thanks for adding them, and for the correction.

AI-assisted; runs executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7086226325 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/683#issuecomment-7086226325). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-22T21:40:19Z. --- **Hardware run on `af36232` — you were right on both rows.** `mul_hi` `(1, 0)`: I applied your mutation in `mul_hi_i32` (`((b >> 31) != 0u ? a : 0u)` → `(asint(b) <= 0 ? a : 0u)`) and ran the suite. ``` 6/22 Test #249: pixel_aot_predicate_rounding_hardware ...***Failed 18.98 sec 17/22 Test #277: pixel_aot_predicate_rounding_warp .......***Failed 8.56 sec 91% tests passed, 2 tests failed out of 22 ``` `pixel_aot_hardware` stays green on its own — that draw lives in `predicate_rounding`, and my first pass filtered on `^pixel_aot_hardware$`, so I saw nothing and called the row redundant. Your row does kill that mutation. My mistake, and a filter mistake rather than a reading of the code. `s_mul_hi_*`: agreed, there is no low half to export. I was reading the fixture as a full 32×32→64 multiply when the instruction only produces the high half; channel 3 at 0 is the only thing it could be. Withdrawn. 64-bit bit count `(1, 1)`: your SCC argument checks out against the fixture — the SCC is sampled right after `s_bcnt` via `s_cselect`, and 2 is the only count among the 64-bit rows with bit 1 set. That is a real distinction I had not looked for. Hardware result on `af36232`: ``` ctest --preset dev --no-tests=error -R "^pixel_aot_" 100% tests passed out of 22 ``` RDNA4 (RX 9070 XT, vendor `1002` device `7550`, driver 32.0.32029.2010), Windows 11 25H2 build 26200.9711, MSVC 19.44.35230, DXC 1.9.2602.17. Both new rows pass, `(0xffffffff, 1)` and `0xfffffffeffffffff`. Thanks for adding them, and for the correction. _AI-assisted; runs executed locally._
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!677
No description provided.