1# Copyright (C) 1997-2013 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# These flags are used for all targets.
28lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fno-vect-cost-model" \
29  "-fdump-tree-vect-details"
30
31# If the target system supports vector instructions, the default action
32# for a test is 'run', otherwise it's 'compile'.  Save current default.
33# Executing vector instructions on a system without hardware vector support
34# is also disabled by a call to check_vect, but disabling execution here is
35# more efficient.
36global dg-do-what-default
37set save-dg-do-what-default ${dg-do-what-default}
38
39# Skip these tests for targets that do not support generating vector
40# code.  Set additional target-dependent vector flags, which can be
41# overridden by using dg-options in individual tests.
42if ![check_vect_support_and_set_flags] {
43    return
44}
45
46# Initialize `dg'.
47dg-init
48
49# Main loop.
50gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vect-*.\[fF\]{,90,95,03,08} ]] $DEFAULT_VECTCFLAGS
51gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[fF\]{,90,95,03,08} ]] $DEFAULT_VECTCFLAGS
52
53#### Tests with special options
54global SAVED_DEFAULT_VECTCFLAGS
55set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
56
57# -ffast-math tests
58set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
59lappend DEFAULT_VECTCFLAGS "-ffast-math"
60dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-*.\[fF\]{,90,95,03,08} ]]  \
61        "" $DEFAULT_VECTCFLAGS
62
63# -ffast-math tests
64set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
65lappend DEFAULT_VECTCFLAGS "-ffast-math" "-fdefault-real-8"
66dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-real8*.\[fF\]{,90,95,03,08} ]]  \
67        "" $DEFAULT_VECTCFLAGS
68
69# -fvect-cost-model tests
70set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
71lappend DEFAULT_VECTCFLAGS "-fvect-cost-model"
72dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/cost-model-*.\[fF\]{,90,95,03,08} ]]  \
73        "" $DEFAULT_VECTCFLAGS
74
75# --param vect-max-version-for-alias-checks=0 tests
76set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
77lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
78dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[fF\]{,90,95,03,08} ]]  \
79        "" $DEFAULT_VECTCFLAGS
80
81# With -O3
82set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
83lappend DEFAULT_VECTCFLAGS "-O3"
84dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-*.\[fF\]{,90,95,03,08} ]]  \
85        "" $DEFAULT_VECTCFLAGS
86
87# With -Ofast
88set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
89lappend DEFAULT_VECTCFLAGS "-Ofast"
90dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Ofast-*.\[fF\]{,90,95,03,08} ]]  \
91        "" $DEFAULT_VECTCFLAGS
92
93# With -fno-tree-copy-prop -fno-tree-fre -O3
94set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
95lappend DEFAULT_VECTCFLAGS "-fno-tree-copy-prop" "-fno-tree-fre" "-O3"
96dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-fre-no-copy-prop-O3-*.\[fF\]{,90,95,03,08} ]]  \
97        "" $DEFAULT_VECTCFLAGS
98
99# Clean up.
100set dg-do-what-default ${save-dg-do-what-default}
101
102# All done.
103dg-finish
104