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