@@ -945,6 +945,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
945
945
# IEEE 754-2018 compliant maximum/minimum, propagating NaNs and treating -0 as less than +0
946
946
if intr == LLVM. Intrinsic (" llvm.minimum" ) || intr == LLVM. Intrinsic (" llvm.maximum" )
947
947
typ = value_type (call)
948
+ is_minimum = intr == LLVM. Intrinsic (" llvm.minimum" )
948
949
949
950
# XXX : LLVM C API doesn't have getPrimitiveSizeInBits
950
951
jltyp = if typ == LLVM. HalfType ()
@@ -959,7 +960,12 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
959
960
960
961
# create a function that performs the IEEE-compliant operation.
961
962
# normally we'd do this inline, but LLVM.jl doesn't have BB split functionality.
962
- new_intr_fn = " air.minimum.f$(8 * sizeof (jltyp)) "
963
+ new_intr_fn = if is_minimum
964
+ " air.minimum.f$(8 * sizeof (jltyp)) "
965
+ else
966
+ " air.maximum.f$(8 * sizeof (jltyp)) "
967
+ end
968
+
963
969
if haskey (functions (mod), new_intr_fn)
964
970
new_intr = functions (mod)[new_intr_fn]
965
971
else
@@ -1017,7 +1023,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
1017
1023
position! (builder, bb_compare_zero)
1018
1024
arg0_negative = icmp! (builder, LLVM. API. LLVMIntNE, arg0_sign,
1019
1025
LLVM. ConstantInt (typ′, 0 ))
1020
- val = if intr == LLVM . Intrinsic ( " llvm.minimum " )
1026
+ val = if is_minimum
1021
1027
select! (builder, arg0_negative, arg0, arg1)
1022
1028
else
1023
1029
select! (builder, arg0_negative, arg1, arg0)
@@ -1027,7 +1033,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
1027
1033
# finally, it's safe to use the existing minnum/maxnum intrinsics
1028
1034
1029
1035
position! (builder, bb_fallback)
1030
- fallback_intr_fn = if intr == LLVM . Intrinsic ( " llvm.minimum " )
1036
+ fallback_intr_fn = if is_minimum
1031
1037
" air.fmin.f$(8 * sizeof (jltyp)) "
1032
1038
else
1033
1039
" air.fmax.f$(8 * sizeof (jltyp)) "
0 commit comments