DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
[SPIR-V] Incorrect SPIR-V generated for `countbits` for non-32 bit type integers
Description
Saw this error:
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-Base-04781] Expected 32-bit int type for Base operand: BitCount
%43 = OpBitCount %v4uint %42
when compiling this code:
StructuredBuffer<int16_t4> In : register(t0);
RWStructuredBuffer<uint4> Out : register(u2);
[numthreads(1,1,1)]
void main() {
Out[0] = countbits(In[0]);
}
The same error occurs when using int64_t as well.
Steps to Reproduce https://godbolt.org/z/65fKP583e
Actual Behavior
From the validator specs, the validator doesn't allow OpBitCount to have non-32 bit integer types
Note: This is in contrast to the spir-v OpBitCount specification that denotes the Result and Base type can be a scalar or vector of integer type.
This will most likely require emulation of the non-32 bit types.
Environment DXC version 1.8.2403.2 Host Operating System N/A