shader: lower scalar bit-count instructions in pixel_aot #599
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/605"
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 descent81 on 2026-11-22T15:24:47Z.
Change
pixel_aotnow translates four SOP1 instructions:s_bcnt0_i32_b32,s_bcnt1_i32_b32,s_bcnt0_i32_b64, ands_bcnt1_i32_b64. They count zeros or ones over the source width and set SCC when the count is nonzero. The 64-bit path reads the existing SGPR pair representation and counts both 32-bit words. It uses 32-bit HLSL operations.Verification
Tested commit
3139ef3on base3ffc193. The fixture exports both counts and both SCC values. Python computes the reference with integerbit_count(). Counts are encoded as1 + count/1024, which is exact through the binary16 pixel export for every possible count. Before each count, the fixture seeds SCC to the opposite of the expected result so a lowering that leaves SCC unchanged fails.For the 64-bit input
0x80000000_00000000, the expected counts are 63 zeros and one one. A second shader replaces the 64-bit ones count with a low-word-only count and uses the unchanged reference. Both backends reportedpixel_mismatch. The all-zero and all-one inputs exercise the zero count and cleared SCC for each operation.From the repository root, with the documented Windows dev build or LLVM 15 installed:
Evidence and follow-up
The fixture uses source-written assembly and synthetic inputs under the repository's MIT license. This change is scoped to scalar counts; the coverage comparison above uses the existing dashboard references. AMD RDNA 2 ISA reference
AI-assisted.