[llvm] [SPIRV] Lower G_FMINIMUMNUM/G_FMAXIMUMNUM to OpenCL extended inst fmin/fmax (PR #153550)

Wenju He via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 15 00:05:35 PDT 2025


================
@@ -218,6 +226,53 @@ define float @scalar_log2(float %a) {
     ret float %r
 }
 
+; CHECK:      %[[#SCALAR_MINNUM]] = OpFunction
+; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
+; CHECK-NEXT: %[[#B:]] = OpFunctionParameter
+; CHECK:      OpLabel
+; CHECK:      %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] fmin %[[#A]] %[[#B]]
----------------
wenju-he wrote:

> I'm not sur the minnum/maxnum lowering to fmin/fmax is correct.

It is probably incorrect and a fix is needed. There is an llvm-spirv issue for it: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/3282

> (but doesn't says if -0 < +0).

I have created an issue in OpenCL spec for clarification of -0 vs +0: https://github.com/KhronosGroup/OpenCL-Docs/issues/1442


https://github.com/llvm/llvm-project/pull/153550


More information about the llvm-commits mailing list