AArch64: Use math-use-builtins for roundeven(f)/lrint(f)/lround(f)

Remove target implementations of roundeven(f)/lrint(f)/lround(f) and
use the math-use-builtins mechanism instead.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Wilco Dijkstra 2025-10-15 16:38:03 +00:00
parent 35807cc5cd
commit 0375e6e233
15 changed files with 20 additions and 313 deletions

View File

@ -0,0 +1,4 @@
#define USE_LLRINT_BUILTIN 1
#define USE_LLRINTF_BUILTIN 1
#define USE_LLRINTL_BUILTIN 0
#define USE_LLRINTF128_BUILTIN 0

View File

@ -0,0 +1,4 @@
#define USE_LLROUND_BUILTIN 1
#define USE_LLROUNDF_BUILTIN 1
#define USE_LLROUNDL_BUILTIN 0
#define USE_LLROUNDF128_BUILTIN 0

View File

@ -0,0 +1,4 @@
#define USE_LRINT_BUILTIN 1
#define USE_LRINTF_BUILTIN 1
#define USE_LRINTL_BUILTIN 0
#define USE_LRINTF128_BUILTIN 0

View File

@ -0,0 +1,4 @@
#define USE_LROUND_BUILTIN 1
#define USE_LROUNDF_BUILTIN 1
#define USE_LROUNDL_BUILTIN 0
#define USE_LROUNDF128_BUILTIN 0

View File

@ -0,0 +1,4 @@
#define USE_ROUNDEVEN_BUILTIN 1
#define USE_ROUNDEVENF_BUILTIN 1
#define USE_ROUNDEVENL_BUILTIN 0
#define USE_ROUNDEVENF128_BUILTIN 0

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)