[committed,02/22] arm: testsuite: correctly detect hard_float

Message ID 20231113142658.69039-3-rearnsha@arm.com
State Unresolved
Headers
Series arm: testsuite: clean up some architecture-specific tests |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Richard Earnshaw Nov. 13, 2023, 2:26 p.m. UTC
  Add an arm-specific test to check_effective_target_hard_float for
Arm to handle cases where we only have single-precision FP in hardware.

gcc/testsuite:

	* lib/target-supports.exp (check_effective_target_hard_float): Add
	arm-specific test.
---
 gcc/testsuite/lib/target-supports.exp | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Christophe Lyon Nov. 20, 2023, 10:41 a.m. UTC | #1
Hi Richard,


On Mon, 13 Nov 2023 at 15:27, Richard Earnshaw <rearnsha@arm.com> wrote:
>
>
> Add an arm-specific test to check_effective_target_hard_float for
> Arm to handle cases where we only have single-precision FP in hardware.
>
> gcc/testsuite:
>
>         * lib/target-supports.exp (check_effective_target_hard_float): Add
>         arm-specific test.
> ---
>  gcc/testsuite/lib/target-supports.exp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

Our CI has detected a problem when testing this patch for cortex-m33:
with -mthumb/-march=armv8-m.main+dsp+fp/-mtune=cortex-m33/-mfloat-abi=hard/-mfpu=auto
and GCC configured with --disable-multilib --with-mode=thumb
--with-cpu=cortex-m33 --with-float=hard

FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -O0  execution test
FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -O1  execution test
FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -O2  execution test
FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -O2 -flto -fno-use-linker-plugin -flto-partition=none  execution
test
FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  execution test
FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -O3 -g  execution test
FAIL: gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
  -Os  execution test

We use qemu for testing. Do these tests pass in your configuration?

Thanks,

Christophe
  
Richard Earnshaw Nov. 20, 2023, 12:20 p.m. UTC | #2
On 20/11/2023 10:41, Christophe Lyon wrote:
> Hi Richard,
> 
> 
> On Mon, 13 Nov 2023 at 15:27, Richard Earnshaw <rearnsha@arm.com> wrote:
>>
>>
>> Add an arm-specific test to check_effective_target_hard_float for
>> Arm to handle cases where we only have single-precision FP in hardware.
>>
>> gcc/testsuite:
>>
>>         * lib/target-supports.exp (check_effective_target_hard_float): Add
>>         arm-specific test.
>> ---
>>  gcc/testsuite/lib/target-supports.exp | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
> 
> Our CI has detected a problem when testing this patch for cortex-m33:
> with 
> -mthumb/-march=armv8-m.main+dsp+fp/-mtune=cortex-m33/-mfloat-abi=hard/-mfpu=auto
> and GCC configured with --disable-multilib --with-mode=thumb
> --with-cpu=cortex-m33 --with-float=hard
> 
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -O0  execution test
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -O1  execution test
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -O2  execution test
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -O2 -flto -fno-use-linker-plugin -flto-partition=none  execution
> test
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  execution test
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -O3 -g  execution test
> FAIL: 
> gcc:gcc.dg/torture/dg-torture.exp=gcc.dg/torture/fp-double-convert-float-1.c
>    -Os  execution test
> 

I think this technically is a real bug in the port.  This test changes 
the rounding modes, but cortex-m33 only has a single-precision FP unit, 
so single-precision is handled in HW, while double-precision is handled 
in SW.  The soft-float functions don't support changing the rounding 
mode, and certainly not through fesetround(), so we don't get the 
expected results.  I think the test would always have failed, but we 
didn't run it in the past as the default test for HW fp only checked for 
double precision HW.

Fixing the real problem is not trivial though, especially in a mixed 
hard/soft environment.


> We use qemu for testing. Do these tests pass in your configuration?
> 
> Thanks,
> 
> Christophe

R.
  

Patch

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index d414cddf4dc..ee173b9fb6b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1420,6 +1420,17 @@  proc check_effective_target_mpaired_single { args } {
 # Return true if the target has access to FPU instructions.
 
 proc check_effective_target_hard_float { } {
+    # This should work on cores that only have single-precision,
+    # and should also correctly handle legacy cores that had thumb1 and
+    # lacked FP support for that, but had it in Arm state.
+    if { [istarget arm*-*-*] } {
+	return [check_no_compiler_messages hard_float assembly {
+		#if __ARM_FP == 0
+		#error __arm_soft_float
+		#endif
+	}]
+    }
+
     if { [istarget loongarch*-*-*] } {
 	return [check_no_compiler_messages hard_float assembly {
 		#if (defined __loongarch_soft_float)