1*f3087befSAndrew Turner /*
2*f3087befSAndrew Turner * Single-precision SVE sincospi(x, *y, *z) 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 "sv_math.h"
9*f3087befSAndrew Turner #include "test_defs.h"
10*f3087befSAndrew Turner #include "mathlib.h"
11*f3087befSAndrew Turner #include "sv_sincospif_common.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 _ZGVsMxvl4l4_sincospif_sin(0x1.b51b8p-2) got 0x1.f28b5ep-1 want
17*f3087befSAndrew Turner 0x1.f28b58p-1.
18*f3087befSAndrew Turner Worst-case error for cos is 3.18 ULP:
19*f3087befSAndrew Turner _ZGVsMxvl4l4_sincospif_cos(0x1.d341a8p-5) got 0x1.f7cd56p-1 want
20*f3087befSAndrew Turner 0x1.f7cd5p-1. */
21*f3087befSAndrew Turner void
_ZGVsMxvl4l4_sincospif(svfloat32_t x,float * out_sin,float * out_cos,svbool_t pg)22*f3087befSAndrew Turner _ZGVsMxvl4l4_sincospif (svfloat32_t x, float *out_sin, float *out_cos,
23*f3087befSAndrew Turner svbool_t pg)
24*f3087befSAndrew Turner {
25*f3087befSAndrew Turner const struct sv_sincospif_data *d = ptr_barrier (&sv_sincospif_data);
26*f3087befSAndrew Turner
27*f3087befSAndrew Turner svfloat32x2_t sc = sv_sincospif_inline (pg, x, d);
28*f3087befSAndrew Turner
29*f3087befSAndrew Turner svst1 (pg, out_sin, svget2 (sc, 0));
30*f3087befSAndrew Turner svst1 (pg, out_cos, svget2 (sc, 1));
31*f3087befSAndrew Turner }
32*f3087befSAndrew Turner
33*f3087befSAndrew Turner #if WANT_TRIGPI_TESTS
34*f3087befSAndrew Turner TEST_DISABLE_FENV (_ZGVsMxvl4l4_sincospif_sin)
35*f3087befSAndrew Turner TEST_DISABLE_FENV (_ZGVsMxvl4l4_sincospif_cos)
36*f3087befSAndrew Turner TEST_ULP (_ZGVsMxvl4l4_sincospif_sin, 2.54)
37*f3087befSAndrew Turner TEST_ULP (_ZGVsMxvl4l4_sincospif_cos, 2.68)
38*f3087befSAndrew Turner # define SV_SINCOSPIF_INTERVAL(lo, hi, n) \
39*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVsMxvl4l4_sincospif_sin, lo, hi, n) \
40*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVsMxvl4l4_sincospif_cos, lo, hi, n)
41*f3087befSAndrew Turner SV_SINCOSPIF_INTERVAL (0, 0x1p-31, 10000)
42*f3087befSAndrew Turner SV_SINCOSPIF_INTERVAL (0x1p-31, 0.5, 50000)
43*f3087befSAndrew Turner SV_SINCOSPIF_INTERVAL (0.5, 0x1p31, 50000)
44*f3087befSAndrew Turner SV_SINCOSPIF_INTERVAL (0x1p31, inf, 10000)
45*f3087befSAndrew Turner #endif
46*f3087befSAndrew Turner CLOSE_SVE_ATTR
47