public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8196] Make SVE tests work with --with-cpu
@ 2021-04-15 15:18 Richard Sandiford
0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2021-04-15 15:18 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ff1912238e28ed204570e0d33d3c3517491caf0f
commit r11-8196-gff1912238e28ed204570e0d33d3c3517491caf0f
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Thu Apr 15 16:18:25 2021 +0100
Make SVE tests work with --with-cpu
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.
Diff:
---
.../g++.target/aarch64/sve/aarch64-sve.exp | 10 ++--
.../gcc.target/aarch64/sve/aarch64-sve.exp | 19 ++-----
.../gcc.target/aarch64/sve2/aarch64-sve2.exp | 14 ++---
gcc/testsuite/lib/gcc-defs.exp | 62 ++++++++++++++++++++++
4 files changed, 76 insertions(+), 29 deletions(-)
diff --git a/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp b/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
index d4761f2d807..2b850232229 100644
--- a/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
+++ b/gcc/testsuite/g++.target/aarch64/sve/aarch64-sve.exp
@@ -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
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp b/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
index 1d3f56690e6..439a012ce43 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
+++ b/gcc/testsuite/gcc.target/aarch64/sve/aarch64-sve.exp
@@ -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
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp b/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
index fcff0d21899..28d61555ff2 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/aarch64-sve2.exp
@@ -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
diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp
index a36b30da7ea..e9119f02d65 100644
--- a/gcc/testsuite/lib/gcc-defs.exp
+++ b/gcc/testsuite/lib/gcc-defs.exp
@@ -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
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-15 15:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 15:18 [gcc r11-8196] Make SVE tests work with --with-cpu Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).