Skip to content

[SPIR-V] fma emits GLSL.std.450 Fma instead of OpFmaKHR #8330

@kmpeng

Description

@kmpeng

Description
When compiling the HLSL fma intrinsic to SPIR-V, DXC emits the GLSL.std.450 Fma instruction. According to the Vulkan spec, this instruction is not guaranteed to be implemented in hardware as a fused operation. HLSL's fma intrinsic specifically requires fused semantics, so emitting this GLSL instruction does not seem correct. This also appears to be the root cause of this issue in the offload-test-suite. On Intel Vulkan, the driver gives the wrong output for one of the precision sensitive constant-folding cases (though the buffer equivalent case produces the correct result).

The fix for this would be to emit OpFmaKHR from SPV_KHR_fma instead, which guarantees a fused operation. This is also what Clang currently does.

Repro
https://godbolt.org/z/ezEexaGMa

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions