RISC-V: Enable basic VLS modes support
[official-gcc.git] / gcc / testsuite / gcc.target / riscv / rvv / rvv.exp
blobb41553bc2f592d69d09a16adb6cca8f135b06015
1 # Copyright (C) 2022-2023 Free Software Foundation, Inc.
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.
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.
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/>.
17 # GCC testsuite that uses the `dg.exp' driver.
19 # Exit immediately if this isn't a RISC-V target.
20 if ![istarget riscv*-*-*] then {
21 return
24 # Load support procs.
25 load_lib gcc-dg.exp
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"
33 set gcc_march "rv64gcv_zfh"
34 set gcc_mabi "lp64d"
35 if [istarget riscv32-*-*] then {
36 set gcc_march "rv32gcv_zfh"
37 set gcc_mabi "ilp32d"
40 # Initialize `dg'.
41 dg-init
43 # Main loop.
44 set CFLAGS "$DEFAULT_CFLAGS -march=$gcc_march -mabi=$gcc_mabi -O3"
45 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/base/*.\[cS\]]] \
46 "" $CFLAGS
47 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vsetvl/*.\[cS\]]] \
48 "" $CFLAGS
49 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/*.\[cS\]]] \
50 "-O3 -ftree-vectorize" $CFLAGS
51 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/vls/*.\[cS\]]] \
52 "-O3 -ftree-vectorize --param riscv-autovec-preference=scalable" $CFLAGS
54 set AUTOVEC_TEST_OPTS [list \
55 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m1} \
56 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m2} \
57 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m4} \
58 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m8} \
59 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m1} \
60 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m2} \
61 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m4} \
62 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m8} ]
63 foreach op $AUTOVEC_TEST_OPTS {
64 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/partial/*.\[cS\]]] \
65 "" "$op"
66 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/binop/*.\[cS\]]] \
67 "" "$op"
68 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/cmp/*.\[cS\]]] \
69 "" "$op"
70 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/conversions/*.\[cS\]]] \
71 "" "$op"
72 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/unop/*.\[cS\]]] \
73 "" "$op"
74 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/ternop/*.\[cS\]]] \
75 "" "$op"
76 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/reduc/*.\[cS\]]] \
77 "" "$op"
80 # widening operation only test on LMUL < 8
81 set AUTOVEC_TEST_OPTS [list \
82 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m1} \
83 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m2} \
84 {-ftree-vectorize -O3 --param riscv-autovec-lmul=m4} \
85 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m1} \
86 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m2} \
87 {-ftree-vectorize -O2 --param riscv-autovec-lmul=m4} ]
88 foreach op $AUTOVEC_TEST_OPTS {
89 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/widen/*.\[cS\]]] \
90 "" "$op"
93 # VLS-VLMAX tests
94 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/vls-vlmax/*.\[cS\]]] \
95 "-std=c99 -O3 -ftree-vectorize --param riscv-autovec-preference=fixed-vlmax" $CFLAGS
97 # gather-scatter tests
98 set AUTOVEC_TEST_OPTS [list \
99 {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \
100 {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \
101 {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \
102 {-ftree-vectorize -O3 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \
103 {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \
104 {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \
105 {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \
106 {-ftree-vectorize -O2 --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \
107 {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \
108 {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \
109 {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \
110 {-ftree-vectorize -O3 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} \
111 {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m1 -fno-vect-cost-model -ffast-math} \
112 {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math} \
113 {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m4 -fno-vect-cost-model -ffast-math} \
114 {-ftree-vectorize -O2 --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m8 -fno-vect-cost-model -ffast-math} ]
115 foreach op $AUTOVEC_TEST_OPTS {
116 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/gather-scatter/*.\[cS\]]] \
117 "" "$op"
120 # All done.
121 dg-finish