Hi Christophe,

On 2026-11-10 15:37, Christophe Lyon wrote:
When running the testsute with non-default RUNTESTFLAGS,
arm_fp16_ok_nocache may insert -mfpu=vfpv4 if needed.

However, if RUNTESTFLAGS uses an incompatible -mcpu, we can end up
generating invalid code.

For instance, if RUNTESTFLAGS uses
-mthumb/-mcpu=cortex-m33/-mfloat-abi=hard/-march=unset,
we compile gcc.target/arm/aapcs/vfp19.c with
-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -march=unset [...] -mfpu=vfpv4 
-mfp16-format=ieee
and this enables GCC to generate instructions such as
vmov    d17, r0, r1
which is incorrect because cortex-m33 supports only 16 D registers.

This patch avoid this by not adding -mfpu=vfpv4 to the list if the
user forced a -mcpu flag.  This is conservative, but there is no way
to reliably detect whether -mfpu=vfpv4 is compatible with the current
flags.

With the patch, vfp18.c, vfp19.c, vfp22.c and vfp23.c are now
UNSUPPORTED in this configuration, instead of failing at execution
time.

I've tested this with my usual targets on arm-none-eabi and it resolves most
of the failures, but I still see these:

FAIL: gcc.target/arm/aapcs/vfp18.c execution test
FAIL: gcc.target/arm/aapcs/vfp19.c execution test
FAIL: gcc.target/arm/aapcs/vfp22.c execution test
FAIL: gcc.target/arm/aapcs/vfp23.c execution test

for:

thumb/arch=armv7e-m+fp/tune=cortex-m4/float-abi=hard/fpu=auto
thumb/arch=armv8-m.main+dsp+fp/tune=cortex-m33/float-abi=hard/fpu=auto

maybe these are expected, maybe the are supposed to pass.

If I instead use

thumb/arch=armv7e-m+fp/cpu=cortex-m4/float-abi=hard/fpu=auto

then the same tests are marked as unsupported.


gcc/testsuite/ChangeLog:

        PR testsuite/126082
        * lib/target-supports.exp (arm_fp16_ok_nocache): Try -mfpu=vfpv4
        only if -mcpu is not overridden.
---
  gcc/testsuite/lib/target-supports.exp | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 3ce06189d2e..1f61da72aea 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6481,14 +6481,19 @@ proc check_effective_target_arm_fp16_ok_nocache { } {
      }
      global et_arm_fp16_flags
      set et_arm_fp16_flags ""
-    foreach flags {
+    set flags_list {
        ""
        "-mfloat-abi=softfp"
        "-mfpu=auto"
        "-mfloat-abi=softfp -mfpu=auto"
-       "-mfpu=vfpv4"
-       "-mfloat-abi=softfp -mfpu=vfpv4"
-    } {
+    }
+
+    if { ![check-flags [list "" { *-*-* } { "-mcpu=*" } { "" } ]] } {

To resolve the 2 targets that are failing, I think this also needs to
check for -mtune, but I could be wrong.

For -mcpu, the arm_fp16_ok check fails.

+       lappend flags_list "-mfpu=vfpv4"

For -march only, the above flags makes the arm_fp16_ok check succeed,
but it does not work for execution.


Kind regards,
Torbjörn


+       lappend flags_list "-mfloat-abi=softfp -mfpu=vfpv4"
+    }
+
+    foreach flags $flags_list {
        if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
            #ifndef __ARM_FP
            #error __ARM_FP not defined

Reply via email to