OSDN Git Service

* lib/target-supports.exp (check_avx_hw_available): New procedure.
[pf3gnuchains/gcc-fork.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     lappend DEFAULT_VECTCFLAGS "-msse2"
71     if { [check_effective_target_sse2_runtime] } {
72         set dg-do-what-default run
73     } else {
74         set dg-do-what-default compile
75     }
76 } elseif { [istarget "mips*-*-*"]
77            && [check_effective_target_mpaired_single]
78            && [check_effective_target_nomips16] } {
79     lappend DEFAULT_VECTCFLAGS "-mpaired-single"
80     set dg-do-what-default run
81 } elseif [istarget "sparc*-*-*"] {
82     lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
83     if [check_effective_target_ultrasparc_hw] {
84         set dg-do-what-default run
85     } else {
86         set dg-do-what-default compile
87     }
88 } elseif [istarget "alpha*-*-*"] {
89     # Alpha's vectorization capabilities are extremely limited.
90     # It's more effort than its worth disabling all of the tests
91     # that it cannot pass.  But if you actually want to see what
92     # does work, command out the return.
93     return
94
95     lappend DEFAULT_VECTCFLAGS "-mmax"
96     if [check_alpha_max_hw_available] {
97         set dg-do-what-default run
98     } else {
99         set dg-do-what-default compile
100     }
101 } elseif [istarget "ia64-*-*"] {
102     set dg-do-what-default run
103 } elseif [is-effective-target arm_neon_ok] {
104     eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
105     # NEON does not support denormals, so is not used for vectorization by
106     # default to avoid loss of precision.  We must pass -ffast-math to test
107     # vectorization of float operations.
108     lappend DEFAULT_VECTCFLAGS "-ffast-math"
109     if [is-effective-target arm_neon_hw] {
110       set dg-do-what-default run
111     } else {
112       set dg-do-what-default compile
113     }
114 } else {
115     return
116 }
117
118 # Initialize `dg'.
119 dg-init
120
121 global O1_VECTCFLAGS
122 set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
123 lappend O1_VECTCFLAGS "-O1"
124 lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
125
126 lappend DEFAULT_VECTCFLAGS "-O2"
127
128 # Tests that should be run without generating dump info
129 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]]  \
130         "" $DEFAULT_VECTCFLAGS
131
132 set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
133
134 lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" 
135 lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
136
137 # Main loop.
138 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]]  \
139         "" $DEFAULT_VECTCFLAGS
140 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vect-*.\[cS\]]]  \
141         "" $DEFAULT_VECTCFLAGS
142 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-*.\[cS\]]]  \
143         "" $DEFAULT_VECTCFLAGS
144 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/bb-slp*.\[cS\]]]  \
145         "" $VECT_SLP_CFLAGS
146
147
148 #### Tests with special options
149 global SAVED_DEFAULT_VECTCFLAGS
150 set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
151 set SAVED_VECT_SLP_CFLAGS $VECT_SLP_CFLAGS
152
153 # --param vect-max-version-for-alias-checks=0 tests
154 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
155 lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
156 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[cS\]]]  \
157         "" $DEFAULT_VECTCFLAGS
158
159 # -ffast-math tests
160 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
161 lappend DEFAULT_VECTCFLAGS "-ffast-math"
162 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-*.\[cS\]]]  \
163         "" $DEFAULT_VECTCFLAGS
164
165 # -fno-math-errno tests
166 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
167 lappend DEFAULT_VECTCFLAGS "-fno-math-errno"
168 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-math-errno-*.\[cS\]]]  \
169         "" $DEFAULT_VECTCFLAGS
170
171 # -fwrapv tests
172 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
173 lappend DEFAULT_VECTCFLAGS "-fwrapv"
174 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/wrapv-*.\[cS\]]]  \
175         "" $DEFAULT_VECTCFLAGS
176
177 # -ftrapv tests
178 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
179 lappend DEFAULT_VECTCFLAGS "-ftrapv"
180 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/trapv-*.\[cS\]]]  \
181         "" $DEFAULT_VECTCFLAGS
182
183 # -fdump-tree-dceloop-details tests
184 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
185 lappend DEFAULT_VECTCFLAGS "-fdump-tree-dceloop-details"
186 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dump-tree-dceloop-*.\[cS\]]]  \
187         "" $DEFAULT_VECTCFLAGS
188
189 # -fno-tree-dce tests
190 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
191 lappend DEFAULT_VECTCFLAGS "-fno-tree-dce"
192 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-dce-*.\[cS\]]]  \
193         "" $DEFAULT_VECTCFLAGS
194
195 # -fsection-anchors tests
196 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
197 lappend DEFAULT_VECTCFLAGS "-fsection-anchors"
198 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/section-anchors-*.\[cS\]]]  \
199         "" $DEFAULT_VECTCFLAGS
200
201 # alignment-sensitive -fsection-anchors tests
202 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
203 lappend DEFAULT_VECTCFLAGS "-fsection-anchors" "-fdump-ipa-increase_alignment"
204 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/aligned-section-anchors-*.\[cS\]]]  \
205         "" $DEFAULT_VECTCFLAGS
206
207 # -fno-section-anchors tests
208 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
209 lappend DEFAULT_VECTCFLAGS "-fno-section-anchors"
210 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-section-anchors-*.\[cS\]]]  \
211         "" $DEFAULT_VECTCFLAGS
212
213 # -funswitch-loops tests
214 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
215 lappend DEFAULT_VECTCFLAGS "-funswitch-loops"
216 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/unswitch-loops-*.\[cS\]]]  \
217         "" $DEFAULT_VECTCFLAGS
218
219 # -fno-trapping-math tests
220 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
221 lappend DEFAULT_VECTCFLAGS "-fno-trapping-math"
222 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-trapping-math-*.\[cS\]]]  \
223         "" $DEFAULT_VECTCFLAGS
224
225 # -fno-tree-scev-cprop
226 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
227 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
228 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-vect-*.\[cS\]]]  \
229         "" $DEFAULT_VECTCFLAGS
230
231 # -fno-tree-scev-cprop
232 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
233 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
234 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-outer-*.\[cS\]]]  \
235         "" $DEFAULT_VECTCFLAGS
236
237 # -fno-tree-scev-cprop -fno-tree-reassoc
238 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
239 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" "-fno-tree-reassoc"
240 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-noreassoc-*.\[cS\]]]  \
241         "" $DEFAULT_VECTCFLAGS
242
243 # -fno-tree-scev-cprop
244 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
245 lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
246 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-scevccp-slp-*.\[cS\]]]  \
247         "" $DEFAULT_VECTCFLAGS
248
249 # -fno-tree-dominator-opts
250 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
251 lappend DEFAULT_VECTCFLAGS "-fno-tree-dominator-opts"
252 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-dom-*.\[cS\]]]  \
253         "" $DEFAULT_VECTCFLAGS
254
255 # -fno-tree-pre
256 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
257 lappend DEFAULT_VECTCFLAGS "-fno-tree-pre"
258 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-pre-*.\[cS\]]]  \
259         "" $DEFAULT_VECTCFLAGS
260
261 # With -Os
262 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
263 lappend DEFAULT_VECTCFLAGS "-Os"
264 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]]  \
265         "" $DEFAULT_VECTCFLAGS
266
267 # With --param ggc-min-expand=0 --param ggc-min-heapsize=0 
268 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
269 lappend DEFAULT_VECTCFLAGS "--param" "ggc-min-expand=0" "--param" "ggc-min-heapsize=0"
270 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/ggc-*.\[cS\]]]  \
271         "" $DEFAULT_VECTCFLAGS
272
273 # With -O3.
274 # Don't allow IPA cloning, because it throws our counts out of whack.
275 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
276 lappend DEFAULT_VECTCFLAGS "-O3" "-fno-ipa-cp-clone"
277 if  [istarget "spu-*-*"] {
278   lappend DEFAULT_VECTCFLAGS "-funroll-loops"
279 }
280 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-*.\[cS\]]]  \
281         "" $DEFAULT_VECTCFLAGS
282
283 # With -O1
284 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
285         "" $O1_VECTCFLAGS
286
287 # -fno-tree-reassoc
288 set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
289 lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
290 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-reassoc-bb-slp-*.\[cS\]]]  \
291         "" $VECT_SLP_CFLAGS
292
293 # Clean up.
294 set dg-do-what-default ${save-dg-do-what-default}
295
296 # All done.
297 dg-finish