1# Copyright (C) 1997-2018 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
21load_lib clearcap.exp
22
23# Set up flags used for tests that don't specify options.
24global DEFAULT_VECTCFLAGS
25set DEFAULT_VECTCFLAGS ""
26
27# Set up a list of effective targets to run vector tests for all supported
28# targets.
29global EFFECTIVE_TARGETS
30set EFFECTIVE_TARGETS ""
31
32# If the target system supports vector instructions, the default action
33# for a test is 'run', otherwise it's 'compile'.  Save current default.
34# Executing vector instructions on a system without hardware vector support
35# is also disabled by a call to check_vect, but disabling execution here is
36# more efficient.
37global dg-do-what-default
38set save-dg-do-what-default ${dg-do-what-default}
39
40# Skip these tests for targets that do not support generating vector
41# code.  Set additional target-dependent vector flags, which can be
42# overridden by using dg-options in individual tests.
43if ![check_vect_support_and_set_flags] {
44    return
45}
46
47# These flags are used for all targets.
48lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-vect-cost-model" "-fno-common"
49
50# Initialize `dg'.
51dg-init
52clearcap-init
53
54global VEC_FLAGS
55set VEC_FLAGS $DEFAULT_VECTCFLAGS
56
57global O1_VECTCFLAGS
58set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
59lappend O1_VECTCFLAGS "-O1"
60lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
61
62global O_VECTCFLAGS
63set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
64lappend O_VECTCFLAGS "-O"
65lappend O_VECTCFLAGS "-fdump-tree-vect-details"
66
67lappend DEFAULT_VECTCFLAGS "-O2"
68
69# Tests that should be run without generating dump info
70et-dg-runtest dg-runtest [lsort \
71	[glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \
72	"" $DEFAULT_VECTCFLAGS
73
74# "-O -fdump-tree-veclower2"
75lappend VEC_FLAGS "-O" "-fdump-tree-veclower2"
76et-dg-runtest dg-runtest [lsort [glob -nocomplain \
77	$srcdir/$subdir/vec-scal-*.\[cS\]]] \
78	"" $VEC_FLAGS
79
80set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
81
82lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
83lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
84
85# Main loop.
86set VECT_ADDITIONAL_FLAGS [list ""]
87if { [check_effective_target_lto] } {
88    lappend VECT_ADDITIONAL_FLAGS "-flto -ffat-lto-objects"
89}
90foreach flags $VECT_ADDITIONAL_FLAGS {
91    et-dg-runtest dg-runtest [lsort \
92	[glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \
93	$flags $DEFAULT_VECTCFLAGS
94    et-dg-runtest dg-runtest [lsort \
95	[glob -nocomplain $srcdir/$subdir/vect-*.\[cS\]]] \
96	$flags $DEFAULT_VECTCFLAGS
97    et-dg-runtest dg-runtest [lsort \
98	[glob -nocomplain $srcdir/$subdir/slp-*.\[cS\]]] \
99	$flags $DEFAULT_VECTCFLAGS
100    et-dg-runtest dg-runtest [lsort \
101	[glob -nocomplain $srcdir/$subdir/bb-slp*.\[cS\]]] \
102	$flags $VECT_SLP_CFLAGS
103}
104
105#### Tests with special options
106global SAVED_DEFAULT_VECTCFLAGS
107set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
108set SAVED_VECT_SLP_CFLAGS $VECT_SLP_CFLAGS
109
110# --param vect-max-version-for-alias-checks=0 tests
111set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
112lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
113et-dg-runtest dg-runtest [lsort \
114	[glob -nocomplain $srcdir/$subdir/no-vfa-*.\[cS\]]] \
115	"" $DEFAULT_VECTCFLAGS
116
117# -ffast-math tests
118set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
119lappend DEFAULT_VECTCFLAGS "-ffast-math"
120et-dg-runtest dg-runtest [lsort \
121	[glob -nocomplain $srcdir/$subdir/fast-math-\[ipsv\]*.\[cS\]]] \
122	"" $DEFAULT_VECTCFLAGS
123
124# -ffast-math SLP tests
125set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
126lappend VECT_SLP_CFLAGS "-ffast-math"
127et-dg-runtest dg-runtest [lsort \
128	[glob -nocomplain $srcdir/$subdir/fast-math-bb-slp-*.\[cS\]]] \
129	"" $VECT_SLP_CFLAGS
130
131# -fno-fast-math tests
132set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
133lappend DEFAULT_VECTCFLAGS "-fno-fast-math"
134et-dg-runtest dg-runtest [lsort \
135	[glob -nocomplain $srcdir/$subdir/no-fast-math-*.\[cS\]]] \
136	"" $DEFAULT_VECTCFLAGS
137
138# -fno-math-errno tests
139set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
140lappend DEFAULT_VECTCFLAGS "-fno-math-errno"
141et-dg-runtest dg-runtest [lsort \
142	[glob -nocomplain $srcdir/$subdir/no-math-errno-*.\[cS\]]] \
143	"" $DEFAULT_VECTCFLAGS
144
145# -fwrapv tests
146set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
147lappend DEFAULT_VECTCFLAGS "-fwrapv"
148et-dg-runtest dg-runtest [lsort \
149	[glob -nocomplain $srcdir/$subdir/wrapv-*.\[cS\]]] \
150	"" $DEFAULT_VECTCFLAGS
151
152# -ftrapv tests
153set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
154lappend DEFAULT_VECTCFLAGS "-ftrapv"
155et-dg-runtest dg-runtest [lsort \
156	[glob -nocomplain $srcdir/$subdir/trapv-*.\[cS\]]] \
157	"" $DEFAULT_VECTCFLAGS
158
159# -fno-tree-dce tests
160set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
161lappend DEFAULT_VECTCFLAGS "-fno-tree-dce"
162et-dg-runtest dg-runtest [lsort \
163	[glob -nocomplain $srcdir/$subdir/no-tree-dce-*.\[cS\]]] \
164	"" $DEFAULT_VECTCFLAGS
165
166# -fsection-anchors tests
167set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
168lappend DEFAULT_VECTCFLAGS "-fsection-anchors"
169et-dg-runtest dg-runtest [lsort \
170	[glob -nocomplain $srcdir/$subdir/section-anchors-*.\[cS\]]] \
171	"" $DEFAULT_VECTCFLAGS
172
173# alignment-sensitive -fsection-anchors tests
174set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
175lappend DEFAULT_VECTCFLAGS "-fsection-anchors" \
176	"-fdump-ipa-increase_alignment-details"
177et-dg-runtest dg-runtest [lsort \
178	[glob -nocomplain $srcdir/$subdir/aligned-section-anchors-*.\[cS\]]] \
179	"" $DEFAULT_VECTCFLAGS
180
181# -fno-section-anchors tests
182set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
183lappend DEFAULT_VECTCFLAGS "-fno-section-anchors"
184et-dg-runtest dg-runtest [lsort \
185	[glob -nocomplain $srcdir/$subdir/no-section-anchors-*.\[cS\]]] \
186	"" $DEFAULT_VECTCFLAGS
187
188# -funswitch-loops tests
189set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
190lappend DEFAULT_VECTCFLAGS "-funswitch-loops"
191et-dg-runtest dg-runtest [lsort \
192	[glob -nocomplain $srcdir/$subdir/unswitch-loops-*.\[cS\]]] \
193	"" $DEFAULT_VECTCFLAGS
194
195# -fno-trapping-math tests
196set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
197lappend DEFAULT_VECTCFLAGS "-fno-trapping-math"
198et-dg-runtest dg-runtest [lsort \
199	[glob -nocomplain $srcdir/$subdir/no-trapping-math-*.\[cS\]]] \
200	"" $DEFAULT_VECTCFLAGS
201
202# -fno-tree-scev-cprop
203set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
204lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
205et-dg-runtest dg-runtest [lsort \
206	[glob -nocomplain $srcdir/$subdir/no-scevccp-vect-*.\[cS\]]] \
207	"" $DEFAULT_VECTCFLAGS
208
209# -fno-tree-scev-cprop
210set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
211lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
212et-dg-runtest dg-runtest [lsort \
213	[glob -nocomplain $srcdir/$subdir/no-scevccp-pr*.\[cS\]]] \
214	"" $DEFAULT_VECTCFLAGS
215
216# -fno-tree-scev-cprop
217set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
218lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
219et-dg-runtest dg-runtest [lsort \
220	[glob -nocomplain $srcdir/$subdir/no-scevccp-outer-*.\[cS\]]] \
221	"" $DEFAULT_VECTCFLAGS
222
223# -fno-tree-scev-cprop -fno-tree-reassoc
224set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
225lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" "-fno-tree-reassoc"
226et-dg-runtest dg-runtest [lsort \
227	[glob -nocomplain $srcdir/$subdir/no-scevccp-noreassoc-*.\[cS\]]] \
228	"" $DEFAULT_VECTCFLAGS
229
230# -fno-tree-scev-cprop
231set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
232lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop"
233et-dg-runtest dg-runtest [lsort \
234	[glob -nocomplain $srcdir/$subdir/no-scevccp-slp-*.\[cS\]]] \
235	"" $DEFAULT_VECTCFLAGS
236
237# -fno-tree-dominator-opts
238set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
239lappend DEFAULT_VECTCFLAGS "-fno-tree-dominator-opts"
240et-dg-runtest dg-runtest [lsort \
241	[glob -nocomplain $srcdir/$subdir/no-tree-dom-*.\[cS\]]] \
242	"" $DEFAULT_VECTCFLAGS
243
244# -fno-tree-pre
245set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
246lappend DEFAULT_VECTCFLAGS "-fno-tree-pre"
247et-dg-runtest dg-runtest [lsort \
248	[glob -nocomplain $srcdir/$subdir/no-tree-pre-*.\[cS\]]] \
249	"" $DEFAULT_VECTCFLAGS
250
251# With -Os
252set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
253lappend DEFAULT_VECTCFLAGS "-Os"
254et-dg-runtest dg-runtest [lsort \
255	[glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]] \
256	"" $DEFAULT_VECTCFLAGS
257
258# With --param ggc-min-expand=0 --param ggc-min-heapsize=0
259set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
260lappend DEFAULT_VECTCFLAGS "--param" "ggc-min-expand=0" "--param" "ggc-min-heapsize=0"
261et-dg-runtest dg-runtest [lsort \
262	[glob -nocomplain $srcdir/$subdir/ggc-*.\[cS\]]] \
263	"" $DEFAULT_VECTCFLAGS
264
265# -ftree-loop-if-convert-stores
266set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
267lappend DEFAULT_VECTCFLAGS "-ftree-loop-if-convert-stores"
268et-dg-runtest dg-runtest [lsort \
269	[glob -nocomplain $srcdir/$subdir/if-cvt-stores-vect-*.\[cS\]]] \
270	"" $DEFAULT_VECTCFLAGS
271
272# With -O3.
273# Don't allow IPA cloning, because it throws our counts out of whack.
274set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
275lappend DEFAULT_VECTCFLAGS "-O3" "-fno-ipa-cp-clone"
276if  [istarget "spu-*-*"] {
277  lappend DEFAULT_VECTCFLAGS "-funroll-loops"
278}
279
280et-dg-runtest dg-runtest [lsort \
281	[glob -nocomplain $srcdir/$subdir/O3-*.\[cS\]]] \
282	"" $DEFAULT_VECTCFLAGS
283
284# With -O1
285et-dg-runtest dg-runtest [lsort \
286	[glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]] \
287	"" $O1_VECTCFLAGS
288
289# With -O
290et-dg-runtest dg-runtest [lsort \
291	[glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]] \
292	"" $O_VECTCFLAGS
293
294# -fno-tree-reassoc
295set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
296lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
297et-dg-runtest dg-runtest [lsort \
298	[glob -nocomplain $srcdir/$subdir/no-tree-reassoc-bb-slp-*.\[cS\]]] \
299	"" $VECT_SLP_CFLAGS
300
301# -fno-tree-fre
302set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
303lappend DEFAULT_VECTCFLAGS "-fno-tree-fre"
304et-dg-runtest dg-runtest [lsort \
305	[glob -nocomplain $srcdir/$subdir/no-tree-fre-*.\[cS\]]] \
306	"" $DEFAULT_VECTCFLAGS
307
308# -fno-tree-fre -fno-tree-pre
309set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
310lappend DEFAULT_VECTCFLAGS "-fno-tree-fre" "-fno-tree-pre"
311et-dg-runtest dg-runtest [lsort \
312	[glob -nocomplain $srcdir/$subdir/no-fre-pre*.\[cS\]]] \
313	"" $DEFAULT_VECTCFLAGS
314
315# -fno-tree-sra
316set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
317lappend VECT_SLP_CFLAGS "-fno-tree-sra"
318et-dg-runtest dg-runtest [lsort \
319	[glob -nocomplain $srcdir/$subdir/no-tree-sra-bb-slp-*.\[cS\]]] \
320	"" $VECT_SLP_CFLAGS
321
322
323# Clean up.
324set dg-do-what-default ${save-dg-do-what-default}
325
326# All done.
327clearcap-finish
328dg-finish
329