https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112989
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>: https://gcc.gnu.org/g:d76651d9170099de4d3bc3cbc3811d499018910b commit r14-7184-gd76651d9170099de4d3bc3cbc3811d499018910b Author: Richard Sandiford <richard.sandif...@arm.com> Date: Fri Jan 12 12:29:22 2024 +0000 aarch64: Use a separate group for SME builtins [PR112989] The PR shows that we were registering the same overloaded SVE builtins twice. This was supposed to be prevented by function_builder::add_overloaded_function, which uses a map to detect whether a function of the same name has already been registered. add_overloaded_function then had some asserts to check for consistency. However, the map that add_overloaded_function uses was a member of function_builder itself. That made sense when there was just one header file, arm_sve.h, since it meant that the memory could be reclaimed once arm_sve.h had been processed. But now we have three header files, and in principle, it's possible for arm_sme.h to include overloads of things that arm_sve.h also defines. We therefore need to use a global map instead. However, doing that meant that the consistency checks in add_overloaded_function fired as expected, which showed some latent issues. This preliminary patch deals with those by adding AARCH64_FL_SME to things that require AARCH64_FL_SME2. This inconsistency led to another problem: functions were selected for arm_sme.h over arm_sve.h based on whether they had AARCH64_FL_SME. So some SME2-only things were actually defined in arm_sve.h, whereas similar SME things were defined in arm_sme.h. Choosing based on flags was an early get-started crutch that I forgot to clean up later :( This patch goes for the more direct approach of having a separate table of SME builtins, as for arm_neon_sve_bridge.h. aarch64-sve-builtins-sve2.def contains several intrinsics that are currently SME-only but that operate entirely on vector registers. Many of these will be extended to SVE2.1 once SVE2.1 support is added, so the patch front-loads that by keeping the current division between aarch64-sve-builtins-sve2.def (whose functions now go in arm_sve.h) and aarch64-sve-builtins-sme.def (whose functions now go in arm_sme.h). gcc/ PR target/112989 * config/aarch64/aarch64-sve-builtins.def: Don't include aarch64-sve-builtins-sme.def. (DEF_SME_ZA_FUNCTION_GS, DEF_SME_ZA_FUNCTION): Move to... * config/aarch64/aarch64-sve-builtins-sme.def: ...here. (DEF_SME_FUNCTION): New macro. Use it and DEF_SME_FUNCTION_GS instead of DEF_SVE_*. Add AARCH64_FL_SME to anything that requires AARCH64_FL_SME2. * config/aarch64/aarch64-sve-builtins-sve2.def: Make same AARCH64_FL_SME adjustment here. * config/aarch64/aarch64-sve-builtins.cc (function_groups): Don't include SME intrinsics. (sme_function_groups): New array. (handle_arm_sve_h): Remove check for AARCH64_FL_SME. (handle_arm_sme_h): Use sme_function_groups instead of function_groups. gcc/testsuite/ PR target/112989 * gcc.target/aarch64/sve/acle/general-c/clamp_1.c: Remove bogus error test.