execute.exp: Change copyright header to refer to version 3 of the GNU General Public...
[gcc.git] / gcc / testsuite / gcc.dg / vect / vect.exp
1 # Copyright (C) 1997, 2004, 2005, 2006, 2007 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.
20 load_lib gcc-dg.exp
21
22 # Set up flags used for tests that don't specify options.
23 set DEFAULT_VECTCFLAGS ""
24
25 # These flags are used for all targets.
26 lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize"
27
28 # If the target system supports vector instructions, the default action
29 # for a test is 'run', otherwise it's 'compile'. Save current default.
30 # Executing vector instructions on a system without hardware vector support
31 # is also disabled by a call to check_vect, but disabling execution here is
32 # more efficient.
33 global dg-do-what-default
34 set save-dg-do-what-default ${dg-do-what-default}
35
36 # Skip these tests for targets that do not support generating vector
37 # code. Set additional target-dependent vector flags, which can be
38 # overridden by using dg-options in individual tests.
39 if [istarget "powerpc*-*-*"] {
40 # Skip targets not supporting -maltivec.
41 if ![is-effective-target powerpc_altivec_ok] {
42 return
43 }
44
45 lappend DEFAULT_VECTCFLAGS "-maltivec"
46 if [check_vmx_hw_available] {
47 set dg-do-what-default run
48 } else {
49 if [is-effective-target ilp32] {
50 # Specify a cpu that supports VMX for compile-only tests.
51 lappend DEFAULT_VECTCFLAGS "-mcpu=7400"
52 }
53 set dg-do-what-default compile
54 }
55 } elseif { [istarget "spu-*-*"] } {
56 set dg-do-what-default run
57 } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
58 lappend DEFAULT_VECTCFLAGS "-msse2"
59 set dg-do-what-default run
60 } elseif { [istarget "mipsisa64*-*-*"]
61 && [check_effective_target_mpaired_single] } {
62 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
63 set dg-do-what-default run
64 } elseif [istarget "sparc*-*-*"] {
65 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
66 if [check_effective_target_ultrasparc_hw] {
67 set dg-do-what-default run
68 } else {
69 set dg-do-what-default compile
70 }
71 } elseif [istarget "alpha*-*-*"] {
72 # Alpha's vectorization capabilities are extremely limited.
73 # It's more effort than its worth disabling all of the tests
74 # that it cannot pass. But if you actually want to see what
75 # does work, command out the return.
76 return
77
78 lappend DEFAULT_VECTCFLAGS "-mmax"
79 if [check_alpha_max_hw_available] {
80 set dg-do-what-default run
81 } else {
82 set dg-do-what-default compile
83 }
84 } elseif [istarget "ia64-*-*"] {
85 set dg-do-what-default run
86 } elseif [is-effective-target arm_neon_ok] {
87 lappend DEFAULT_VECTCFLAGS "-mfpu=neon" "-mfloat-abi=softfp"
88 if [is-effective-target arm_neon_hw] {
89 set dg-do-what-default run
90 } else {
91 set dg-do-what-default compile
92 }
93 } else {
94 return
95 }
96
97 # Initialize `dg'.
98 dg-init
99
100 # Tests that should be run without generating dump info
101 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \
102 "" $DEFAULT_VECTCFLAGS
103
104 lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
105
106 # Main loop.
107 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \
108 "" $DEFAULT_VECTCFLAGS
109 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vect-*.\[cS\]]] \
110 "" $DEFAULT_VECTCFLAGS
111
112 #### Tests with special options
113 global SAVED_DEFAULT_VECTCFLAGS
114 set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
115
116 # -ffast-math tests
117 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
118 lappend DEFAULT_VECTCFLAGS "-ffast-math"
119 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-vect*.\[cS\]]] \
120 "" $DEFAULT_VECTCFLAGS
121
122 # -fno-math-errno tests
123 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
124 lappend DEFAULT_VECTCFLAGS "-fno-math-errno"
125 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-math-errno-vect*.\[cS\]]] \
126 "" $DEFAULT_VECTCFLAGS
127
128 # -fwrapv tests
129 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
130 lappend DEFAULT_VECTCFLAGS "-fwrapv"
131 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/wrapv-vect*.\[cS\]]] \
132 "" $DEFAULT_VECTCFLAGS
133
134 # -ftrapv tests
135 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
136 lappend DEFAULT_VECTCFLAGS "-ftrapv"
137 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/trapv-vect*.\[cS\]]] \
138 "" $DEFAULT_VECTCFLAGS
139
140 # -fdump-tree-dceloop-details tests
141 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
142 lappend DEFAULT_VECTCFLAGS "-fdump-tree-dceloop-details"
143 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dump-tree-dceloop-*.\[cS\]]] \
144 "" $DEFAULT_VECTCFLAGS
145
146 # -fno-tree-dce tests
147 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
148 lappend DEFAULT_VECTCFLAGS "-fno-tree-dce"
149 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-dce-*.\[cS\]]] \
150 "" $DEFAULT_VECTCFLAGS
151
152 # -fsection-anchors tests
153 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
154 lappend DEFAULT_VECTCFLAGS "-fsection-anchors"
155 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/section-anchors-*.\[cS\]]] \
156 "" $DEFAULT_VECTCFLAGS
157
158 # -fno-section-anchors tests
159 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
160 lappend DEFAULT_VECTCFLAGS "-fno-section-anchors"
161 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-section-anchors-*.\[cS\]]] \
162 "" $DEFAULT_VECTCFLAGS
163
164 # -funswitch-loops tests
165 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
166 lappend DEFAULT_VECTCFLAGS "-funswitch-loops"
167 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/unswitch-loops-*.\[cS\]]] \
168 "" $DEFAULT_VECTCFLAGS
169
170 # -fno-trapping-math tests
171 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
172 lappend DEFAULT_VECTCFLAGS "-fno-trapping-math"
173 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-trapping-math-*.\[cS\]]] \
174 "" $DEFAULT_VECTCFLAGS
175
176 # -fno-tree-scev-cprop
177 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
178 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
179 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-scev-cprop-*.\[cS\]]] \
180 "" $DEFAULT_VECTCFLAGS
181
182 # -fno-tree-dominator-opts
183 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
184 lappend DEFAULT_VECTCFLAGS "-fno-tree-dominator-opts"
185 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-dom-*.\[cS\]]] \
186 "" $DEFAULT_VECTCFLAGS
187
188 # With -Os
189 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
190 lappend DEFAULT_VECTCFLAGS "-Os"
191 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]] \
192 "" $DEFAULT_VECTCFLAGS
193
194 # With -O3
195 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
196 lappend DEFAULT_VECTCFLAGS "-O3"
197 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-vect-*.\[cS\]]] \
198 "" $DEFAULT_VECTCFLAGS
199
200 # Clean up.
201 set dg-do-what-default ${save-dg-do-what-default}
202
203 # All done.
204 dg-finish