[SPIR-V] Invalid SPIR-V operand with isnan()
Description DXC generates an invalid SPIR-V
Steps to Reproduce
dxc -T cs_6_0 -spirv path/to/file.hlsl
HLSL code:
RWStructuredBuffer<float> Out;
[numthreads(1, 1, 1)]
void main(uint id : SV_DispatchThreadID)
{
bool bar = isnan(Out[id]);
Out[id] = (float)bar;
}
If we change the code as follows, the issue is not occurred.
float baz = Out[id];
Out[id] = (float)isnan(baz);
Actual Behavior
fatal error: generated SPIR-V is invalid: Expected bool scalar or vector type as Result Type: IsNan %23 = OpIsNan %uint %22 note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Environment
- DXC version: libdxcompiler.dylib: 1.8(dev;4640-45018c75)
- Host Operating System: Windows 11 23H2 and macOS 14.5
If you're interested in a quick fix, you can use inline SPIR-V to use OpIsNan directly
Indeed, by defining a new function as follows, we can pass the validation.
[[vk::ext_instruction(156)]]
bool alt_isnan(float v1);
RWStructuredBuffer
Thanks for the issue! Sent a PR 😊 Most of the team being OOO, there might be some delays, but it's on its way.