shader: cover four multiply-high and bit-count lowerings that no draw observed #677
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/683"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 onmain. Onlytests/pixel_aot_check.pychanges; the translator does not.s_mul_hi_i32with(1, 0)(result 0)bis 0s_bcnt0_i32_b32of0xfffffffe(count 1)s_bcnt1_i32_b32of1(count 1)s_bcnt1_i32_b64of0x0000000100000001(count 2)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)inmul_hi, whose signed high half is0xffffffffand unsigned high half is 0, and0xfffffffeffffffffin 64-bit bit count, with 63 bits set. They are not tied to a mutation.Verification
On
af36232(branch on0a9cc04), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, WARP:All 297 tests pass.
Each mutation was applied to
tools/pixel_aot.pyone at a time, and all WARP tests were run. Onmain, all of them passed for each mutation. On the same harness, a control that changed the 64-bits_flbitresult (63uto62u) was caught bypixel_aot_predicate_rounding_warp, so the run does detect a broken translator. On this branch, each of the four mutations failspixel_aot_predicate_rounding_warp.Checklist
AI-assisted.
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)inmul_hi: a signed correction that treatsb == 0as negative ((asint(b) <= 0 ? a : 0u)instead of((b >> 31) != 0u ? a : 0u)) returns0xffffffffinstead of 0. The earlier rows all haveb != 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 of0xffffffffand an unsigned high half of 0, and0xfffffffeffffffff, 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.
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 observedHead
1b810b6e, merged withmain. One file,tests/pixel_aot_check.py, +8/−3. No translatorchange: coverage only.
What it adds
Rows to two existing scalar fixtures:
check_scalar_bit_count_draw: 32-bit0xfffffffeand1, plus 64-bit(1, 1)— that is0x100000001, two set bits across the pair.check_scalar_mul_hi_draw:(1, 0), a case where the high product is zero for a reason otherthan 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
Negative control: I inverted the
bcnt1_i32_b32lowering fromcountbits({0})to32u - countbits({0})and re-ran^pixel_aot_hardware$:The reserve
Neither added row introduces a shape the fixture was missing.
(1, 0)inmul_hi: both expected high halves are0, exactly like the existing(0, 0x80000000)row, so nothing about the sign is added. Worse, the fixture never exports the lowhalf at all —
v_mov_b32_e32 v15, 0hardcodes 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 highword. That is wrong —
(0x1234abcd, 0x5678ef90)hashi = 0x5678ef90. For acountbits(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 is0xffffffffwhile theunsigned one is
0, and the low word is0xffffffff. That is the one absent shape — a non-zeroproduct 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 becomes0xfffffffeffffffff, soones = 63andzeros = 1, testing64u - countbitsright next to theall-ones case. Today the only row with
zeros = 0is0xfffffffftwice.What this does not prove
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.
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 inmul_hi_i32(((b >> 31) != 0u ? a : 0u)→(asint(b) <= 0 ? a : 0u)) and ran the suite.pixel_aot_hardwarestays green on its own — that draw lives inpredicate_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 afters_bcntvias_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:RDNA4 (RX 9070 XT, vendor
1002device7550, 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)and0xfffffffeffffffff.Thanks for adding them, and for the correction.
AI-assisted; runs executed locally.