https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117814
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Christophe Lyon <[email protected]>: https://gcc.gnu.org/g:c6fff0b1709f2a7d665ffadce96d6deb07ce62ae commit r16-5394-gc6fff0b1709f2a7d665ffadce96d6deb07ce62ae Author: Christophe Lyon <[email protected]> Date: Thu Sep 18 23:16:32 2025 +0000 arm: [MVE intrinsics] Avoid warnings when floating-point is not supported [PR 117814] If the target does not support floating-point, we register FP vector types as 'void' (see register_vector_type). This leads to warnings about 'pure attribute on function returning void' when we declare the various load intrinsics because their call_properties say CP_READ_MEMORY (thus giving them the 'pure' attribute), but their return type is void. This happens for instance in gcc.target/arm/pr112337.c, depending on how GCC is built (I didn't notice the warnings because arm_mve.h is considered as a system include in my environment, and the warning is not emitted, but CI reported it). To avoid such warnings, declare floating-point scalar and vector types even if the target does not have an FPU. Note that since an FPU can be activated via #pragma GCC target ("arch=armv8.1-m.main+mve.fp" for instance), it means that such types cannot appear and disappear withing a single TU, they have to be available in all contexts. This implies a noteworthy change for __fp16: it not longer depends on using -mfp16-format=ieee or alternative. Also note that if the target ISA has the fp16 bit set, we already silently activate -mfp16-format=ieee (with an error if -mfp16-format=alternative was supplied). The patch now enforces -mfp16-format=none if the option was used. In arm-mve-builtins.cc (register_builtin_types, register_vector_type, register_builtin_tuple_types), this means simply removing the early exits. However, for this to work, we need to update arm_vector_mode_supported_p, so that vector floating-point types are always defined, and __fp16 must always be registered by arm_init_fp16_builtins (as it is the base type for vectors of float16_t. Another side effect is that the declaration of float16_t and float32_t typedefs is now unconditional. The new tests verify that: - we emit an error if the code tries to use floating-point intrinsics and the target does not have the floating-point extension - we emit the expected code when activating the floating-point expected via a pragma - we emit the expected code when the target supports floating-point (no pragma needed) - we apply -mfp16-format=none where we used to default to ieee An update is needed in g++.target/arm/mve/general-c++/nomve_fp_1.c, because the error message now correctly uses float16x8_t instead of void as return type. The patch removes gcc.target/arm/fp16-compile-none-1.c which tests that using __fp16 produces an error with -mfp16-format=none, since it is no longer the case. gcc/ChangeLog: PR target/117814 * config/arm/arm-builtins.cc (arm_init_fp16_builtins): Always register __fp16 type. * config/arm/arm-mve-builtins.cc (register_builtin_tuple_types): Remove special handling when TARGET_HAVE_MVE_FLOAT is false. (register_vector_type): Likewise. (register_builtin_tuple_types): Likewise. * config/arm/arm-opts.h (arm_fp16_format_type): Add ARM_FP16_FORMAT_DEFAULT. * config/arm/arm.cc (arm_vector_mode_supported_p): Accept floating-point vector modes even if TARGET_HAVE_MVE_FLOAT is false. (arm_option_reconfigure_globals): Apply ARM_FP16_FORMAT_NONE if requested. * config/arm/arm.opt (mfp16-format): Default to ARM_FP16_FORMAT_DEFAULT. * config/arm/arm_mve_types.h (float16_t, float32_t): Define unconditionally. * doc/sourcebuild.texi (ARM-specific attributes): Document arm_v8_1m_mve_nofp_ok. gcc/testsuite/ChangeLog: PR target/117814 * gcc.target/arm/mve/intrinsics/pr117814-f16.c: New test. * gcc.target/arm/mve/intrinsics/pr117814-2-f16.c: New test. * gcc.target/arm/mve/intrinsics/pr117814-3-f16.c: New test. * gcc.target/arm/mve/intrinsics/pr117814-4-f16.c: New test. * gcc.target/arm/mve/intrinsics/pr117814-f32.c: New test. * gcc.target/arm/mve/intrinsics/pr117814-2-f32.c: New test. * gcc.target/arm/mve/intrinsics/pr117814-3-f32.c: New test. * gcc.target/arm/fp16-compile-none-1.c: Delete. * g++.target/arm/mve/general-c++/nomve_fp_1.c: Fix expected error message. * lib/target-supports.exp (check_effective_target_arm_v8_1m_mve_nofp_ok_nocache): New. (check_effective_target_arm_v8_1m_mve_nofp_ok): New. (add_options_for_arm_v8_1m_mve_nofp): New.
