You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Native compiler: lower 32-bit bit counts and scans in the direct compute path #3050
Part of the instruction-coverage item of #2935. Target branch main (cpp-migration merged in #3039).
Gap. The direct C++ compute path refuses the 32-bit bit counts and bit scans with direct DXIL lowering for <name>:
s_bcnt0_i32_b32 and s_bcnt1_i32_b32
s_ff0_i32_b32 and s_ff1_i32_b32
s_flbit_i32_b32 and s_flbit_i32
v_ffbl_b32, v_ffbh_u32 and v_ffbh_i32
gfx2hlsl.py and tools/pixel_aot.py already lower them. They agree on these rules:
The bit counts set SCC to D != 0.
The scans return 0xffffffff when no bit qualifies, and leave SCC unchanged.
ffbh/flbit count from bit 31.
The signed forms search for the first bit that differs from the sign bit.
Measured. I ran compile_dxil --refusals (counts only) at main98007de5 on a local start-up capture of 2,689 compute requests. 12 of them stop first at one of these names: s_bcnt1_i32_b32 5, s_ff1_i32_b32 3, v_ffbl_b32 3 and v_ffbh_i32 1.
Proposed.
Lower them to DXIL Countbits, FirstbitLo, FirstbitHi and FirstbitSHi. FirstbitHi and FirstbitSHi already count from bit 31, as dxc shows: HLSL firstbithigh compiles to 31 - FirstbitHi.
Keep VOP3 modifiers refused.
Leave the 64-bit scalar forms for later.
Add a controls/hardware fixture covering negative values, single bits, 0, 0xffffffff and both SCC cases, with mutant references.
I am taking it, and the PR follows. This issue was AI-assisted.
Activity
shader: lower 32-bit bit counts and scans in direct compute (R0Y00#3051)