xref: /freebsd/contrib/arm-optimized-routines/math/aarch64/advsimd/sincospif.c (revision f3087bef11543b42e0d69b708f367097a4118d24)
1 /*
2  * Single-precision vector sincospi function.
3  *
4  * Copyright (c) 2024, Arm Limited.
5  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6  */
7 
8 #include "v_sincospif_common.h"
9 #include "v_math.h"
10 #include "test_defs.h"
11 #include "mathlib.h"
12 
13 /* Single-precision vector function allowing calculation of both sinpi and
14    cospi in one function call, using shared argument reduction and polynomials.
15    Worst-case error for sin is 3.04 ULP:
16    _ZGVnN4v_sincospif_sin(0x1.1d341ap-1) got 0x1.f7cd56p-1 want 0x1.f7cd5p-1.
17    Worst-case error for cos is 3.18 ULP:
18    _ZGVnN4v_sincospif_cos(0x1.d341a8p-5) got 0x1.f7cd56p-1 want 0x1.f7cd5p-1.
19  */
20 VPCS_ATTR void
_ZGVnN4vl4l4_sincospif(float32x4_t x,float * out_sin,float * out_cos)21 _ZGVnN4vl4l4_sincospif (float32x4_t x, float *out_sin, float *out_cos)
22 {
23   const struct v_sincospif_data *d = ptr_barrier (&v_sincospif_data);
24 
25   float32x4x2_t sc = v_sincospif_inline (x, d);
26 
27   vst1q_f32 (out_sin, sc.val[0]);
28   vst1q_f32 (out_cos, sc.val[1]);
29 }
30 
31 #if WANT_TRIGPI_TESTS
32 TEST_DISABLE_FENV (_ZGVnN4v_sincospif_sin)
33 TEST_DISABLE_FENV (_ZGVnN4v_sincospif_cos)
34 TEST_ULP (_ZGVnN4v_sincospif_sin, 2.54)
35 TEST_ULP (_ZGVnN4v_sincospif_cos, 2.68)
36 #  define V_SINCOSPIF_INTERVAL(lo, hi, n)                                     \
37     TEST_SYM_INTERVAL (_ZGVnN4v_sincospif_sin, lo, hi, n)                     \
38     TEST_SYM_INTERVAL (_ZGVnN4v_sincospif_cos, lo, hi, n)
39 V_SINCOSPIF_INTERVAL (0, 0x1p-63, 10000)
40 V_SINCOSPIF_INTERVAL (0x1p-63, 0.5, 50000)
41 V_SINCOSPIF_INTERVAL (0.5, 0x1p31, 50000)
42 V_SINCOSPIF_INTERVAL (0x1p31, inf, 10000)
43 #endif
44