llvm-project/llvm/test/CodeGen/SPIRV/capability-FloatControl2.ll
Steven Perron 4e213159af
[SPIRV] Add FloatControl2 capability (#144371)
Add handling for FPFastMathMode in SPIR-V shaders. This is a first pass
that
simply does a direct translation when the proper extension is available.
This will unblock work for HLSL. However, it is not a full solution.

The default math mode for spir-v is determined by the API. When
targeting Vulkan many of the fast math options are assumed. We should do
something particular when targeting Vulkan.

We will also need to handle the hlsl "precise" keyword correctly when
FPFastMathMode is not available.

Unblockes https://github.com/llvm/llvm-project/issues/140739, but we are
keeing it open to track the remaining issues mentioned above.
2025-07-02 08:48:57 -04:00

23 lines
1.0 KiB
LLVM

; RUN: llc -O0 -mtriple=spirv1.6-vulkan1.3-compute %s -o - | FileCheck %s --check-prefix=CHECK-NOEXT
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-vulkan1.3-compute %s -o - -filetype=obj | spirv-val --target-env vulkan1.3 %}
; RUN: llc -O0 -mtriple=spirv1.6-vulkan1.3-compute -spirv-ext=+SPV_KHR_float_controls2 %s -o - | FileCheck %s --check-prefix=CHECK-EXT
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-vulkan1.3-compute -spirv-ext=+SPV_KHR_float_controls2 %s -o - -filetype=obj | spirv-val --target-env vulkan1.3 %}
; CHECK-NOEXT-NOT: OpDecorate FPFastMathMode
; CHECK-EXT: OpCapability FloatControls2
; CHECK-EXT: OpExtension "SPV_KHR_float_controls2"
; CHECK-EXT: OpDecorate {{%[0-9]+}} FPFastMathMode NotNaN|NotInf|NSZ|AllowRecip|Fast
define hidden spir_func float @foo(float %0) local_unnamed_addr {
%2 = fmul reassoc nnan ninf nsz arcp afn float %0, 2.000000e+00
ret float %2
}
define void @main() local_unnamed_addr #1 {
ret void
}
attributes #1 = { "hlsl.numthreads"="8,1,1" "hlsl.shader"="compute" }