On Tue, 2019-03-12 at 14:17 +0000, Joseph Myers wrote: > > On Tue, 12 Mar 2019, Richard Biener wrote: > > > It shouldn't be difficult to provide an alias from the glibc side, no? > > How does x86 avoid this issue? > > There are static-only wrappers in libmvec_nonshared.a to work around the > GCC limitation (not included in the shared library, so less efficient than > direct calls to the vectorized functions, because it ought not be > necessary to have multiple symbols for the same function exported from the > shared library for this purpose). > > The issue is as I said in > <https://gcc.gnu.org/ml/gcc/2015-06/msg00176.html> - vector and scalar > versions of functions should not need to be in one-to-one correspondence. > For example, you could add __attribute__ ((__vector_asm__ ("name"))) to > set the version of a function's name to be used as the basis for forming > vector function names, overriding the use of a name specified with asm > ("name") for that purpose.
I like this idea. I have prototyped something, I created 'vector_asm' as an aarch64 attribute because I couldn't find where to put global attributes like __simd__. Does anyone know where these are listed? I left off the leading/trailing underscores because GCC didn't like them in a target attribute. I then updated my sysdeps/aarch64/fpu/bits/math-vector.h file in glibc and things seemed to work fine. Here are my changes, what do people think about changing GCC to do this? The GCC changes I made are: diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b38505b..45fde16 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1180,8 +1180,9 @@ static const struct attribute_spec aarch64_attribute_table[] = { /* { name, min_len, max_len, decl_req, type_req, fn_type_req, affects_type_identity, handler, exclude } */ - { "aarch64_vector_pcs", 0, 0, false, true, true, true, NULL, NULL }, - { NULL, 0, 0, false, false, false, false, NULL, NULL } + { "aarch64_vector_pcs", 0, 0, false, true, true, true, NULL, NULL }, + { "vector_asm", 1, 1, true, false, false, false, NULL, NULL }, + { NULL, 0, 0, false, false, false, false, NULL, NULL } }; #define AARCH64_CPU_DEFAULT_FLAGS ((selected_cpu) ? selected_cpu->flags : 0) diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 388198b..59183f0 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -342,6 +342,8 @@ simd_clone_mangle (struct cgraph_node *node, unsigned int simdlen = clone_info->simdlen; unsigned int n; pretty_printer pp; + tree attr; + const char *str; gcc_assert (vecsize_mangle && simdlen); @@ -409,7 +411,12 @@ simd_clone_mangle (struct cgraph_node *node, } pp_underscore (&pp); - const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)); + attr = lookup_attribute ("vector_asm", DECL_ATTRIBUTES (node->decl)); + if (attr) + str = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))); + else + str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)); + if (*str == '*') ++str; pp_string (&pp, str); The new sysdeps/aarch64/fpu/bits/math-vector.h was modified to include: # ifdef __DECL_SIMD_AARCH64 # undef __DECL_SIMD_exp # define __DECL_SIMD_exp __DECL_SIMD_AARCH64 __attribute__ ((vector_asm ("exp"))) # undef __DECL_SIMD_expf # define __DECL_SIMD_expf __DECL_SIMD_AARCH64 __attribute__ ((vector_asm ("expf"))) # endif