This is a proposed GCC patch that allows targets to modify the names of the libmvec routines that get called. Currently, if you build ToT GCC on Aarch64 and include this glibc patch:
https://sourceware.org/ml/libc-alpha/2019-03/msg00106.html And then compile a call to expf which gets vectorized, GCC will generate a libmvec call to '_ZGVnN4v___expf_finite' instead of _ZGVnN4v_expf because the limvec name is based on the assembly name of the scalar function (__expf_finite) and not the 'real' name (expf). This means that libmvec needs to provide both names, even though the routines don't differ. Rather than create both names I would like to make it possible for GCC to generate calls to libmvec based on the real name by having a target specific function that allows GCC to use the DECL_NAME instead of DECL_ASSEMBLER_NAME to create the libmvec name. The responses to my glibc patch (referenced above) has a pointer to where this was discussed in the GCC mailing list a couple of years ago: https://gcc.gnu.org/ml/gcc/2015-06/msg00173.html and which has a pointer back to an older glibc string as well: https://sourceware.org/ml/libc-alpha/2015-06/msg00213.html Any thoughts on this patch as a way of 'fixing' GCC to not use the finite alias names? Steve Ellcey sell...@marvell.com 2018-03-11 Steve Ellcey <sell...@marvell.com> * config/aarch64/aarch64.c (aarch64_simd_clone_vec_base_name): New function. (TARGET_SIMD_CLONE_VEC_BASE_NAME): New macro. * doc/tm.texi.in (TARGET_SIMD_CLONE_VEC_BASE_NAME): New hook. * doc/tm.texi: Regenerate. * omp-simd-clone.c (simd_clone_mangle): Call vec_base_name hook. * target.def (vec_base_name): New hook. * targhooks.c (cgraph.h): New include. (default_vec_base_name): New function. * targhooks.h (default_vec_base_name): New function declaration.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 252bed7..cddab80 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -18711,6 +18711,14 @@ aarch64_simd_clone_usable (struct cgraph_node *node) } } +/* Implement TARGET_SIMD_CLONE_VEC_BASE_NAME */ + +static const char * +aarch64_simd_clone_vec_base_name (struct cgraph_node *node) +{ + return IDENTIFIER_POINTER (DECL_NAME (node->decl)); +} + /* Implement TARGET_COMP_TYPE_ATTRIBUTES */ static int @@ -19251,6 +19259,9 @@ aarch64_libgcc_floating_mode_supported_p #undef TARGET_SIMD_CLONE_USABLE #define TARGET_SIMD_CLONE_USABLE aarch64_simd_clone_usable +#undef TARGET_SIMD_CLONE_VEC_BASE_NAME +#define TARGET_SIMD_CLONE_VEC_BASE_NAME aarch64_simd_clone_vec_base_name + #undef TARGET_COMP_TYPE_ATTRIBUTES #define TARGET_COMP_TYPE_ATTRIBUTES aarch64_comp_type_attributes diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index fe1194e..de4bdb42 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -4196,6 +4196,8 @@ address; but often a machine-dependent strategy can generate better code. @hook TARGET_SIMD_CLONE_USABLE +@hook TARGET_SIMD_CLONE_VEC_BASE_NAME + @hook TARGET_SIMT_VF @hook TARGET_GOACC_VALIDATE_DIMS diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 388198b..b3a57aa 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -409,7 +409,7 @@ simd_clone_mangle (struct cgraph_node *node, } pp_underscore (&pp); - const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)); + const char *str = targetm.simd_clone.vec_base_name (node); if (*str == '*') ++str; pp_string (&pp, str); diff --git a/gcc/target.def b/gcc/target.def index 66cee07..da60249 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -1655,6 +1655,13 @@ usable. In that case, the smaller the number is, the more desirable it is\n\ to use it.", int, (struct cgraph_node *), NULL) +DEFHOOK +(vec_base_name, +"This hook should return the name of the scalar function being cloned.\n\ +This defaults to DECL_ASSEMBLER_NAME, but targets could use DECL_NAME\n\ +instead or some other variation of the function name.", +const char *, (struct cgraph_node *), default_vec_base_name) + HOOK_VECTOR_END (simd_clone) /* Functions relating to OpenMP SIMT vectorization transform. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 318f7e9..6792ee5 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -83,6 +83,7 @@ along with GCC; see the file COPYING3. If not see #include "real.h" #include "langhooks.h" #include "sbitmap.h" +#include "cgraph.h" bool default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED, @@ -2379,4 +2380,10 @@ default_remove_extra_call_preserved_regs (rtx_insn *, HARD_REG_SET *) { } +const char * +default_vec_base_name (struct cgraph_node * node) +{ + return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)); +} + #include "gt-targhooks.h" diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 5943627..85dce1a 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -286,5 +286,6 @@ extern bool speculation_safe_value_not_needed (bool); extern rtx default_speculation_safe_value (machine_mode, rtx, rtx, rtx); extern void default_remove_extra_call_preserved_regs (rtx_insn *, HARD_REG_SET *); +extern const char * default_vec_base_name (struct cgraph_node *); #endif /* GCC_TARGHOOKS_H */