The following exposes VECT_ADDITIONAL_FLAGS to check_vect_support_and_set_flags
and makes its elements pairs of dg-do-what-default and an option.  For
x86 this adds -mavx2 as proof-of-concept.  Ideally we'd have effective
target checks for -march=x86-64-v[34], but we don't.

I'm posting this for feedback on the TCL - there doesn't seem to be
a documented minimum version.  I have TCL 8.6 where the chosen way
to concatenate two lists works ([concat ..] somehow does not).

Any feedback on this part?

The vect.exp testsuite is not yet clean with -mavx2, I am working on
that though.

Thanks,
Richard.

        * gcc.dg/vect/vect.exp: Make VECT_ADDITIONAL_FLAGS global
        and a list of pairs specifying default dg-do and option.
        * lib/target-supports.exp (check_vect_support_and_set_flags):
        For x86 add -mavx to the set of VECT_ADDITIONAL_FLAGS.
---
 gcc/testsuite/gcc.dg/vect/vect.exp    | 17 +++++++++++++----
 gcc/testsuite/lib/target-supports.exp |  8 ++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/vect.exp 
b/gcc/testsuite/gcc.dg/vect/vect.exp
index 025c3360c0d..dacf7b8c44c 100644
--- a/gcc/testsuite/gcc.dg/vect/vect.exp
+++ b/gcc/testsuite/gcc.dg/vect/vect.exp
@@ -29,6 +29,9 @@ set DEFAULT_VECTCFLAGS ""
 global EFFECTIVE_TARGETS
 set EFFECTIVE_TARGETS ""
 
+global VECT_ADDITIONAL_FLAGS
+set VECT_ADDITIONAL_FLAGS [list]
+
 # If the target system supports vector instructions, the default action
 # for a test is 'run', otherwise it's 'compile'.  Save current default.
 # Executing vector instructions on a system without hardware vector support
@@ -67,12 +70,18 @@ set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
 lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" 
 lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
 
-# Main loop.
-set VECT_ADDITIONAL_FLAGS [list ""]
+# We iterate over VECT_ADDITIONAL_FLAGS, first the default flags, then
+# possibly check_vect_support_and_set_flags injected and then with LTO
+set VECT_ADDITIONAL_FLAGS [list [list ${dg-do-what-default} ""] \
+       {*}$VECT_ADDITIONAL_FLAGS]
 if { [check_effective_target_lto] } {
-    lappend VECT_ADDITIONAL_FLAGS "-flto -ffat-lto-objects"
+    lappend VECT_ADDITIONAL_FLAGS [list ${dg-do-what-default} "-flto 
-ffat-lto-objects"]
 }
-foreach flags $VECT_ADDITIONAL_FLAGS {
+
+# Main loop.
+foreach optset $VECT_ADDITIONAL_FLAGS {
+    set dg-do-what-default [lindex $optset 0]
+    set flags [lindex $optset 1]
     et-dg-runtest dg-runtest [lsort \
        [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \
        $flags $DEFAULT_VECTCFLAGS
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index c8791827556..b3f21558871 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -12510,6 +12510,7 @@ proc check_vect_support_and_set_flags { } {
     global DEFAULT_VECTCFLAGS
     global dg-do-what-default
     global EFFECTIVE_TARGETS
+    global VECT_ADDITIONAL_FLAGS
 
     if [istarget powerpc*-*-*] {
        # Skip targets not supporting -maltivec.
@@ -12548,6 +12549,13 @@ proc check_vect_support_and_set_flags { } {
        } else {
            set dg-do-what-default compile
        }
+       if { [check_effective_target_avx2] } {
+          if { [check_effective_target_avx2_runtime] } {
+            lappend VECT_ADDITIONAL_FLAGS [list run "-mavx2"]
+          } else {
+            lappend VECT_ADDITIONAL_FLAGS [list compile "-mavx2"]
+          }
+       }
     } elseif { [istarget mips*-*-*]
               && [check_effective_target_nomips16] } {
        if { [check_effective_target_mpaired_single "-mpaired-single"] } {
-- 
2.51.0

Reply via email to