]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_phi-23.c
RISC-V: Add testcases for VSETVL PASS 2
[thirdparty/gcc.git] / gcc / testsuite / gcc.target / riscv / rvv / vsetvl / vlmax_phi-23.c
1 /* { dg-do compile } */
2 /* { dg-options "-march=rv32gcv -mabi=ilp32" } */
3
4 #include "riscv_vector.h"
5
6 /* The for loop body should not have vsetvl instruction. */
7 void f (void * restrict in, void * restrict out, int n, int cond)
8 {
9 switch (cond)
10 {
11 case 1:{
12 vint16mf2_t v = *(vint16mf2_t*)(in + 100);
13 *(vint16mf2_t*)(out + 100) = v;
14 break;
15 }
16 case 2:{
17 vint16mf2_t v = *(vint16mf2_t*)(in + 200);
18 *(vint16mf2_t*)(out + 100) = v;
19 break;
20 }
21 case 3:{
22 vint16mf2_t v = *(vint16mf2_t*)(in + 300);
23 *(vint16mf2_t*)(out + 100) = v;
24 break;
25 }
26 default:{
27 vint16mf2_t v = *(vint16mf2_t*)(in + 400);
28 *(vint16mf2_t*)(out + 400) = v;
29 break;
30 }
31 }
32 for (int i = 0; i < n; i++)
33 {
34 vint16mf2_t v = *(vint16mf2_t*)(in + i);
35 *(vint16mf2_t*)(out + i) = v;
36 }
37 }
38
39 /* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf2,\s*t[au],\s*m[au]} 4 { target { no-opts "-O0" no-opts "-Os" no-opts "-funroll-loops" no-opts "-g" no-opts "-flto" } } } } */
40 /* { dg-final { scan-assembler-times {ble\tra|[sgtf]p|t[0-6]|s[0-9]|s10|s11|a[0-7],zero,.L[0-9]+\s*\.L[0-9]+\:\s*vle16\.v\s+(?:v[0-9]|v[1-2][0-9]|v3[0-1]),0\s*\([a-x0-9]+\)} 1 { target { no-opts "-O0" no-opts "-Os" no-opts "-funroll-loops" no-opts "-g" no-opts "-flto" } } } } */