| 1 |
# Copyright (C) 2022-2025 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 |
# Exit immediately if this isn't a RISC-V target. |
| 20 |
if ![istarget riscv*-*-*] then { |
| 21 |
return |
| 22 |
} |
| 23 |
|
| 24 |
# Load support procs. |
| 25 |
load_lib gcc-dg.exp |
| 26 |
|
| 27 |
# If a testcase doesn't have special options, use these. |
| 28 |
global DEFAULT_CFLAGS |
| 29 |
if ![info exists DEFAULT_CFLAGS] then { |
| 30 |
set DEFAULT_CFLAGS " -ansi -pedantic-errors" |
| 31 |
} |
| 32 |
|
| 33 |
# Initialize `dg'. |
| 34 |
dg-init |
| 35 |
|
| 36 |
# Main loop. |
| 37 |
set CFLAGS "$DEFAULT_CFLAGS -O3" |
| 38 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ |
| 39 |
"" $CFLAGS |
| 40 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/base/*.\[cS\]]] \ |
| 41 |
"" $CFLAGS |
| 42 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/xsfvector/*.\[cS\]]] \ |
| 43 |
"" $CFLAGS |
| 44 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/xtheadvector/*.\[cS\]]] \ |
| 45 |
"" $CFLAGS |
| 46 |
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vsetvl/*.\[cS\]]] \ |
| 47 |
"" $CFLAGS |
| 48 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/*.\[cS\]]] \ |
| 49 |
"-O3 -ftree-vectorize" $CFLAGS |
| 50 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/vls/*.\[cS\]]] \ |
| 51 |
"-O3 -ftree-vectorize -mrvv-vector-bits=scalable" $CFLAGS |
| 52 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/struct/*.\[cS\]]] \ |
| 53 |
"" "-O3 -ftree-vectorize" |
| 54 |
|
| 55 |
set AUTOVEC_TEST_OPTS [list \ |
| 56 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m1} \ |
| 57 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m2} \ |
| 58 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m4} \ |
| 59 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m8} \ |
| 60 |
{-ftree-vectorize -O3 -mrvv-max-lmul=dynamic} \ |
| 61 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m1} \ |
| 62 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m2} \ |
| 63 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m4} \ |
| 64 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m8} \ |
| 65 |
{-ftree-vectorize -O2 -mrvv-max-lmul=dynamic} ] |
| 66 |
foreach op $AUTOVEC_TEST_OPTS { |
| 67 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/partial/*.\[cS\]]] \ |
| 68 |
"$op" "" |
| 69 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/binop/*.\[cS\]]] \ |
| 70 |
"$op" "" |
| 71 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/cmp/*.\[cS\]]] \ |
| 72 |
"$op" "" |
| 73 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/conversions/*.\[cS\]]] \ |
| 74 |
"$op" "" |
| 75 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/unop/*.\[cS\]]] \ |
| 76 |
"$op" "" |
| 77 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/ternop/*.\[cS\]]] \ |
| 78 |
"$op" "" |
| 79 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/reduc/*.\[cS\]]] \ |
| 80 |
"$op" "" |
| 81 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/cond/*.\[cS\]]] \ |
| 82 |
"$op" "" |
| 83 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/builtin/*.\[cS\]]] \ |
| 84 |
"$op" "" |
| 85 |
} |
| 86 |
|
| 87 |
# widening operation only test on LMUL < 8 |
| 88 |
set AUTOVEC_TEST_OPTS [list \ |
| 89 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m1} \ |
| 90 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m2} \ |
| 91 |
{-ftree-vectorize -O3 -mrvv-max-lmul=m4} \ |
| 92 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m1} \ |
| 93 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m2} \ |
| 94 |
{-ftree-vectorize -O2 -mrvv-max-lmul=m4} ] |
| 95 |
foreach op $AUTOVEC_TEST_OPTS { |
| 96 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/widen/*.\[cS\]]] \ |
| 97 |
"$op" "" |
| 98 |
} |
| 99 |
|
| 100 |
# VLS-VLMAX tests |
| 101 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/vls-vlmax/*.\[cS\]]] \ |
| 102 |
"-std=c99 -O3 -ftree-vectorize -mrvv-vector-bits=zvl" $CFLAGS |
| 103 |
|
| 104 |
# gather-scatter tests |
| 105 |
set AUTOVEC_TEST_OPTS [list \ |
| 106 |
{-ftree-vectorize -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m1 -fno-vect-cost-model -ffast-math} \ |
| 107 |
{-ftree-vectorize -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m2 -fno-vect-cost-model -ffast-math} \ |
| 108 |
{-ftree-vectorize -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m4 -fno-vect-cost-model -ffast-math} \ |
| 109 |
{-ftree-vectorize -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m8 -fno-vect-cost-model -ffast-math} \ |
| 110 |
{-ftree-vectorize -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=dynamic -ffast-math} \ |
| 111 |
{-ftree-vectorize -O2 -mrvv-vector-bits=zvl -mrvv-max-lmul=m1 -fno-vect-cost-model -ffast-math} \ |
| 112 |
{-ftree-vectorize -O2 -mrvv-vector-bits=zvl -mrvv-max-lmul=m2 -fno-vect-cost-model -ffast-math} \ |
| 113 |
{-ftree-vectorize -O2 -mrvv-vector-bits=zvl -mrvv-max-lmul=m4 -fno-vect-cost-model -ffast-math} \ |
| 114 |
{-ftree-vectorize -O2 -mrvv-vector-bits=zvl -mrvv-max-lmul=m8 -fno-vect-cost-model -ffast-math} \ |
| 115 |
{-ftree-vectorize -O2 -mrvv-vector-bits=zvl -mrvv-max-lmul=dynamic -ffast-math} \ |
| 116 |
{-ftree-vectorize -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m1 -fno-vect-cost-model -ffast-math} \ |
| 117 |
{-ftree-vectorize -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m2 -fno-vect-cost-model -ffast-math} \ |
| 118 |
{-ftree-vectorize -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m4 -fno-vect-cost-model -ffast-math} \ |
| 119 |
{-ftree-vectorize -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m8 -fno-vect-cost-model -ffast-math} \ |
| 120 |
{-ftree-vectorize -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=dynamic -ffast-math} \ |
| 121 |
{-ftree-vectorize -O2 -mrvv-vector-bits=scalable -mrvv-max-lmul=m1 -fno-vect-cost-model -ffast-math} \ |
| 122 |
{-ftree-vectorize -O2 -mrvv-vector-bits=scalable -mrvv-max-lmul=m2 -fno-vect-cost-model -ffast-math} \ |
| 123 |
{-ftree-vectorize -O2 -mrvv-vector-bits=scalable -mrvv-max-lmul=m4 -fno-vect-cost-model -ffast-math} \ |
| 124 |
{-ftree-vectorize -O2 -mrvv-vector-bits=scalable -mrvv-max-lmul=m8 -fno-vect-cost-model -ffast-math} \ |
| 125 |
{-ftree-vectorize -O2 -mrvv-vector-bits=scalable -mrvv-max-lmul=dynamic -ffast-math} ] |
| 126 |
foreach op $AUTOVEC_TEST_OPTS { |
| 127 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/gather-scatter/*.\[cS\]]] \ |
| 128 |
"$op" "" |
| 129 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/strided/*.\[cS\]]] \ |
| 130 |
"$op" "" |
| 131 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/sat/*.\[cS\]]] \ |
| 132 |
"$op" "" |
| 133 |
} |
| 134 |
|
| 135 |
# All done. |
| 136 |
dg-finish |