]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make SVE tests work with --with-cpu
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 15 Apr 2021 15:18:25 +0000 (16:18 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 15 Apr 2021 15:18:25 +0000 (16:18 +0100)
A lot of the SVE assembly tests are for generic-tuned SVE codegen
and so can fail when run on a toolchain configured with --with-cpu.

This could easily be solved by forcing -mtune=generic, like we already
do for -moverride=tune=none.  However, the testsuite also has some
useful execution tests that it would be better to run with as
few flag changes as possible.  Also, the flags in $sve_flags are
printed as part of the test results, so each change to $sve_flags
results in a change to the test summaries.

This patch instead intercepts dg-options and tailors the list
of additional options based on what the test is trying to do.
It also gets rid of DEFAULT_CFLAGS, which are never useful
for these tests.

gcc/testsuite/
* lib/gcc-defs.exp (aarch64-arch-dg-options): New procedure.
(aarch64-with-arch-dg-options): Likewise.
* g++.target/aarch64/sve/aarch64-sve.exp: Run the tests inside
aarch64-with-arch-dg-options.  Move the default architecture
flags to the final dg-runtest argument.
* gcc.target/aarch64/sve/aarch64-sve.exp: Likewise.  Dispense with
DEFAULT_CFLAGS.
* gcc.target/aarch64/sve2/aarch64-sve2.exp: Likewise.

gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
gcc/testsuite/lib/gcc-defs.exp

index d4761f2d8075eaab056c2c22d2c429a82bf6452c..2b8502322292ad61983128b416abd916454e6ec1 100644 (file)
@@ -38,12 +38,10 @@ if { [check_effective_target_aarch64_sve] } {
     set sve_flags "-march=armv8.2-a+sve"
 }
 
-# Turn off any codegen tweaks by default that may affect expected assembly.
-# Tests relying on those should turn them on explicitly.
-set sve_flags "$sve_flags -moverride=tune=none"
-
-# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] $sve_flags ""
+aarch64-with-arch-dg-options $sve_flags {
+    # Main loop.
+    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" $sve_flags
+}
 
 # All done.
 dg-finish
index 1d3f56690e61bfd2102228f6a172e327b59c98d7..439a012ce43b7f6619d29ef38cc60da58bcef9e5 100644 (file)
@@ -28,26 +28,15 @@ if {![istarget aarch64*-*-*] } then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# If a testcase doesn't have special options, use these.
-global DEFAULT_CFLAGS
-if ![info exists DEFAULT_CFLAGS] then {
-    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
-}
-
 # Initialize `dg'.
 dg-init
 
-# Force SVE if we're not testing it already.
 if { [check_effective_target_aarch64_sve] } {
     set sve_flags ""
 } else {
     set sve_flags "-march=armv8.2-a+sve"
 }
 
-# Turn off any codegen tweaks by default that may affect expected assembly.
-# Tests relying on those should turn them on explicitly.
-set sve_flags "$sve_flags -moverride=tune=none"
-
 # Most of the code-quality tests are written for LP64.  Just do the
 # correctness tests for ILP32.
 if { [check_effective_target_ilp32] } {
@@ -56,9 +45,11 @@ if { [check_effective_target_ilp32] } {
     set pattern "*"
 }
 
-# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/$pattern.\[cCS\]]] \
-    $sve_flags $DEFAULT_CFLAGS
+aarch64-with-arch-dg-options $sve_flags {
+    # Main loop.
+    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/$pattern.\[cCS\]]] \
+       "" $sve_flags
+}
 
 # All done.
 dg-finish
index fcff0d21899213df5426f4f6cd1e1a75a4d1c552..28d61555ff28cf9966f7af9f67ee807310423b6b 100644 (file)
@@ -28,12 +28,6 @@ if {![istarget aarch64*-*-*] } then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# If a testcase doesn't have special options, use these.
-global DEFAULT_CFLAGS
-if ![info exists DEFAULT_CFLAGS] then {
-    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
-}
-
 # Initialize `dg'.
 dg-init
 
@@ -44,9 +38,11 @@ if { [check_effective_target_aarch64_sve2] } {
     set sve2_flags "-march=armv8.5-a+sve2"
 }
 
-# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
-    $sve2_flags $DEFAULT_CFLAGS
+aarch64-with-arch-dg-options $sve2_flags {
+    # Main loop.
+    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+       "" $sve2_flags
+}
 
 # All done.
 dg-finish
index a36b30da7ea3b22b782175f2e311ab61cf9a4847..e9119f02d65b9472955537a9d90bda00e0beb43c 100644 (file)
@@ -506,3 +506,65 @@ proc dg-check-dot { args } {
 
     pass "$testcase dg-check-dot $dotfile"
 }
+
+# Used by aarch64-with-arch-dg-options to intercept dg-options and make
+# the changes required.  See there for details.
+proc aarch64-arch-dg-options { args } {
+    upvar dg-do-what do_what
+    global aarch64_default_testing_arch
+
+    set add_arch 1
+    set add_tune 1
+    set checks_output [string equal [lindex $do_what 0] "compile"]
+    set options [lindex $args 1]
+
+    foreach option [split $options] {
+       switch -glob -- $option {
+           -march=* { set add_arch 0 }
+           -mcpu=* { set add_arch 0; set add_tune 0 }
+           -mtune=* { set add_tune 0 }
+           -moverride=* { set add_tune 0 }
+           -save-temps { set checks_output 1 }
+           --save-temps { set checks_output 1 }
+           -fdump* { set checks_output 1 }
+       }
+    }
+
+    if { $add_arch && ![string equal $aarch64_default_testing_arch ""] } {
+       # Force SVE if we're not testing it already.
+       append options " $aarch64_default_testing_arch"
+    }
+
+    if { $add_tune && $checks_output } {
+       # Turn off any default tuning and codegen tweaks.
+       append options " -mtune=generic -moverride=tune=none"
+    }
+
+    uplevel 1 aarch64-old-dg-options [lreplace $args 1 1 $options]
+}
+
+# Run Tcl code CODE with dg-options modified to work better for some
+# AArch64 tests.  In particular:
+#
+# - If the dg-options do not specify an -march or -mcpu option,
+#   use the architecture options in ARCH (which might be empty).
+#
+# - If the dg-options do not specify an -mcpu, -mtune or -moverride option,
+#   and if the test appears to be checking assembly or dump output,
+#   force the test to use generic tuning.
+#
+# The idea is to handle toolchains that are configured with a default
+# CPU or architecture that's different from the norm.
+proc aarch64-with-arch-dg-options { arch code } {
+    global aarch64_default_testing_arch
+
+    set aarch64_default_testing_arch $arch
+
+    rename dg-options aarch64-old-dg-options
+    rename aarch64-arch-dg-options dg-options
+
+    uplevel 1 $code
+
+    rename dg-options aarch64-arch-dg-options
+    rename aarch64-old-dg-options dg-options
+}