From a7bab89c934d181ddbfa6e17103b2587581ee5e9 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 6 Mar 2024 15:07:21 +0000 Subject: Unify min/max semantics for simd_(min|max) --- src/llvm_backend_utility.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/llvm_backend_utility.cpp') diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index 0f5d7fb43..2c80f9c6a 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -124,7 +124,8 @@ gb_internal lbValue lb_emit_select(lbProcedure *p, lbValue cond, lbValue x, lbVa gb_internal lbValue lb_emit_min(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); - if (is_type_float(t)) { + bool use_llvm_intrinsic = is_type_float(t) || (is_type_simd_vector(t) && is_type_float(base_array_type(t))); + if (use_llvm_intrinsic) { // NOTE(bill): f either operand is a NaN, returns NaN. Otherwise returns the lesser of the two arguments. // -0.0 is considered to be less than +0.0 for this intrinsic. // These semantics are specified by IEEE 754-2019. @@ -138,7 +139,8 @@ gb_internal lbValue lb_emit_min(lbProcedure *p, Type *t, lbValue x, lbValue y) { gb_internal lbValue lb_emit_max(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); - if (is_type_float(t)) { + bool use_llvm_intrinsic = is_type_float(t) || (is_type_simd_vector(t) && is_type_float(base_array_type(t))); + if (use_llvm_intrinsic) { // NOTE(bill): If either operand is a NaN, returns NaN. Otherwise returns the greater of the two arguments. // -0.0 is considered to be less than +0.0 for this intrinsic. // These semantics are specified by IEEE 754-2019. -- cgit v1.2.3