On 2024-11-08 12:24, Richard Earnshaw (lists) wrote:
On 05/11/2024 20:06, Torbjörn SVENSSON wrote:
Based on how these functions are used in test cases, I think it's correct
to require 16-bit float support in both functions.
Without this change, the checks passes for armv8-m and armv8.1-m, but the
test cases that uses them fails due to the incorrect -mfpu option.
Ok for trunk and releases/gcc-14?
Can you expand on the issue you're trying to address with this change?
If dejagnu is started with a specified FPU, the function
arm_v8_2a_fp16_scalar_ok will check if
__ARM_FEATURE_FP16_VECTOR_ARITHMETIC is defined, but it will not ensure
that the FPU supports 16-bit floats.
The result is that with the given FPU, GCC might report that
__ARM_FEATURE_FP16_VECTOR_ARITHMETIC is supported, but 16-bit floats are
not.
With -march and -mfpu:
.../bin/arm-none-eabi-gcc -E -dM - -mthumb -march=armv8-m.main+fp
-mfloat-abi=hard -mfpu=fpv5-sp-d16 -fdiagnostics-plain-output -O2
-mcpu=unset -march=armv8.2-a+fp16 </dev/null | grep -e '__ARM_FP ' -e
__ARM_FEATURE_FP16_SCALAR_ARITHMETIC
#define __ARM_FP 4
#define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
Same as above, but with -mfpu=auto appended:
.../bin/arm-none-eabi-gcc -E -dM - -mthumb -march=armv8-m.main+fp
-mfloat-abi=hard -mfpu=fpv5-sp-d16 -fdiagnostics-plain-output -O2
-mcpu=unset -march=armv8.2-a+fp16 -mfpu=auto </dev/null | grep -e
'__ARM_FP ' -e __ARM_FEATURE_FP16_SCALAR_ARITHMETIC
#define __ARM_FP 14
#define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
So, adding the __ARM_FP validation ensures that the empty set of flags
is never accepted for this scenario.
For check_effective_target_arm_v8_2a_fp16_neon_ok_nocache, it's the same
thing but here we also assume that neon is available without checking it.
Looking though other failing tests, I also notices that
check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache is
essential a copy of
check_effective_target_arm_v8_2a_fp16_neon_ok_nocache, but with a
different architecture and define, so I'll add a fix for that too.
With all this said, I see that there is an error in this patch, so a v2
will be sent as soon as my current test run completes and there is no
regression.
Kind regards,
Torbjörn
R.
--
In both functions, it's assumed that 16-bit float support is available,
but it's not checked.
In addition, check_effective_target_arm_v8_2a_fp16_neon_ok also assumes
that neon is used, but it's not checked.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp
(check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache): Check
that 16-bit float is supported.
(check_effective_target_arm_v8_2a_fp16_neon_ok_nocache): Check
that neon is used and that 16-bit float is supported.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svens...@foss.st.com>
---
gcc/testsuite/lib/target-supports.exp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/
lib/target-supports.exp
index 75703ddca60..19a9981d9cd 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6360,6 +6360,12 @@ proc
check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
"-mfpu=fp-armv8 -mfloat-abi=softfp"} {
if { [check_no_compiler_messages_nocache \
arm_v8_2a_fp16_scalar_ok object {
+ #if !defined (__ARM_FP)
+ #error "__ARM_FP not defined"
+ #endif
+ #if ((__ARM_FP & 1) == 0)
+ #error "__ARM_FP indicates that 16-bit is not supported"
+ #endif
#if !defined (__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
#error "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined"
#endif
@@ -6395,6 +6401,15 @@ proc
check_effective_target_arm_v8_2a_fp16_neon_ok_nocache { } {
"-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
if { [check_no_compiler_messages_nocache \
arm_v8_2a_fp16_neon_ok object {
+ #if !defined (__ARM_FP)
+ #error "__ARM_FP not defined"
+ #endif
+ #if ((__ARM_FP & 1) == 0)
+ #error "__ARM_FP indicates that 16-bit is not supported"
+ #endif
+ #if !defined (__ARM_NEON__)
+ #error "__ARM_NEON__ not defined"
+ #endif
#if !defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
#error "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined"
#endif