1# Copyright (C) 1997-2021 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 powerpc target.
23if { ![istarget powerpc*-*-*] } then {
24  return
25}
26
27# Skip targets not supporting -maltivec.
28if ![is-effective-target powerpc_altivec_ok] {
29  return
30}
31
32# Set up flags used for tests that don't specify options.
33set DEFAULT_VECTCFLAGS ""
34
35# These flags are used for all targets.
36lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fvect-cost-model=dynamic" "-fno-common"
37
38# If the target system supports vector instructions, the default action
39# for a test is 'run', otherwise it's 'compile'.  Save current default.
40# Executing vector instructions on a system without hardware vector support
41# is also disabled by a call to check_vect, but disabling execution here is
42# more efficient.
43global dg-do-what-default
44set save-dg-do-what-default ${dg-do-what-default}
45
46lappend DEFAULT_VECTCFLAGS "-maltivec"
47if [check_vmx_hw_available] {
48    set dg-do-what-default run
49} else {
50    if [is-effective-target ilp32] {
51        # Specify a cpu that supports VMX for compile-only tests.
52        lappend DEFAULT_VECTCFLAGS "-mcpu=970"
53    }
54    set dg-do-what-default compile
55}
56
57# Initialize `dg'.
58dg-init
59
60set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
61
62lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
63lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
64
65# Main loop.
66dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-pr*.\[cS\]]]  \
67	"" $DEFAULT_VECTCFLAGS
68dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-vect-*.\[cS\]]]  \
69	"" $DEFAULT_VECTCFLAGS
70dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-slp-*.\[cS\]]]  \
71        "" $DEFAULT_VECTCFLAGS
72dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-bb-slp*.\[cS\]]]  \
73        "" $VECT_SLP_CFLAGS
74
75#### Tests with special options
76global SAVED_DEFAULT_VECTCFLAGS
77set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
78
79# -ffast-math tests
80set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
81lappend DEFAULT_VECTCFLAGS "-ffast-math"
82dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-fast-math-vect*.\[cS\]]]  \
83	"" $DEFAULT_VECTCFLAGS
84
85# Clean up.
86set dg-do-what-default ${save-dg-do-what-default}
87
88# All done.
89dg-finish
90