[PATCH v2 2/2] aarch64: Add SIMD attributes to math functions with vector versions
Florian Weimer
fweimer@redhat.com
Mon Jan 27 06:22:43 GMT 2025
* Joe Ramsay:
> Added annotations for autovec by GCC and GFortran - this enables GCC
> >= 9 to autovectorise math calls at -Ofast.
> diff --git a/sysdeps/aarch64/fpu/bits/math-vector.h b/sysdeps/aarch64/fpu/bits/math-vector.h
> index 52aad95e3b..67dc65bb76 100644
> --- a/sysdeps/aarch64/fpu/bits/math-vector.h
> +++ b/sysdeps/aarch64/fpu/bits/math-vector.h
> @@ -25,6 +25,72 @@
> /* Get default empty definitions for simd declarations. */
> #include <bits/libm-simd-decl-stubs.h>
>
> +#if defined __aarch64__ && defined __FAST_MATH__ && __GNUC_PREREQ (6, 0)
> +/* Requires GCC >= 6 for __attribute__ ((__simd__)). */
> +# define __DECL_SIMD_aarch64 __attribute__ ((__simd__ ("notinbranch"), const))
This is active for -Ofast/-ffast-math only, so it matches the commit
message.
> diff --git a/sysdeps/aarch64/fpu/finclude/math-vector-fortran.h b/sysdeps/aarch64/fpu/finclude/math-vector-fortran.h
> new file mode 100644
> index 0000000000..af489f4769
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/finclude/math-vector-fortran.h
> @@ -0,0 +1,47 @@
> +! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
> +! Copyright (C) 2019-2023 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/>.
> +!GCC$ builtin (acos) attributes simd (notinbranch)
> +!GCC$ builtin (acosf) attributes simd (notinbranch)
[…]
But this is not conditional on -Ofast/-ffast-math, as far as I can see.
Is it correct to use the libmvec routines in the default mode?
(The x86-64 Fortran header has a similar issue, I think.)
Thanks,
Florian
More information about the Libc-alpha
mailing list