[PATCH 2/2] AArch64: Use math-use-builtins for roundeven(f)/lrint(f)/lround(f)
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Fri Oct 17 16:26:20 GMT 2025
On 16/10/25 15:09, wilco.dijkstra@arm.com wrote:
> From: Wilco Dijkstra <wilco.dijkstra@arm.com>
>
> Remove target implementations of roundeven(f)/lrint(f)/lround(f) and
> use the math-use-builtins mechanism instead.
>
> Passes regress, OK for commit?
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> .../aarch64/fpu/math-use-builtins-llrint.h | 4 ++
> .../aarch64/fpu/math-use-builtins-llround.h | 4 ++
> sysdeps/aarch64/fpu/math-use-builtins-lrint.h | 4 ++
> .../aarch64/fpu/math-use-builtins-lround.h | 4 ++
> .../aarch64/fpu/math-use-builtins-roundeven.h | 4 ++
> sysdeps/aarch64/fpu/s_llrint.c | 35 ------------------
> sysdeps/aarch64/fpu/s_llrintf.c | 36 ------------------
> sysdeps/aarch64/fpu/s_llround.c | 28 --------------
> sysdeps/aarch64/fpu/s_llroundf.c | 28 --------------
> sysdeps/aarch64/fpu/s_lrint.c | 37 -------------------
> sysdeps/aarch64/fpu/s_lrintf.c | 35 ------------------
> sysdeps/aarch64/fpu/s_lround.c | 28 --------------
> sysdeps/aarch64/fpu/s_lroundf.c | 28 --------------
> sysdeps/aarch64/fpu/s_roundeven.c | 29 ---------------
> sysdeps/aarch64/fpu/s_roundevenf.c | 29 ---------------
> 15 files changed, 20 insertions(+), 313 deletions(-)
> create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-llrint.h
> create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-llround.h
> create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-lrint.h
> create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-lround.h
> create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-roundeven.h
> delete mode 100644 sysdeps/aarch64/fpu/s_llrint.c
> delete mode 100644 sysdeps/aarch64/fpu/s_llrintf.c
> delete mode 100644 sysdeps/aarch64/fpu/s_llround.c
> delete mode 100644 sysdeps/aarch64/fpu/s_llroundf.c
> delete mode 100644 sysdeps/aarch64/fpu/s_lrint.c
> delete mode 100644 sysdeps/aarch64/fpu/s_lrintf.c
> delete mode 100644 sysdeps/aarch64/fpu/s_lround.c
> delete mode 100644 sysdeps/aarch64/fpu/s_lroundf.c
> delete mode 100644 sysdeps/aarch64/fpu/s_roundeven.c
> delete mode 100644 sysdeps/aarch64/fpu/s_roundevenf.c
>
> diff --git a/sysdeps/aarch64/fpu/math-use-builtins-llrint.h b/sysdeps/aarch64/fpu/math-use-builtins-llrint.h
> new file mode 100644
> index 0000000000..32a6fb82b9
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins-llrint.h
> @@ -0,0 +1,4 @@
> +#define USE_LLRINT_BUILTIN 1
> +#define USE_LLRINTF_BUILTIN 1
> +#define USE_LLRINTL_BUILTIN 0
> +#define USE_LLRINTF128_BUILTIN 0
> diff --git a/sysdeps/aarch64/fpu/math-use-builtins-llround.h b/sysdeps/aarch64/fpu/math-use-builtins-llround.h
> new file mode 100644
> index 0000000000..d4623a0dc4
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins-llround.h
> @@ -0,0 +1,4 @@
> +#define USE_LLROUND_BUILTIN 1
> +#define USE_LLROUNDF_BUILTIN 1
> +#define USE_LLROUNDL_BUILTIN 0
> +#define USE_LLROUNDF128_BUILTIN 0
> diff --git a/sysdeps/aarch64/fpu/math-use-builtins-lrint.h b/sysdeps/aarch64/fpu/math-use-builtins-lrint.h
> new file mode 100644
> index 0000000000..d8a8d6c540
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins-lrint.h
> @@ -0,0 +1,4 @@
> +#define USE_LRINT_BUILTIN 1
> +#define USE_LRINTF_BUILTIN 1
> +#define USE_LRINTL_BUILTIN 0
> +#define USE_LRINTF128_BUILTIN 0
> diff --git a/sysdeps/aarch64/fpu/math-use-builtins-lround.h b/sysdeps/aarch64/fpu/math-use-builtins-lround.h
> new file mode 100644
> index 0000000000..eaeb601ea0
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins-lround.h
> @@ -0,0 +1,4 @@
> +#define USE_LROUND_BUILTIN 1
> +#define USE_LROUNDF_BUILTIN 1
> +#define USE_LROUNDL_BUILTIN 0
> +#define USE_LROUNDF128_BUILTIN 0
> diff --git a/sysdeps/aarch64/fpu/math-use-builtins-roundeven.h b/sysdeps/aarch64/fpu/math-use-builtins-roundeven.h
> new file mode 100644
> index 0000000000..b7f51730d6
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins-roundeven.h
> @@ -0,0 +1,4 @@
> +#define USE_ROUNDEVEN_BUILTIN 1
> +#define USE_ROUNDEVENF_BUILTIN 1
> +#define USE_ROUNDEVENL_BUILTIN 0
> +#define USE_ROUNDEVENF128_BUILTIN 0
> diff --git a/sysdeps/aarch64/fpu/s_llrint.c b/sysdeps/aarch64/fpu/s_llrint.c
> deleted file mode 100644
> index 3ed519ca2b..0000000000
> --- a/sysdeps/aarch64/fpu/s_llrint.c
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -/* Copyright (C) 2011-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <math-barriers.h>
> -#include <libm-alias-double.h>
> -
> -long long int
> -__llrint (double x)
> -{
> - double r = __builtin_rint (x);
> -
> - /* Prevent gcc from calling llrint directly when compiled with
> - -fno-math-errno by inserting a barrier. */
> -
> - math_opt_barrier (r);
> - return r;
> -}
> -
> -libm_alias_double (__llrint, llrint)
> diff --git a/sysdeps/aarch64/fpu/s_llrintf.c b/sysdeps/aarch64/fpu/s_llrintf.c
> deleted file mode 100644
> index 0f339582b2..0000000000
> --- a/sysdeps/aarch64/fpu/s_llrintf.c
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -/* Copyright (C) 2011-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <math-barriers.h>
> -#include <libm-alias-float.h>
> -
> -long long int
> -__llrintf (float x)
> -{
> - float r = __builtin_rintf (x);
> -
> - /* Prevent gcc from calling llrintf directly when compiled with
> - -fno-math-errno by inserting a barrier. */
> -
> -
> - math_opt_barrier (r);
> - return r;
> -}
> -
> -libm_alias_float (__llrint, llrint)
> diff --git a/sysdeps/aarch64/fpu/s_llround.c b/sysdeps/aarch64/fpu/s_llround.c
> deleted file mode 100644
> index a1b46e8c9e..0000000000
> --- a/sysdeps/aarch64/fpu/s_llround.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (C) 2011-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <libm-alias-double.h>
> -
> -long long int
> -__llround (double x)
> -{
> - return __builtin_llround (x);
> -}
> -
> -libm_alias_double (__llround, llround)
> diff --git a/sysdeps/aarch64/fpu/s_llroundf.c b/sysdeps/aarch64/fpu/s_llroundf.c
> deleted file mode 100644
> index 5269f4447e..0000000000
> --- a/sysdeps/aarch64/fpu/s_llroundf.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (C) 2011-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <libm-alias-float.h>
> -
> -long long int
> -__llroundf (float x)
> -{
> - return __builtin_llroundf (x);
> -}
> -
> -libm_alias_float (__llround, llround)
> diff --git a/sysdeps/aarch64/fpu/s_lrint.c b/sysdeps/aarch64/fpu/s_lrint.c
> deleted file mode 100644
> index 66b3cca399..0000000000
> --- a/sysdeps/aarch64/fpu/s_lrint.c
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -/* Copyright (C) 1996-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <get-rounding-mode.h>
> -#include <stdint.h>
> -#include <math-barriers.h>
> -#include <libm-alias-double.h>
> -
> -long int
> -__lrint (double x)
> -{
> - double r = __builtin_rint (x);
> -
> - /* Prevent gcc from calling lrint directly when compiled with
> - -fno-math-errno by inserting a barrier. */
> -
> - math_opt_barrier (r);
> - return r;
> -}
> -
> -libm_alias_double (__lrint, lrint)
> diff --git a/sysdeps/aarch64/fpu/s_lrintf.c b/sysdeps/aarch64/fpu/s_lrintf.c
> deleted file mode 100644
> index cc9d44c48c..0000000000
> --- a/sysdeps/aarch64/fpu/s_lrintf.c
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -/* Copyright (C) 2011-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <math-barriers.h>
> -#include <libm-alias-float.h>
> -
> -long int
> -__lrintf (float x)
> -{
> - float r = __builtin_rintf (x);
> -
> - /* Prevent gcc from calling lrintf directly when compiled with
> - -fno-math-errno by inserting a barrier. */
> -
> - math_opt_barrier (r);
> - return r;
> -}
> -
> -libm_alias_float (__lrint, lrint)
> diff --git a/sysdeps/aarch64/fpu/s_lround.c b/sysdeps/aarch64/fpu/s_lround.c
> deleted file mode 100644
> index ab5c7cefab..0000000000
> --- a/sysdeps/aarch64/fpu/s_lround.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (C) 1996-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <libm-alias-double.h>
> -
> -long int
> -__lround (double x)
> - {
> - return __builtin_lround (x);
> - }
> -
> -libm_alias_double (__lround, lround)
> diff --git a/sysdeps/aarch64/fpu/s_lroundf.c b/sysdeps/aarch64/fpu/s_lroundf.c
> deleted file mode 100644
> index 236f1a8a54..0000000000
> --- a/sysdeps/aarch64/fpu/s_lroundf.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (C) 2011-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <math.h>
> -#include <libm-alias-float.h>
> -
> -long int
> -__lroundf (float x)
> -{
> - return __builtin_lroundf (x);
> -}
> -
> -libm_alias_float (__lround, lround)
> diff --git a/sysdeps/aarch64/fpu/s_roundeven.c b/sysdeps/aarch64/fpu/s_roundeven.c
> deleted file mode 100644
> index de9ee566f6..0000000000
> --- a/sysdeps/aarch64/fpu/s_roundeven.c
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* Copyright (C) 2021-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#define NO_MATH_REDIRECT
> -#include <math.h>
> -#include <libm-alias-double.h>
> -
> -double
> -__roundeven (double x)
> -{
> - asm volatile ("frintn \t%d0, %d1" : "=w" (x) : "w" (x));
> - return x;
> -}
> -libm_alias_double (__roundeven, roundeven)
> diff --git a/sysdeps/aarch64/fpu/s_roundevenf.c b/sysdeps/aarch64/fpu/s_roundevenf.c
> deleted file mode 100644
> index 63b8aa717f..0000000000
> --- a/sysdeps/aarch64/fpu/s_roundevenf.c
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* Copyright (C) 2021-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
> - <https://www.gnu.org/licenses/>. */
> -
> -#define NO_MATH_REDIRECT
> -#include <math.h>
> -#include <libm-alias-float.h>
> -
> -float
> -__roundevenf (float x)
> -{
> - asm volatile ("frintn \t%s0, %s1" : "=w" (x) : "w" (x));
> - return x;
> -}
> -libm_alias_float (__roundeven, roundeven)
More information about the Libc-alpha
mailing list