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