aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Ramsay <Joe.Ramsay@arm.com>2023-12-18 15:51:16 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2023-12-20 08:41:25 +0000
commit667f277c782f4457603e6d192bac294e5f2c5186 (patch)
treee77202e2ec1c441fcde7e000cda5be3173672785
parentcc0d77ba944cd4ce46c5f0e6d426af3057962ca5 (diff)
downloadglibc-667f277c782f4457603e6d192bac294e5f2c5186.tar
glibc-667f277c782f4457603e6d192bac294e5f2c5186.tar.gz
glibc-667f277c782f4457603e6d192bac294e5f2c5186.tar.bz2
glibc-667f277c782f4457603e6d192bac294e5f2c5186.zip
aarch64: Add SIMD attributes to math functions with vector versions
Added annotations for autovec by GCC and GFortran - this enables GCC >= 9 to autovectorise math calls at -Ofast. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
-rw-r--r--sysdeps/aarch64/fpu/bits/math-vector.h66
-rw-r--r--sysdeps/aarch64/fpu/finclude/math-vector-fortran.h47
2 files changed, 113 insertions, 0 deletions
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))
+
+# undef __DECL_SIMD_acos
+# define __DECL_SIMD_acos __DECL_SIMD_aarch64
+# undef __DECL_SIMD_acosf
+# define __DECL_SIMD_acosf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_asin
+# define __DECL_SIMD_asin __DECL_SIMD_aarch64
+# undef __DECL_SIMD_asinf
+# define __DECL_SIMD_asinf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_atan
+# define __DECL_SIMD_atan __DECL_SIMD_aarch64
+# undef __DECL_SIMD_atanf
+# define __DECL_SIMD_atanf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_atan2
+# define __DECL_SIMD_atan2 __DECL_SIMD_aarch64
+# undef __DECL_SIMD_atan2f
+# define __DECL_SIMD_atan2f __DECL_SIMD_aarch64
+# undef __DECL_SIMD_cos
+# define __DECL_SIMD_cos __DECL_SIMD_aarch64
+# undef __DECL_SIMD_cosf
+# define __DECL_SIMD_cosf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_exp
+# define __DECL_SIMD_exp __DECL_SIMD_aarch64
+# undef __DECL_SIMD_expf
+# define __DECL_SIMD_expf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_exp10
+# define __DECL_SIMD_exp10 __DECL_SIMD_aarch64
+# undef __DECL_SIMD_exp10f
+# define __DECL_SIMD_exp10f __DECL_SIMD_aarch64
+# undef __DECL_SIMD_exp2
+# define __DECL_SIMD_exp2 __DECL_SIMD_aarch64
+# undef __DECL_SIMD_exp2f
+# define __DECL_SIMD_exp2f __DECL_SIMD_aarch64
+# undef __DECL_SIMD_expm1
+# define __DECL_SIMD_expm1 __DECL_SIMD_aarch64
+# undef __DECL_SIMD_expm1f
+# define __DECL_SIMD_expm1f __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log
+# define __DECL_SIMD_log __DECL_SIMD_aarch64
+# undef __DECL_SIMD_logf
+# define __DECL_SIMD_logf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log10
+# define __DECL_SIMD_log10 __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log10f
+# define __DECL_SIMD_log10f __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log1p
+# define __DECL_SIMD_log1p __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log1pf
+# define __DECL_SIMD_log1pf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log2
+# define __DECL_SIMD_log2 __DECL_SIMD_aarch64
+# undef __DECL_SIMD_log2f
+# define __DECL_SIMD_log2f __DECL_SIMD_aarch64
+# undef __DECL_SIMD_sin
+# define __DECL_SIMD_sin __DECL_SIMD_aarch64
+# undef __DECL_SIMD_sinf
+# define __DECL_SIMD_sinf __DECL_SIMD_aarch64
+# undef __DECL_SIMD_tan
+# define __DECL_SIMD_tan __DECL_SIMD_aarch64
+# undef __DECL_SIMD_tanf
+# define __DECL_SIMD_tanf __DECL_SIMD_aarch64
+#endif
+
#if __GNUC_PREREQ(9, 0)
# define __ADVSIMD_VEC_MATH_SUPPORTED
typedef __Float32x4_t __f32x4_t;
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)
+!GCC$ builtin (asin) attributes simd (notinbranch)
+!GCC$ builtin (asinf) attributes simd (notinbranch)
+!GCC$ builtin (atan) attributes simd (notinbranch)
+!GCC$ builtin (atanf) attributes simd (notinbranch)
+!GCC$ builtin (atan2) attributes simd (notinbranch)
+!GCC$ builtin (atan2f) attributes simd (notinbranch)
+!GCC$ builtin (cos) attributes simd (notinbranch)
+!GCC$ builtin (cosf) attributes simd (notinbranch)
+!GCC$ builtin (exp) attributes simd (notinbranch)
+!GCC$ builtin (expf) attributes simd (notinbranch)
+!GCC$ builtin (exp10) attributes simd (notinbranch)
+!GCC$ builtin (exp10f) attributes simd (notinbranch)
+!GCC$ builtin (exp2) attributes simd (notinbranch)
+!GCC$ builtin (exp2f) attributes simd (notinbranch)
+!GCC$ builtin (expm1) attributes simd (notinbranch)
+!GCC$ builtin (expm1f) attributes simd (notinbranch)
+!GCC$ builtin (log) attributes simd (notinbranch)
+!GCC$ builtin (logf) attributes simd (notinbranch)
+!GCC$ builtin (log10) attributes simd (notinbranch)
+!GCC$ builtin (log10f) attributes simd (notinbranch)
+!GCC$ builtin (log1p) attributes simd (notinbranch)
+!GCC$ builtin (log1pf) attributes simd (notinbranch)
+!GCC$ builtin (log2) attributes simd (notinbranch)
+!GCC$ builtin (log2f) attributes simd (notinbranch)
+!GCC$ builtin (sin) attributes simd (notinbranch)
+!GCC$ builtin (sinf) attributes simd (notinbranch)
+!GCC$ builtin (tan) attributes simd (notinbranch)
+!GCC$ builtin (tanf) attributes simd (notinbranch)