1# Copyright (C) 1997-2021 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with GCC; see the file COPYING3.  If not see
15# <http://www.gnu.org/licenses/>.
16
17# GCC testsuite that uses the `dg.exp' driver.
18
19# Load support procs.
20load_lib gfortran-dg.exp
21load_lib target-supports.exp
22
23# Set up flags used for tests that don't specify options.
24global DEFAULT_VECTCFLAGS
25set DEFAULT_VECTCFLAGS ""
26
27# Set up a list of effective targets to run vector tests for all supported
28# targets.
29global EFFECTIVE_TARGETS
30set EFFECTIVE_TARGETS ""
31
32# These flags are used for all targets.
33lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fvect-cost-model=unlimited" \
34  "-fdump-tree-vect-details"
35
36# If the target system supports vector instructions, the default action
37# for a test is 'run', otherwise it's 'compile'.  Save current default.
38# Executing vector instructions on a system without hardware vector support
39# is also disabled by a call to check_vect, but disabling execution here is
40# more efficient.
41global dg-do-what-default
42set save-dg-do-what-default ${dg-do-what-default}
43
44# Skip these tests for targets that do not support generating vector
45# code.  Set additional target-dependent vector flags, which can be
46# overridden by using dg-options in individual tests.
47if ![check_vect_support_and_set_flags] {
48    return
49}
50
51# Initialize `dg'.
52dg-init
53
54# Main loop.
55et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
56	$srcdir/$subdir/vect-*.\[fF\]{,90,95,03,08} ]] "" $DEFAULT_VECTCFLAGS
57et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
58	$srcdir/$subdir/pr*.\[fF\]{,90,95,03,08} ]] "" $DEFAULT_VECTCFLAGS
59
60#### Tests with special options
61global SAVED_DEFAULT_VECTCFLAGS
62set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
63
64# -ffast-math tests
65set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
66lappend DEFAULT_VECTCFLAGS "-ffast-math"
67et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
68	$srcdir/$subdir/fast-math-*.\[fF\]{,90,95,03,08} ]] \
69	"" $DEFAULT_VECTCFLAGS
70
71# -ffast-math tests
72set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
73lappend DEFAULT_VECTCFLAGS "-ffast-math" "-fdefault-real-8"
74et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
75	$srcdir/$subdir/fast-math-real8*.\[fF\]{,90,95,03,08} ]] \
76	"" $DEFAULT_VECTCFLAGS
77
78# -fvect-cost-model tests
79set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
80lappend DEFAULT_VECTCFLAGS "-fvect-cost-model=dynamic"
81et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
82	$srcdir/$subdir/cost-model-*.\[fF\]{,90,95,03,08} ]] \
83	"" $DEFAULT_VECTCFLAGS
84
85# --param vect-max-version-for-alias-checks=0 tests
86set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
87lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
88et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
89	$srcdir/$subdir/no-vfa-*.\[fF\]{,90,95,03,08} ]] \
90	"" $DEFAULT_VECTCFLAGS
91
92# With -O3
93set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
94lappend DEFAULT_VECTCFLAGS "-O3"
95et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
96	$srcdir/$subdir/O3-*.\[fF\]{,90,95,03,08} ]] \
97	"" $DEFAULT_VECTCFLAGS
98
99# With -Ofast
100set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
101lappend DEFAULT_VECTCFLAGS "-Ofast"
102et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
103	$srcdir/$subdir/Ofast-*.\[fF\]{,90,95,03,08} ]] \
104	"" $DEFAULT_VECTCFLAGS
105
106# With -fno-tree-copy-prop -fno-tree-fre -O3
107set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
108lappend DEFAULT_VECTCFLAGS "-fno-tree-copy-prop" "-fno-tree-fre" "-O3"
109et-dg-runtest gfortran-dg-runtest [lsort [glob -nocomplain \
110	$srcdir/$subdir/no-fre-no-copy-prop-O3-*.\[fF\]{,90,95,03,08} ]] \
111	"" $DEFAULT_VECTCFLAGS
112
113# Clean up.
114set dg-do-what-default ${save-dg-do-what-default}
115
116# All done.
117dg-finish
118