diff options
| author | gingerBill <bill@gingerbill.org> | 2024-03-06 15:07:21 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-03-06 15:07:21 +0000 |
| commit | a7bab89c934d181ddbfa6e17103b2587581ee5e9 (patch) | |
| tree | dc285f349b2bca963f8bf4982fae24ca46a537bb /src/llvm_backend_utility.cpp | |
| parent | a1ee9e70352c6ab0402f98c3b84f8b3f0c86e6f9 (diff) | |
Unify min/max semantics for simd_(min|max)
Diffstat (limited to 'src/llvm_backend_utility.cpp')
| -rw-r--r-- | src/llvm_backend_utility.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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. |