sourcebuild.texi (Effective-Target Keywords): Document 3dnow, sse3, sse2.
[gcc.git] / gcc / testsuite / gcc.dg / vect / vect.exp
1 # Copyright (C) 1997, 2004, 2005, 2006, 2007, 2008, 2010
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
17
18 # GCC testsuite that uses the `dg.exp' driver.
19
20 # Load support procs.
21 load_lib gcc-dg.exp
22
23 # Set up flags used for tests that don't specify options.
24 set DEFAULT_VECTCFLAGS ""
25
26 # These flags are used for all targets.
27 lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-vect-cost-model"
28
29 # If the target system supports vector instructions, the default action
30 # for a test is 'run', otherwise it's 'compile'. Save current default.
31 # Executing vector instructions on a system without hardware vector support
32 # is also disabled by a call to check_vect, but disabling execution here is
33 # more efficient.
34 global dg-do-what-default
35 set save-dg-do-what-default ${dg-do-what-default}
36
37 # Skip these tests for targets that do not support generating vector
38 # code. Set additional target-dependent vector flags, which can be
39 # overridden by using dg-options in individual tests.
40 if [istarget "powerpc-*paired*"] {
41 lappend DEFAULT_VECTCFLAGS "-mpaired"
42 if [check_750cl_hw_available] {
43 set dg-do-what-default run
44 } else {
45 set dg-do-what-default compile
46 }
47 } elseif [istarget "powerpc*-*-*"] {
48 # Skip targets not supporting -maltivec.
49 if ![is-effective-target powerpc_altivec_ok] {
50 return
51 }
52
53 lappend DEFAULT_VECTCFLAGS "-maltivec"
54 if [check_vsx_hw_available] {
55 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
56 }
57
58 if [check_vmx_hw_available] {
59 set dg-do-what-default run
60 } else {
61 if [is-effective-target ilp32] {
62 # Specify a cpu that supports VMX for compile-only tests.
63 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
64 }
65 set dg-do-what-default compile
66 }
67 } elseif { [istarget "spu-*-*"] } {
68 set dg-do-what-default run
69 } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
70 if { ![check_effective_target_sse2] } then {
71 return
72 }
73 lappend DEFAULT_VECTCFLAGS "-msse2"
74 if [check_sse2_hw_available] {
75 set dg-do-what-default run
76 } else {
77 set dg-do-what-default compile
78 }
79 } elseif { [istarget "mips*-*-*"]
80 && [check_effective_target_mpaired_single]
81 && [check_effective_target_nomips16] } {
82 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
83 set dg-do-what-default run
84 } elseif [istarget "sparc*-*-*"] {
85 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
86 if [check_effective_target_ultrasparc_hw] {
87 set dg-do-what-default run
88 } else {
89 set dg-do-what-default compile
90 }
91 } elseif [istarget "alpha*-*-*"] {
92 # Alpha's vectorization capabilities are extremely limited.
93 # It's more effort than its worth disabling all of the tests
94 # that it cannot pass. But if you actually want to see what
95 # does work, command out the return.
96 return
97
98 lappend DEFAULT_VECTCFLAGS "-mmax"
99 if [check_alpha_max_hw_available] {
100 set dg-do-what-default run
101 } else {
102 set dg-do-what-default compile
103 }
104 } elseif [istarget "ia64-*-*"] {
105 set dg-do-what-default run
106 } elseif [is-effective-target arm_neon_ok] {
107 lappend DEFAULT_VECTCFLAGS "-mfpu=neon" "-mfloat-abi=softfp"
108 if [is-effective-target arm_neon_hw] {
109 set dg-do-what-default run
110 } else {
111 set dg-do-what-default compile
112 }
113 } else {
114 return
115 }
116
117 # Initialize `dg'.
118 dg-init
119
120 global O1_VECTCFLAGS
121 set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
122 lappend O1_VECTCFLAGS "-O1"
123 lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
124
125 lappend DEFAULT_VECTCFLAGS "-O2"
126
127 # Tests that should be run without generating dump info
128 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \
129 "" $DEFAULT_VECTCFLAGS
130
131 set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
132
133 lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
134 lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
135
136 # Main loop.
137 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \
138 "" $DEFAULT_VECTCFLAGS
139 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vect-*.\[cS\]]] \
140 "" $DEFAULT_VECTCFLAGS
141 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-*.\[cS\]]] \
142 "" $DEFAULT_VECTCFLAGS
143 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/bb-slp*.\[cS\]]] \
144 "" $VECT_SLP_CFLAGS
145
146
147 #### Tests with special options
148 global SAVED_DEFAULT_VECTCFLAGS
149 set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
150 set SAVED_VECT_SLP_CFLAGS $VECT_SLP_CFLAGS
151
152 # --param vect-max-version-for-alias-checks=0 tests
153 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
154 lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
155 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[cS\]]] \
156 "" $DEFAULT_VECTCFLAGS
157
158 # -ffast-math tests
159 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
160 lappend DEFAULT_VECTCFLAGS "-ffast-math"
161 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-*.\[cS\]]] \
162 "" $DEFAULT_VECTCFLAGS
163
164 # -fno-math-errno tests
165 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
166 lappend DEFAULT_VECTCFLAGS "-fno-math-errno"
167 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-math-errno-*.\[cS\]]] \
168 "" $DEFAULT_VECTCFLAGS
169
170 # -fwrapv tests
171 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
172 lappend DEFAULT_VECTCFLAGS "-fwrapv"
173 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/wrapv-*.\[cS\]]] \
174 "" $DEFAULT_VECTCFLAGS
175
176 # -ftrapv tests
177 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
178 lappend DEFAULT_VECTCFLAGS "-ftrapv"
179 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/trapv-*.\[cS\]]] \
180 "" $DEFAULT_VECTCFLAGS
181
182 # -fdump-tree-dceloop-details tests
183 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
184 lappend DEFAULT_VECTCFLAGS "-fdump-tree-dceloop-details"
185 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dump-tree-dceloop-*.\[cS\]]] \
186 "" $DEFAULT_VECTCFLAGS
187
188 # -fno-tree-dce tests
189 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
190 lappend DEFAULT_VECTCFLAGS "-fno-tree-dce"
191 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-dce-*.\[cS\]]] \
192 "" $DEFAULT_VECTCFLAGS
193
194 # -fsection-anchors tests
195 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
196 lappend DEFAULT_VECTCFLAGS "-fsection-anchors"
197 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/section-anchors-*.\[cS\]]] \
198 "" $DEFAULT_VECTCFLAGS
199
200 # alignment-sensitive -fsection-anchors tests
201 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
202 lappend DEFAULT_VECTCFLAGS "-fsection-anchors" "-fdump-ipa-increase_alignment"
203 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/aligned-section-anchors-*.\[cS\]]] \
204 "" $DEFAULT_VECTCFLAGS
205
206 # -fno-section-anchors tests
207 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
208 lappend DEFAULT_VECTCFLAGS "-fno-section-anchors"
209 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-section-anchors-*.\[cS\]]] \
210 "" $DEFAULT_VECTCFLAGS
211
212 # -funswitch-loops tests
213 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
214 lappend DEFAULT_VECTCFLAGS "-funswitch-loops"
215 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/unswitch-loops-*.\[cS\]]] \
216 "" $DEFAULT_VECTCFLAGS
217
218 # -fno-trapping-math tests
219 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
220 lappend DEFAULT_VECTCFLAGS "-fno-trapping-math"
221 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-trapping-math-*.\[cS\]]] \
222 "" $DEFAULT_VECTCFLAGS
223
224 # -fno-tree-scev-cprop
225 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
226 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
227 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-vect-*.\[cS\]]] \
228 "" $DEFAULT_VECTCFLAGS
229
230 # -fno-tree-scev-cprop
231 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
232 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
233 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-outer-*.\[cS\]]] \
234 "" $DEFAULT_VECTCFLAGS
235
236 # -fno-tree-scev-cprop -fno-tree-reassoc
237 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
238 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" "-fno-tree-reassoc"
239 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-noreassoc-*.\[cS\]]] \
240 "" $DEFAULT_VECTCFLAGS
241
242 # -fno-tree-scev-cprop
243 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
244 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
245 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-slp-*.\[cS\]]] \
246 "" $DEFAULT_VECTCFLAGS
247
248 # -fno-tree-dominator-opts
249 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
250 lappend DEFAULT_VECTCFLAGS "-fno-tree-dominator-opts"
251 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-dom-*.\[cS\]]] \
252 "" $DEFAULT_VECTCFLAGS
253
254 # -fno-tree-pre
255 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
256 lappend DEFAULT_VECTCFLAGS "-fno-tree-pre"
257 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-pre-*.\[cS\]]] \
258 "" $DEFAULT_VECTCFLAGS
259
260 # With -Os
261 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
262 lappend DEFAULT_VECTCFLAGS "-Os"
263 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]] \
264 "" $DEFAULT_VECTCFLAGS
265
266 # With --param ggc-min-expand=0 --param ggc-min-heapsize=0
267 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
268 lappend DEFAULT_VECTCFLAGS "--param" "ggc-min-expand=0" "--param" "ggc-min-heapsize=0"
269 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/ggc-*.\[cS\]]] \
270 "" $DEFAULT_VECTCFLAGS
271
272 # With -O3.
273 # Don't allow IPA cloning, because it throws our counts out of whack.
274 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
275 lappend DEFAULT_VECTCFLAGS "-O3" "-fno-ipa-cp-clone"
276 if [istarget "spu-*-*"] {
277 lappend DEFAULT_VECTCFLAGS "-funroll-loops"
278 }
279 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-*.\[cS\]]] \
280 "" $DEFAULT_VECTCFLAGS
281
282 # With -O1
283 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]] \
284 "" $O1_VECTCFLAGS
285
286 # -fno-tree-reassoc
287 set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
288 lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
289 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-reassoc-bb-slp-*.\[cS\]]] \
290 "" $VECT_SLP_CFLAGS
291
292 # Clean up.
293 set dg-do-what-default ${save-dg-do-what-default}
294
295 # All done.
296 dg-finish