aarch64: Fix SVE log1p helper mixed-lane shortcut [BZ #34923]

Message ID 20261104150637.23767-1-Dylan.Fleming@arm.com (mailing list archive)
State Committed
Commit abdae8c703d5c0be3087183611b3ca007433e56f
Headers
Series aarch64: Fix SVE log1p helper mixed-lane shortcut [BZ #34923] |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Dylan Fleming Nov. 4, 2026, 3:06 p.m. UTC
  The log1p helper only selects the original input for k == 0 when all
active lanes have k == 0. If another lane needs exponent reduction, the
shortcut is skipped even though the correction term is already zeroed
for k == 0. This loses accuracy in SVE acosh near 1, for example with
inputs [0x1.0000000000001p0, 2.0, ...].

Select the original input for k == 0 independently in each lane by
removing the vector-wide condition around svsel.
---
 SHARED-FILES                              | 2 +-
 sysdeps/aarch64/fpu/sve/sv_log1p_inline.h | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)
  

Comments

Adhemerval Zanella Netto Nov. 6, 2026, 2:55 p.m. UTC | #1
On 04/11/26 12:06, Dylan Fleming wrote:
> The log1p helper only selects the original input for k == 0 when all
> active lanes have k == 0. If another lane needs exponent reduction, the
> shortcut is skipped even though the correction term is already zeroed
> for k == 0. This loses accuracy in SVE acosh near 1, for example with
> inputs [0x1.0000000000001p0, 2.0, ...].
> 
> Select the original input for k == 0 independently in each lane by
> removing the vector-wide condition around svsel.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  SHARED-FILES                              | 2 +-
>  sysdeps/aarch64/fpu/sve/sv_log1p_inline.h | 5 +----
>  2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/SHARED-FILES b/SHARED-FILES
> index 8f89400177..1f176aa6f8 100644
> --- a/SHARED-FILES
> +++ b/SHARED-FILES
> @@ -591,7 +591,7 @@ arm-optimized-routines:
>    sysdeps/aarch64/fpu/sve/sv_expf_special_inline.h
>    # math/aarch64/sve/sv_expm1f_inline.h, revision 78cd003
>    sysdeps/aarch64/fpu/sve/sv_expm1f_inline.h
> -  # math/aarch64/sve/sv_log1p_inline.h, revision 7d08237
> +  # math/aarch64/sve/sv_log1p_inline.h, revision 5e51e52
>    sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
>    # math/aarch64/sve/sv_log1pf_inline.h, revision a553540
>    sysdeps/aarch64/fpu/sve/sv_log1pf_inline.h
> diff --git a/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h b/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
> index 1b2c542851..2e17280cf6 100644
> --- a/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
> +++ b/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
> @@ -102,10 +102,7 @@ sv_log1p_inline (svfloat64_t x, const svbool_t pg)
>       that the approximation is solely the polynomial.  */
>    svbool_t knot0 = svcmpne (pg, k, 0);
>    cm = svdiv_z (knot0, c, m);
> -  if (__glibc_likely (!svptest_any (pg, knot0)))
> -    {
> -      f = svsel (knot0, f, x);
> -    }
> +  f = svsel (knot0, f, x);
>  #else
>    /* No shortcut.  */
>    cm = svdiv_x (pg, c, m);
  

Patch

diff --git a/SHARED-FILES b/SHARED-FILES
index 8f89400177..1f176aa6f8 100644
--- a/SHARED-FILES
+++ b/SHARED-FILES
@@ -591,7 +591,7 @@  arm-optimized-routines:
   sysdeps/aarch64/fpu/sve/sv_expf_special_inline.h
   # math/aarch64/sve/sv_expm1f_inline.h, revision 78cd003
   sysdeps/aarch64/fpu/sve/sv_expm1f_inline.h
-  # math/aarch64/sve/sv_log1p_inline.h, revision 7d08237
+  # math/aarch64/sve/sv_log1p_inline.h, revision 5e51e52
   sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
   # math/aarch64/sve/sv_log1pf_inline.h, revision a553540
   sysdeps/aarch64/fpu/sve/sv_log1pf_inline.h
diff --git a/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h b/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
index 1b2c542851..2e17280cf6 100644
--- a/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
+++ b/sysdeps/aarch64/fpu/sve/sv_log1p_inline.h
@@ -102,10 +102,7 @@  sv_log1p_inline (svfloat64_t x, const svbool_t pg)
      that the approximation is solely the polynomial.  */
   svbool_t knot0 = svcmpne (pg, k, 0);
   cm = svdiv_z (knot0, c, m);
-  if (__glibc_likely (!svptest_any (pg, knot0)))
-    {
-      f = svsel (knot0, f, x);
-    }
+  f = svsel (knot0, f, x);
 #else
   /* No shortcut.  */
   cm = svdiv_x (pg, c, m);