xref: /freebsd/contrib/arm-optimized-routines/math/aarch64/sve/log1pf.c (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1 /*
2  * Single-precision vector log(x + 1) function.
3  *
4  * Copyright (c) 2023-2024, Arm Limited.
5  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6  */
7 
8 #include "sv_math.h"
9 #include "test_sig.h"
10 #include "test_defs.h"
11 #include "sv_log1pf_inline.h"
12 
13 static svfloat32_t NOINLINE
14 special_case (svfloat32_t x, svbool_t special)
15 {
16   return sv_call_f32 (log1pf, x, sv_log1pf_inline (x, svptrue_b32 ()),
17 		      special);
18 }
19 
20 /* Vector log1pf approximation using polynomial on reduced interval. Worst-case
21    error is 1.27 ULP very close to 0.5.
22    _ZGVsMxv_log1pf(0x1.fffffep-2) got 0x1.9f324p-2
23 				 want 0x1.9f323ep-2.  */
24 svfloat32_t SV_NAME_F1 (log1p) (svfloat32_t x, svbool_t pg)
25 {
26   /* x < -1, Inf/Nan.  */
27   svbool_t special = svcmpeq (pg, svreinterpret_u32 (x), 0x7f800000);
28   special = svorn_z (pg, special, svcmpge (pg, x, -1));
29 
30   if (unlikely (svptest_any (pg, special)))
31     return special_case (x, special);
32 
33   return sv_log1pf_inline (x, pg);
34 }
35 
36 TEST_SIG (SV, F, 1, log1p, -0.9, 10.0)
37 TEST_ULP (SV_NAME_F1 (log1p), 0.77)
38 TEST_DISABLE_FENV (SV_NAME_F1 (log1p))
39 TEST_SYM_INTERVAL (SV_NAME_F1 (log1p), 0, 0x1p-23, 5000)
40 TEST_SYM_INTERVAL (SV_NAME_F1 (log1p), 0x1p-23, 1, 5000)
41 TEST_INTERVAL (SV_NAME_F1 (log1p), 1, inf, 10000)
42 TEST_INTERVAL (SV_NAME_F1 (log1p), -1, -inf, 10)
43 CLOSE_SVE_ATTR
44