1*f3087befSAndrew Turner /*
2*f3087befSAndrew Turner * Single-precision vector log(x + 1) 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 "test_sig.h"
10*f3087befSAndrew Turner #include "test_defs.h"
11*f3087befSAndrew Turner #include "sv_log1pf_inline.h"
12*f3087befSAndrew Turner
13*f3087befSAndrew Turner static svfloat32_t NOINLINE
special_case(svfloat32_t x,svbool_t special)14*f3087befSAndrew Turner special_case (svfloat32_t x, svbool_t special)
15*f3087befSAndrew Turner {
16*f3087befSAndrew Turner return sv_call_f32 (log1pf, x, sv_log1pf_inline (x, svptrue_b32 ()),
17*f3087befSAndrew Turner special);
18*f3087befSAndrew Turner }
19*f3087befSAndrew Turner
20*f3087befSAndrew Turner /* Vector log1pf approximation using polynomial on reduced interval. Worst-case
21*f3087befSAndrew Turner error is 1.27 ULP very close to 0.5.
22*f3087befSAndrew Turner _ZGVsMxv_log1pf(0x1.fffffep-2) got 0x1.9f324p-2
23*f3087befSAndrew Turner want 0x1.9f323ep-2. */
SV_NAME_F1(log1p)24*f3087befSAndrew Turner svfloat32_t SV_NAME_F1 (log1p) (svfloat32_t x, svbool_t pg)
25*f3087befSAndrew Turner {
26*f3087befSAndrew Turner /* x < -1, Inf/Nan. */
27*f3087befSAndrew Turner svbool_t special = svcmpeq (pg, svreinterpret_u32 (x), 0x7f800000);
28*f3087befSAndrew Turner special = svorn_z (pg, special, svcmpge (pg, x, -1));
29*f3087befSAndrew Turner
30*f3087befSAndrew Turner if (unlikely (svptest_any (pg, special)))
31*f3087befSAndrew Turner return special_case (x, special);
32*f3087befSAndrew Turner
33*f3087befSAndrew Turner return sv_log1pf_inline (x, pg);
34*f3087befSAndrew Turner }
35*f3087befSAndrew Turner
36*f3087befSAndrew Turner TEST_SIG (SV, F, 1, log1p, -0.9, 10.0)
37*f3087befSAndrew Turner TEST_ULP (SV_NAME_F1 (log1p), 0.77)
38*f3087befSAndrew Turner TEST_DISABLE_FENV (SV_NAME_F1 (log1p))
39*f3087befSAndrew Turner TEST_SYM_INTERVAL (SV_NAME_F1 (log1p), 0, 0x1p-23, 5000)
40*f3087befSAndrew Turner TEST_SYM_INTERVAL (SV_NAME_F1 (log1p), 0x1p-23, 1, 5000)
41*f3087befSAndrew Turner TEST_INTERVAL (SV_NAME_F1 (log1p), 1, inf, 10000)
42*f3087befSAndrew Turner TEST_INTERVAL (SV_NAME_F1 (log1p), -1, -inf, 10)
43*f3087befSAndrew Turner CLOSE_SVE_ATTR
44