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 gcc-dg.exp
21
22# Exit immediately if this isn't a x86 target.
23if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
24  return
25}
26
27# Set up flags used for tests that don't specify options.
28set DEFAULT_VECTCFLAGS ""
29
30# These flags are used for all targets.
31lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fvect-cost-model"
32
33# If the target system supports vector instructions, the default action
34# for a test is 'run', otherwise it's 'compile'.  Save current default.
35# Executing vector instructions on a system without hardware vector support
36# is also disabled by a call to check_vect, but disabling execution here is
37# more efficient.
38global dg-do-what-default
39set save-dg-do-what-default ${dg-do-what-default}
40
41if { ![check_effective_target_sse2] } then {
42  return
43}
44lappend DEFAULT_VECTCFLAGS "-msse2"
45if [check_sse2_hw_available] {
46    set dg-do-what-default run
47} else {
48    set dg-do-what-default compile
49}
50
51# Initialize `dg'.
52dg-init
53
54lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
55
56# Main loop.
57dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-vect-*.\[cS\]]]  \
58	"" $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"
67dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-fast-math-vect*.\[cS\]]]  \
68	"" $DEFAULT_VECTCFLAGS
69
70# Clean up.
71set dg-do-what-default ${save-dg-do-what-default}
72
73# All done.
74dg-finish
75