1*f3087befSAndrew Turner /*
2*f3087befSAndrew Turner * Single-precision vector cexpi function.
3*f3087befSAndrew Turner *
4*f3087befSAndrew Turner * Copyright (c) 2023-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 "sv_sincosf_common.h"
10*f3087befSAndrew Turner #include "test_defs.h"
11*f3087befSAndrew Turner
12*f3087befSAndrew Turner static svfloat32x2_t NOINLINE
special_case(svfloat32_t x,svbool_t special,svfloat32x2_t y)13*f3087befSAndrew Turner special_case (svfloat32_t x, svbool_t special, svfloat32x2_t y)
14*f3087befSAndrew Turner {
15*f3087befSAndrew Turner return svcreate2 (sv_call_f32 (sinf, x, svget2 (y, 0), special),
16*f3087befSAndrew Turner sv_call_f32 (cosf, x, svget2 (y, 1), special));
17*f3087befSAndrew Turner }
18*f3087befSAndrew Turner
19*f3087befSAndrew Turner /* Single-precision vector function allowing calculation of both sin and cos in
20*f3087befSAndrew Turner one function call, using shared argument reduction and separate low-order
21*f3087befSAndrew Turner polynomials.
22*f3087befSAndrew Turner Worst-case error for sin is 1.67 ULP:
23*f3087befSAndrew Turner v_cexpif_sin(0x1.c704c4p+19) got 0x1.fff698p-5 want 0x1.fff69cp-5
24*f3087befSAndrew Turner Worst-case error for cos is 1.81 ULP:
25*f3087befSAndrew Turner v_cexpif_cos(0x1.e506fp+19) got -0x1.ffec6ep-6 want -0x1.ffec72p-6. */
26*f3087befSAndrew Turner svfloat32x2_t
_ZGVsMxv_cexpif(svfloat32_t x,svbool_t pg)27*f3087befSAndrew Turner _ZGVsMxv_cexpif (svfloat32_t x, svbool_t pg)
28*f3087befSAndrew Turner {
29*f3087befSAndrew Turner const struct sv_sincosf_data *d = ptr_barrier (&sv_sincosf_data);
30*f3087befSAndrew Turner svbool_t special = check_ge_rangeval (pg, x, d);
31*f3087befSAndrew Turner
32*f3087befSAndrew Turner svfloat32x2_t sc = sv_sincosf_inline (pg, x, d);
33*f3087befSAndrew Turner
34*f3087befSAndrew Turner if (unlikely (svptest_any (pg, special)))
35*f3087befSAndrew Turner return special_case (x, special, sc);
36*f3087befSAndrew Turner return sc;
37*f3087befSAndrew Turner }
38*f3087befSAndrew Turner
39*f3087befSAndrew Turner TEST_DISABLE_FENV (_ZGVsMxv_cexpif_sin)
40*f3087befSAndrew Turner TEST_DISABLE_FENV (_ZGVsMxv_cexpif_cos)
41*f3087befSAndrew Turner TEST_ULP (_ZGVsMxv_cexpif_sin, 1.17)
42*f3087befSAndrew Turner TEST_ULP (_ZGVsMxv_cexpif_cos, 1.31)
43*f3087befSAndrew Turner #define SV_CEXPIF_INTERVAL(lo, hi, n) \
44*f3087befSAndrew Turner TEST_INTERVAL (_ZGVsMxv_cexpif_sin, lo, hi, n) \
45*f3087befSAndrew Turner TEST_INTERVAL (_ZGVsMxv_cexpif_cos, lo, hi, n)
46*f3087befSAndrew Turner SV_CEXPIF_INTERVAL (0, 0x1p20, 500000)
47*f3087befSAndrew Turner SV_CEXPIF_INTERVAL (-0, -0x1p20, 500000)
48*f3087befSAndrew Turner SV_CEXPIF_INTERVAL (0x1p20, inf, 10000)
49*f3087befSAndrew Turner SV_CEXPIF_INTERVAL (-0x1p20, -inf, 10000)
50*f3087befSAndrew Turner CLOSE_SVE_ATTR
51