From: Adhemerval Zanella Date: Wed, 8 Oct 2025 13:55:02 +0000 (-0300) Subject: i386: Remove the SVID error handling from fmodf X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1dd2163e51c84ec78b3f6425d3266808a5570de4;p=thirdparty%2Fglibc.git i386: Remove the SVID error handling from fmodf The optimized i386 version is faster than the generic one, and gcc implements it through the builtin. It allows us to move the implementation to a C one. The performance on a Zen3 chip is slight better: reciprocal-throughput input master no-SVID improvement i686 subnormals 22.4741 20.1571 10.31% i686 normal 74.1631 70.3606 5.13% i686 close-exponent 22.5625 20.2435 10.28% Tested on i686-linux-gnu. Reviewed-by: Wilco Dijkstra --- diff --git a/sysdeps/i386/fpu/Versions b/sysdeps/i386/fpu/Versions index 940384a21f4..8668b42dd6a 100644 --- a/sysdeps/i386/fpu/Versions +++ b/sysdeps/i386/fpu/Versions @@ -5,6 +5,6 @@ libm { } GLIBC_2.43 { # No SVID compatible error handling. - fmod; + fmod; fmodf; } } diff --git a/sysdeps/i386/fpu/e_fmodf.S b/sysdeps/i386/fpu/e_fmodf.S deleted file mode 100644 index f73ce9da1ef..00000000000 --- a/sysdeps/i386/fpu/e_fmodf.S +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -ENTRY(__ieee754_fmodf) - flds 8(%esp) - flds 4(%esp) -1: fprem - fstsw %ax - sahf - jp 1b - fstp %st(1) - ret -END(__ieee754_fmodf) -libm_alias_finite (__ieee754_fmodf, __fmodf) diff --git a/sysdeps/i386/fpu/e_fmodf.c b/sysdeps/i386/fpu/e_fmodf.c new file mode 100644 index 00000000000..5b05d0fd958 --- /dev/null +++ b/sysdeps/i386/fpu/e_fmodf.c @@ -0,0 +1,41 @@ +/* Floating-point remainder function. + Copyright (C) 2023-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include "sysdeps/ieee754/flt-32/math_config.h" + +float +__fmodf (float x, float y) +{ + uint32_t hx = asuint (x); + uint32_t hy = asuint (y); + + /* fmod(+-Inf,y) or fmod(x,0) */ + if (__glibc_unlikely ((is_inf (hx) || y == 0.0f) + && !is_nan (hy) + && !is_nan (hx))) + return __math_invalidf (x); + + return __builtin_fmodf (x, y); +} +strong_alias (__fmodf, __ieee754_fmodf) +versioned_symbol (libm, __fmodf, fmodf, GLIBC_2_43); +libm_alias_float_other (__fmod, fmod) +libm_alias_finite (__ieee754_fmodf, __fmodf) diff --git a/sysdeps/i386/fpu/e_fmodf_ver.h b/sysdeps/i386/fpu/e_fmodf_ver.h new file mode 100644 index 00000000000..384d7917d24 --- /dev/null +++ b/sysdeps/i386/fpu/e_fmodf_ver.h @@ -0,0 +1,2 @@ +/* i386 remove SVID wrapper on 2.43 */ +#define FMODF_NOSVID_VER GLIBC_2_43 diff --git a/sysdeps/i386/fpu/w_fmodf_compat.c b/sysdeps/i386/fpu/w_fmodf_compat.c deleted file mode 100644 index 5a61693e51f..00000000000 --- a/sysdeps/i386/fpu/w_fmodf_compat.c +++ /dev/null @@ -1,15 +0,0 @@ -/* i386 provides an optimized __ieee752_fmodf. */ -#include -#ifdef SHARED -# undef SHLIB_COMPAT -# define SHLIB_COMPAT(a, b, c) 1 -# undef LIBM_SVID_COMPAT -# define LIBM_SVID_COMPAT 1 -# undef compat_symbol -# define compat_symbol(a, b, c, d) -# include -libm_alias_float (__fmod_compat, fmod) -#else -#include -#include -#endif diff --git a/sysdeps/mach/hurd/i386/libm.abilist b/sysdeps/mach/hurd/i386/libm.abilist index 6c8e2b6d9cb..3bf087812ca 100644 --- a/sysdeps/mach/hurd/i386/libm.abilist +++ b/sysdeps/mach/hurd/i386/libm.abilist @@ -1318,3 +1318,4 @@ GLIBC_2.42 rsqrtf64 F GLIBC_2.42 rsqrtf64x F GLIBC_2.42 rsqrtl F GLIBC_2.43 fmod F +GLIBC_2.43 fmodf F diff --git a/sysdeps/unix/sysv/linux/i386/libm.abilist b/sysdeps/unix/sysv/linux/i386/libm.abilist index 5f545098126..38e31ed1a76 100644 --- a/sysdeps/unix/sysv/linux/i386/libm.abilist +++ b/sysdeps/unix/sysv/linux/i386/libm.abilist @@ -1325,3 +1325,4 @@ GLIBC_2.42 rsqrtf64 F GLIBC_2.42 rsqrtf64x F GLIBC_2.42 rsqrtl F GLIBC_2.43 fmod F +GLIBC_2.43 fmodf F