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

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 04:11:59 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]]
----------------
Keenuts wrote:

I'm not sur the minnum/maxnum lowering to fmin/fmax is correct.
Looking at the instruction, seems like fmin/fmax does match the minimumnum/maximumnum in regards to NaNs (but doesn't says if -0 < +0). But Seems like lowering minnum to fmin wouldn't propagate the NaN in the expected way

Should the backend refuse to lower those? Or warn to say behavior might differ slightly?

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


More information about the llvm-commits mailing list