diff mbox series

[4/5] aarch/fpu: use generic sqrt, fma functions

Message ID 20200530020047.5490-5-vgupta@synopsys.com
State New
Headers show
Series use gcc builtins for sqrt and fma functions | expand

Commit Message

Vineet Gupta May 30, 2020, 2 a.m. UTC
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 sysdeps/aarch64/fpu/e_sqrt.c            | 27 ----------
 sysdeps/aarch64/fpu/e_sqrtf.c           | 27 ----------
 sysdeps/aarch64/fpu/math-use-builtins.h | 70 +++++++++++++++++++++++++
 sysdeps/aarch64/fpu/s_fma.c             | 28 ----------
 sysdeps/aarch64/fpu/s_fmaf.c            | 28 ----------
 5 files changed, 70 insertions(+), 110 deletions(-)
 delete mode 100644 sysdeps/aarch64/fpu/e_sqrt.c
 delete mode 100644 sysdeps/aarch64/fpu/e_sqrtf.c
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
 delete mode 100644 sysdeps/aarch64/fpu/s_fma.c
 delete mode 100644 sysdeps/aarch64/fpu/s_fmaf.c

Comments

Adhemerval Zanella June 1, 2020, 4:38 p.m. UTC | #1
On 29/05/2020 23:00, Vineet Gupta wrote:
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

LGTM, some comments below.

> ---
>  sysdeps/aarch64/fpu/e_sqrt.c            | 27 ----------
>  sysdeps/aarch64/fpu/e_sqrtf.c           | 27 ----------
>  sysdeps/aarch64/fpu/math-use-builtins.h | 70 +++++++++++++++++++++++++
>  sysdeps/aarch64/fpu/s_fma.c             | 28 ----------
>  sysdeps/aarch64/fpu/s_fmaf.c            | 28 ----------
>  5 files changed, 70 insertions(+), 110 deletions(-)
>  delete mode 100644 sysdeps/aarch64/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/aarch64/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
>  delete mode 100644 sysdeps/aarch64/fpu/s_fma.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_fmaf.c
> 
> diff --git a/sysdeps/aarch64/fpu/e_sqrt.c b/sysdeps/aarch64/fpu/e_sqrt.c
> deleted file mode 100644
> index abb67ef7b061..000000000000
> --- a/sysdeps/aarch64/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Square root of floating point number.
> -   Copyright (C) 2015-2020 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_private.h>
> -#include <libm-alias-finite.h>
> -
> -double
> -__ieee754_sqrt (double d)
> -{
> -  return __builtin_sqrt (d);
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)

Ok.

> diff --git a/sysdeps/aarch64/fpu/e_sqrtf.c b/sysdeps/aarch64/fpu/e_sqrtf.c
> deleted file mode 100644
> index 13008a4f45d6..000000000000
> --- a/sysdeps/aarch64/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Single-precision floating point square root.
> -   Copyright (C) 2015-2020 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_private.h>
> -#include <libm-alias-finite.h>
> -
> -float
> -__ieee754_sqrtf (float s)
> -{
> -  return __builtin_sqrtf (s);
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)

Ok.

> diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h b/sysdeps/aarch64/fpu/math-use-builtins.h
> new file mode 100644
> index 000000000000..52f0a0dad6dd
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins.h
> @@ -0,0 +1,70 @@
> +/* Using math gcc builtins instead of generic implementation.  aarch64 version.
> +   Copyright (C) 2019-2020 Free Software Foundation, Inc.

I think it should be just 2020 here.

> +   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/>.  */
> +
> +#ifndef MATH_USE_BUILTINS_H
> +#define MATH_USE_BUILTINS_H	1
> +
> +#include <features.h> /* For __GNUC_PREREQ.  */
> +
> +/* Define these macros to 1 to use __builtin_xyz instead of the
> +   generic implementation.  */
> +#define USE_NEARBYINT_BUILTIN 0
> +#define USE_NEARBYINTF_BUILTIN 0
> +#define USE_NEARBYINTL_BUILTIN 0
> +#define USE_NEARBYINTF128_BUILTIN 0

Since we are adding this new file for aarch64, we could also enable it fo
nearbyint{f} and remove sysdeps/aarch64/fpu/s_nearbyint{f}.c as well.

> +
> +#define USE_RINT_BUILTIN 0
> +#define USE_RINTF_BUILTIN 0
> +#define USE_RINTL_BUILTIN 0
> +#define USE_RINTF128_BUILTIN 0

Ditto.

> +
> +#define USE_FLOOR_BUILTIN 0
> +#define USE_FLOORF_BUILTIN 0
> +#define USE_FLOORL_BUILTIN 0
> +#define USE_FLOORF128_BUILTIN 0

Ditto.

> +
> +#define USE_CEIL_BUILTIN 0
> +#define USE_CEILF_BUILTIN 0
> +#define USE_CEILL_BUILTIN 0
> +#define USE_CEILF128_BUILTIN 0

Ditto.

> +
> +#define USE_TRUNC_BUILTIN 0
> +#define USE_TRUNCF_BUILTIN 0
> +#define USE_TRUNCL_BUILTIN 0
> +#define USE_TRUNCF128_BUILTIN 0

Ditto.

> +
> +#define USE_ROUND_BUILTIN 0
> +#define USE_ROUNDF_BUILTIN 0
> +#define USE_ROUNDL_BUILTIN 0
> +#define USE_ROUNDF128_BUILTIN 0

Ditto.

> +
> +#define USE_COPYSIGNL_BUILTIN 1
> +#if __GNUC_PREREQ (7, 0)
> +# define USE_COPYSIGNF128_BUILTIN 1
> +#else
> +# define USE_COPYSIGNF128_BUILTIN 0
> +#endif
> +

It should be described in commit message as well (although generated
instruction are essentially the same).

> +#define USE_SQRT_BUILTIN 1
> +#define USE_SQRTF_BUILTIN 1
> +
> +#define USE_FMA_BUILTIN 1
> +#define USE_FMAF_BUILTIN 1
> +#define USE_FMAL_BUILTIN 0
> +
> +#endif /* math-use-builtins.h */

Ok.

> diff --git a/sysdeps/aarch64/fpu/s_fma.c b/sysdeps/aarch64/fpu/s_fma.c
> deleted file mode 100644
> index 48bb40482dc9..000000000000
> --- a/sysdeps/aarch64/fpu/s_fma.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (C) 1996-2020 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>
> -
> -double
> -__fma (double x, double y, double z)
> -{
> -  return __builtin_fma (x, y, z);
> -}
> -
> -libm_alias_double (__fma, fma)

Ok.

> diff --git a/sysdeps/aarch64/fpu/s_fmaf.c b/sysdeps/aarch64/fpu/s_fmaf.c
> deleted file mode 100644
> index 544f32e27aec..000000000000
> --- a/sysdeps/aarch64/fpu/s_fmaf.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (C) 2011-2020 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>
> -
> -float
> -__fmaf (float x, float y, float z)
> -{
> -  return __builtin_fmaf (x, y, z);
> -}
> -
> -libm_alias_float (__fma, fma)
> 

Ok.
Vineet Gupta June 1, 2020, 9:44 p.m. UTC | #2
On 6/1/20 9:38 AM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 29/05/2020 23:00, Vineet Gupta wrote:
>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> 
> LGTM, some comments below.
> 
>> -#include <math_private.h>
>> -#include <libm-alias-finite.h>
>> -
>> -double
>> -__ieee754_sqrt (double d)
>> -{
>> -  return __builtin_sqrt (d);
>> -}
>> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> 
> Ok.

How is one to test aarch64 port with hard-float. build-many-glibc doesn't have a
hf variant and hacking one didn't do the right thing either.

>> diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h b/sysdeps/aarch64/fpu/math-use-builtins.h
>> new file mode 100644
>> index 000000000000..52f0a0dad6dd
>> --- /dev/null
>> +++ b/sysdeps/aarch64/fpu/math-use-builtins.h
>> @@ -0,0 +1,70 @@
>> +/* Using math gcc builtins instead of generic implementation.  aarch64 version.
>> +   Copyright (C) 2019-2020 Free Software Foundation, Inc.
> 
> I think it should be just 2020 here.

Fixed.

>> +
>> +/* Define these macros to 1 to use __builtin_xyz instead of the
>> +   generic implementation.  */
>> +#define USE_NEARBYINT_BUILTIN 0
>> +#define USE_NEARBYINTF_BUILTIN 0
>> +#define USE_NEARBYINTL_BUILTIN 0
>> +#define USE_NEARBYINTF128_BUILTIN 0
> 
> Since we are adding this new file for aarch64, we could also enable it fo
> nearbyint{f} and remove sysdeps/aarch64/fpu/s_nearbyint{f}.c as well.

OK, but only

+#define USE_NEARBYINT_BUILTIN 1
+#define USE_NEARBYINTF_BUILTIN 1

The other 2 are not defined currently. If they are, then I prefer they be enabled
as a separate commit for bisectability.


>> +#define USE_RINT_BUILTIN 0
>> +#define USE_RINTF_BUILTIN 0
>> +#define USE_RINTL_BUILTIN 0
>> +#define USE_RINTF128_BUILTIN 0
> 
> Ditto.

OK and again only RINT and RINTF.
Also I don't understand one thing. Both the generic and aarch64 code have this

float
__rintf (float x)
...
libm_alias_float (__rint, rint)

The alias arg 1 __rint seems to lack suffix 'f' ?


>> +
>> +#define USE_FLOOR_BUILTIN 0
>> +#define USE_FLOORF_BUILTIN 0

Again FLOOR, FLOORF only

>> +#define USE_FLOORL_BUILTIN 0
>> +#define USE_FLOORF128_BUILTIN 0
> 
> Ditto.

Ditto


>> +
>> +#define USE_CEIL_BUILTIN 0
>> +#define USE_CEILF_BUILTIN 0
>> +#define USE_CEILL_BUILTIN 0
>> +#define USE_CEILF128_BUILTIN 0
> 
> Ditto.

Ditto

> 
>> +
>> +#define USE_TRUNC_BUILTIN 0
>> +#define USE_TRUNCF_BUILTIN 0
>> +#define USE_TRUNCL_BUILTIN 0
>> +#define USE_TRUNCF128_BUILTIN 0
> 
> Ditto.

Ditto

>> +
>> +#define USE_ROUND_BUILTIN 0
>> +#define USE_ROUNDF_BUILTIN 0
>> +#define USE_ROUNDL_BUILTIN 0
>> +#define USE_ROUNDF128_BUILTIN 0
> 
> Ditto.

Ditto

>> +
>> +#define USE_COPYSIGNL_BUILTIN 1
>> +#if __GNUC_PREREQ (7, 0)
>> +# define USE_COPYSIGNF128_BUILTIN 1
>> +#else
>> +# define USE_COPYSIGNF128_BUILTIN 0
>> +#endif
>> +
> 
> It should be described in commit message as well (although generated
> instruction are essentially the same).

Well this one is even more special as it was already using the same code, except
that the math-use-builtins.h was generic vs. aarch64 specific one.

Thx
-Vineet
Ramana Radhakrishnan June 1, 2020, 10:08 p.m. UTC | #3
On Mon, Jun 1, 2020 at 10:45 PM Vineet Gupta via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On 6/1/20 9:38 AM, Adhemerval Zanella via Libc-alpha wrote:
> >
> >
> > On 29/05/2020 23:00, Vineet Gupta wrote:
> >> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> >
> > LGTM, some comments below.
> >
> >> -#include <math_private.h>
> >> -#include <libm-alias-finite.h>
> >> -
> >> -double
> >> -__ieee754_sqrt (double d)
> >> -{
> >> -  return __builtin_sqrt (d);
> >> -}
> >> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> >
> > Ok.
>
> How is one to test aarch64 port with hard-float. build-many-glibc doesn't have a
> hf variant and hacking one didn't do the right thing either.

AArch64 is hard-float by default : there is no soft-float variant.

regards
Ramana

>
> >> diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h b/sysdeps/aarch64/fpu/math-use-builtins.h
> >> new file mode 100644
> >> index 000000000000..52f0a0dad6dd
> >> --- /dev/null
> >> +++ b/sysdeps/aarch64/fpu/math-use-builtins.h
> >> @@ -0,0 +1,70 @@
> >> +/* Using math gcc builtins instead of generic implementation.  aarch64 version.
> >> +   Copyright (C) 2019-2020 Free Software Foundation, Inc.
> >
> > I think it should be just 2020 here.
>
> Fixed.
>
> >> +
> >> +/* Define these macros to 1 to use __builtin_xyz instead of the
> >> +   generic implementation.  */
> >> +#define USE_NEARBYINT_BUILTIN 0
> >> +#define USE_NEARBYINTF_BUILTIN 0
> >> +#define USE_NEARBYINTL_BUILTIN 0
> >> +#define USE_NEARBYINTF128_BUILTIN 0
> >
> > Since we are adding this new file for aarch64, we could also enable it fo
> > nearbyint{f} and remove sysdeps/aarch64/fpu/s_nearbyint{f}.c as well.
>
> OK, but only
>
> +#define USE_NEARBYINT_BUILTIN 1
> +#define USE_NEARBYINTF_BUILTIN 1
>
> The other 2 are not defined currently. If they are, then I prefer they be enabled
> as a separate commit for bisectability.
>
>
> >> +#define USE_RINT_BUILTIN 0
> >> +#define USE_RINTF_BUILTIN 0
> >> +#define USE_RINTL_BUILTIN 0
> >> +#define USE_RINTF128_BUILTIN 0
> >
> > Ditto.
>
> OK and again only RINT and RINTF.
> Also I don't understand one thing. Both the generic and aarch64 code have this
>
> float
> __rintf (float x)
> ...
> libm_alias_float (__rint, rint)
>
> The alias arg 1 __rint seems to lack suffix 'f' ?
>
>
> >> +
> >> +#define USE_FLOOR_BUILTIN 0
> >> +#define USE_FLOORF_BUILTIN 0
>
> Again FLOOR, FLOORF only
>
> >> +#define USE_FLOORL_BUILTIN 0
> >> +#define USE_FLOORF128_BUILTIN 0
> >
> > Ditto.
>
> Ditto
>
>
> >> +
> >> +#define USE_CEIL_BUILTIN 0
> >> +#define USE_CEILF_BUILTIN 0
> >> +#define USE_CEILL_BUILTIN 0
> >> +#define USE_CEILF128_BUILTIN 0
> >
> > Ditto.
>
> Ditto
>
> >
> >> +
> >> +#define USE_TRUNC_BUILTIN 0
> >> +#define USE_TRUNCF_BUILTIN 0
> >> +#define USE_TRUNCL_BUILTIN 0
> >> +#define USE_TRUNCF128_BUILTIN 0
> >
> > Ditto.
>
> Ditto
>
> >> +
> >> +#define USE_ROUND_BUILTIN 0
> >> +#define USE_ROUNDF_BUILTIN 0
> >> +#define USE_ROUNDL_BUILTIN 0
> >> +#define USE_ROUNDF128_BUILTIN 0
> >
> > Ditto.
>
> Ditto
>
> >> +
> >> +#define USE_COPYSIGNL_BUILTIN 1
> >> +#if __GNUC_PREREQ (7, 0)
> >> +# define USE_COPYSIGNF128_BUILTIN 1
> >> +#else
> >> +# define USE_COPYSIGNF128_BUILTIN 0
> >> +#endif
> >> +
> >
> > It should be described in commit message as well (although generated
> > instruction are essentially the same).
>
> Well this one is even more special as it was already using the same code, except
> that the math-use-builtins.h was generic vs. aarch64 specific one.
>
> Thx
> -Vineet
Joseph Myers June 2, 2020, 6:12 p.m. UTC | #4
On Mon, 1 Jun 2020, Vineet Gupta via Libc-alpha wrote:

> Also I don't understand one thing. Both the generic and aarch64 code have this
> 
> float
> __rintf (float x)
> ...
> libm_alias_float (__rint, rint)
> 
> The alias arg 1 __rint seems to lack suffix 'f' ?

Please see the comments in sysdeps/generic/libm-alias-float.h.  The 
arguments are *unsuffixed* names.
diff mbox series

Patch

diff --git a/sysdeps/aarch64/fpu/e_sqrt.c b/sysdeps/aarch64/fpu/e_sqrt.c
deleted file mode 100644
index abb67ef7b061..000000000000
--- a/sysdeps/aarch64/fpu/e_sqrt.c
+++ /dev/null
@@ -1,27 +0,0 @@ 
-/* Square root of floating point number.
-   Copyright (C) 2015-2020 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_private.h>
-#include <libm-alias-finite.h>
-
-double
-__ieee754_sqrt (double d)
-{
-  return __builtin_sqrt (d);
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/aarch64/fpu/e_sqrtf.c b/sysdeps/aarch64/fpu/e_sqrtf.c
deleted file mode 100644
index 13008a4f45d6..000000000000
--- a/sysdeps/aarch64/fpu/e_sqrtf.c
+++ /dev/null
@@ -1,27 +0,0 @@ 
-/* Single-precision floating point square root.
-   Copyright (C) 2015-2020 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_private.h>
-#include <libm-alias-finite.h>
-
-float
-__ieee754_sqrtf (float s)
-{
-  return __builtin_sqrtf (s);
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h b/sysdeps/aarch64/fpu/math-use-builtins.h
new file mode 100644
index 000000000000..52f0a0dad6dd
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins.h
@@ -0,0 +1,70 @@ 
+/* Using math gcc builtins instead of generic implementation.  aarch64 version.
+   Copyright (C) 2019-2020 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/>.  */
+
+#ifndef MATH_USE_BUILTINS_H
+#define MATH_USE_BUILTINS_H	1
+
+#include <features.h> /* For __GNUC_PREREQ.  */
+
+/* Define these macros to 1 to use __builtin_xyz instead of the
+   generic implementation.  */
+#define USE_NEARBYINT_BUILTIN 0
+#define USE_NEARBYINTF_BUILTIN 0
+#define USE_NEARBYINTL_BUILTIN 0
+#define USE_NEARBYINTF128_BUILTIN 0
+
+#define USE_RINT_BUILTIN 0
+#define USE_RINTF_BUILTIN 0
+#define USE_RINTL_BUILTIN 0
+#define USE_RINTF128_BUILTIN 0
+
+#define USE_FLOOR_BUILTIN 0
+#define USE_FLOORF_BUILTIN 0
+#define USE_FLOORL_BUILTIN 0
+#define USE_FLOORF128_BUILTIN 0
+
+#define USE_CEIL_BUILTIN 0
+#define USE_CEILF_BUILTIN 0
+#define USE_CEILL_BUILTIN 0
+#define USE_CEILF128_BUILTIN 0
+
+#define USE_TRUNC_BUILTIN 0
+#define USE_TRUNCF_BUILTIN 0
+#define USE_TRUNCL_BUILTIN 0
+#define USE_TRUNCF128_BUILTIN 0
+
+#define USE_ROUND_BUILTIN 0
+#define USE_ROUNDF_BUILTIN 0
+#define USE_ROUNDL_BUILTIN 0
+#define USE_ROUNDF128_BUILTIN 0
+
+#define USE_COPYSIGNL_BUILTIN 1
+#if __GNUC_PREREQ (7, 0)
+# define USE_COPYSIGNF128_BUILTIN 1
+#else
+# define USE_COPYSIGNF128_BUILTIN 0
+#endif
+
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+
+#define USE_FMA_BUILTIN 1
+#define USE_FMAF_BUILTIN 1
+#define USE_FMAL_BUILTIN 0
+
+#endif /* math-use-builtins.h */
diff --git a/sysdeps/aarch64/fpu/s_fma.c b/sysdeps/aarch64/fpu/s_fma.c
deleted file mode 100644
index 48bb40482dc9..000000000000
--- a/sysdeps/aarch64/fpu/s_fma.c
+++ /dev/null
@@ -1,28 +0,0 @@ 
-/* Copyright (C) 1996-2020 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>
-
-double
-__fma (double x, double y, double z)
-{
-  return __builtin_fma (x, y, z);
-}
-
-libm_alias_double (__fma, fma)
diff --git a/sysdeps/aarch64/fpu/s_fmaf.c b/sysdeps/aarch64/fpu/s_fmaf.c
deleted file mode 100644
index 544f32e27aec..000000000000
--- a/sysdeps/aarch64/fpu/s_fmaf.c
+++ /dev/null
@@ -1,28 +0,0 @@ 
-/* Copyright (C) 2011-2020 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>
-
-float
-__fmaf (float x, float y, float z)
-{
-  return __builtin_fmaf (x, y, z);
-}
-
-libm_alias_float (__fma, fma)