diff options
author | Elliott Hughes <enh@google.com> | 2023-01-25 21:31:42 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-01-25 21:31:42 +0000 |
commit | 8a481eb48cf7ace04026cbe776d65492f89a6d7d (patch) | |
tree | 945eb1832687ad5eb97c433013617dbe107718e5 /pl/math/sv_atanf_common.h | |
parent | 0bc581b0e4f509c96bffa7af329087ae2b4bfb97 (diff) | |
parent | 8783f524beaad825ac1bddeb93cef35b5f793513 (diff) | |
download | arm-optimized-routines-8a481eb48cf7ace04026cbe776d65492f89a6d7d.tar.gz |
Upgrade ARM-software/optimized-routines to v23.01 am: 62662f115a am: 8783f524be
Original change: https://android-review.googlesource.com/c/platform/external/arm-optimized-routines/+/2402215
Change-Id: Ief5438cf89d86c43e5f52d5e48b882bacb945170
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'pl/math/sv_atanf_common.h')
-rw-r--r-- | pl/math/sv_atanf_common.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pl/math/sv_atanf_common.h b/pl/math/sv_atanf_common.h new file mode 100644 index 0000000..dc45eff --- /dev/null +++ b/pl/math/sv_atanf_common.h @@ -0,0 +1,47 @@ +/* + * Single-precision polynomial evaluation function for SVE atan(x) and + * atan2(y,x). + * + * Copyright (c) 2021-2023, Arm Limited. + * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception + */ + +#ifndef PL_MATH_SV_ATANF_COMMON_H +#define PL_MATH_SV_ATANF_COMMON_H + +#include "math_config.h" +#include "sv_math.h" + +#define P(i) sv_f32 (__atanf_poly_data.poly[i]) + +/* Polynomial used in fast SVE atanf(x) and atan2f(y,x) implementations + The order 7 polynomial P approximates (f(sqrt(x))-sqrt(x))/x^(3/2). */ +static inline sv_f32_t +__sv_atanf_common (svbool_t pg, svbool_t red, sv_f32_t z, sv_f32_t az, + sv_f32_t shift) +{ + /* Use full Estrin scheme for P(z^2) with deg(P)=7. */ + + /* First compute square powers of z. */ + sv_f32_t z2 = svmul_f32_x (pg, z, z); + sv_f32_t z4 = svmul_f32_x (pg, z2, z2); + sv_f32_t z8 = svmul_f32_x (pg, z4, z4); + + /* Then assemble polynomial. */ + sv_f32_t p_4_7 = sv_fma_f32_x (pg, z4, (sv_fma_f32_x (pg, z2, P (7), P (6))), + (sv_fma_f32_x (pg, z2, P (5), P (4)))); + sv_f32_t p_0_3 = sv_fma_f32_x (pg, z4, (sv_fma_f32_x (pg, z2, P (3), P (2))), + (sv_fma_f32_x (pg, z2, P (1), P (0)))); + sv_f32_t y = sv_fma_f32_x (pg, z8, p_4_7, p_0_3); + + /* Finalize. y = shift + z + z^3 * P(z^2). */ + sv_f32_t z3 = svmul_f32_x (pg, z2, az); + y = sv_fma_f32_x (pg, y, z3, az); + + /* Apply shift as indicated by 'red' predicate. */ + y = svadd_f32_m (red, y, shift); + + return y; +} + +#endif // PL_MATH_SV_ATANF_COMMON_H |