aboutsummaryrefslogtreecommitdiff
path: root/math/aarch64/advsimd/cexpif.c
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2025-01-10 10:34:52 +0000
committerAndrew Turner <andrew@FreeBSD.org>2025-01-10 10:39:34 +0000
commit9d1de25930735261c16ed874a933b4c1f1d9041e (patch)
treeb0cac1c933cc1ecb885c7e757b89ffbf13f1f012 /math/aarch64/advsimd/cexpif.c
parentedc5c0de794f521eb620d2b6cbaee2434442a8f3 (diff)
Diffstat (limited to 'math/aarch64/advsimd/cexpif.c')
-rw-r--r--math/aarch64/advsimd/cexpif.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/math/aarch64/advsimd/cexpif.c b/math/aarch64/advsimd/cexpif.c
new file mode 100644
index 000000000000..e55d99653a66
--- /dev/null
+++ b/math/aarch64/advsimd/cexpif.c
@@ -0,0 +1,49 @@
+/*
+ * Single-precision vector cexpi function.
+ *
+ * Copyright (c) 2023-2024, Arm Limited.
+ * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
+ */
+
+#include "v_sincosf_common.h"
+#include "v_math.h"
+#include "test_defs.h"
+
+static float32x4x2_t VPCS_ATTR NOINLINE
+special_case (float32x4_t x, uint32x4_t special, float32x4x2_t y)
+{
+ return (float32x4x2_t){ v_call_f32 (sinf, x, y.val[0], special),
+ v_call_f32 (cosf, x, y.val[1], special) };
+}
+
+/* Single-precision vector function allowing calculation of both sin and cos in
+ one function call, using shared argument reduction and separate low-order
+ polynomials.
+ Worst-case error for sin is 1.67 ULP:
+ v_cexpif_sin(0x1.c704c4p+19) got 0x1.fff698p-5 want 0x1.fff69cp-5
+ Worst-case error for cos is 1.81 ULP:
+ v_cexpif_cos(0x1.e506fp+19) got -0x1.ffec6ep-6 want -0x1.ffec72p-6. */
+VPCS_ATTR float32x4x2_t
+_ZGVnN4v_cexpif (float32x4_t x)
+{
+ const struct v_sincosf_data *d = ptr_barrier (&v_sincosf_data);
+ uint32x4_t special = check_ge_rangeval (x, d);
+
+ float32x4x2_t sc = v_sincosf_inline (x, d);
+
+ if (unlikely (v_any_u32 (special)))
+ return special_case (x, special, sc);
+ return sc;
+}
+
+TEST_DISABLE_FENV (_ZGVnN4v_cexpif_sin)
+TEST_DISABLE_FENV (_ZGVnN4v_cexpif_cos)
+TEST_ULP (_ZGVnN4v_cexpif_sin, 1.17)
+TEST_ULP (_ZGVnN4v_cexpif_cos, 1.31)
+#define V_CEXPIF_INTERVAL(lo, hi, n) \
+ TEST_INTERVAL (_ZGVnN4v_cexpif_sin, lo, hi, n) \
+ TEST_INTERVAL (_ZGVnN4v_cexpif_cos, lo, hi, n)
+V_CEXPIF_INTERVAL (0, 0x1p20, 500000)
+V_CEXPIF_INTERVAL (-0, -0x1p20, 500000)
+V_CEXPIF_INTERVAL (0x1p20, inf, 10000)
+V_CEXPIF_INTERVAL (-0x1p20, -inf, 10000)