[PATCH] aarch64: Fix SVE tanf mixed-lane results [BZ #34922]
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Wed Nov 4 15:38:19 GMT 2026
On 04/11/26 12:06, Dylan Fleming wrote:
> The special-case path reciprocates every lane before calling scalar tanf
> for large inputs. This also changes ordinary lanes which do not need the
> reciprocal, so inputs [0.0f, 0x1p15f, ...] return infinity in the first
> lane instead of zero.
This requires a regression testcase, as we do for all other math function.
>
> Fixed by passing the alternate-lane predicate to special_case and selecting
> the reciprocal only where needed before handling the special lanes.
> ---
> SHARED-FILES | 2 +-
> sysdeps/aarch64/fpu/sve/tanf.c | 6 ++++--
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/SHARED-FILES b/SHARED-FILES
> index 8f89400177..2c6e4546dd 100644
> --- a/SHARED-FILES
> +++ b/SHARED-FILES
> @@ -573,7 +573,7 @@ arm-optimized-routines:
> sysdeps/aarch64/fpu/sve/sinpif.c
> # math/aarch64/sve/tan.c, revision 1aad38d
> sysdeps/aarch64/fpu/sve/tan.c
> - # math/aarch64/sve/tanf.c, revision 1aad38d
> + # math/aarch64/sve/tanf.c, revision 5e51e52
> sysdeps/aarch64/fpu/sve/tanf.c
> # math/aarch64/sve/tanh.c, revision 1aad38d
> sysdeps/aarch64/fpu/sve/tanh.c
> diff --git a/sysdeps/aarch64/fpu/sve/tanf.c b/sysdeps/aarch64/fpu/sve/tanf.c
> index 60d93fd7e2..4a627d31e0 100644
> --- a/sysdeps/aarch64/fpu/sve/tanf.c
> +++ b/sysdeps/aarch64/fpu/sve/tanf.c
> @@ -47,8 +47,10 @@ static const struct data
> };
>
> static svfloat32_t NOINLINE
> -special_case (svfloat32_t x, svfloat32_t y, svbool_t cmp)
> +special_case (svfloat32_t x, svfloat32_t y, svbool_t cmp, svbool_t pred_alt)
> {
> + svfloat32_t inv_y = svdivr_x (svptrue_b32 (), y, 1.0f);
> + y = svsel (pred_alt, inv_y, y);
> return sv_call_f32 (tanf, x, y, cmp);
> }
>
> @@ -107,7 +109,7 @@ svfloat32_t SV_NAME_F1 (tan) (svfloat32_t x, const svbool_t pg)
> /* Determine whether input is too large to perform fast regression. */
> svbool_t cmp = svacge (pg, x, d->range_val);
> if (__glibc_unlikely (svptest_any (pg, cmp)))
> - return special_case (x, svdivr_x (pg, y, 1.0f), cmp);
> + return special_case (x, y, cmp, pred_alt);
>
> svfloat32_t inv_y = svdivr_x (pg, y, 1.0f);
> return svsel (pred_alt, inv_y, y);
More information about the Libc-alpha
mailing list