| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-march=rv64gcv -mabi=lp64 -O2" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ |
| 4 |
|
| 5 |
#include "riscv_vector.h" |
| 6 |
|
| 7 |
extern void can_clobber_vtype(); |
| 8 |
|
| 9 |
static inline void v_loop (void * restrict in, void * restrict out, int n) |
| 10 |
{ |
| 11 |
for (int i = 0; i < n; i++) |
| 12 |
{ |
| 13 |
vuint8mf8_t v = *(vuint8mf8_t*)(in + i); |
| 14 |
*(vuint8mf8_t*)(out + i) = v; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
/* Two V instructions back-back. |
| 19 |
Only 1 vsetvli insn. */ |
| 20 |
void |
| 21 |
vec1 (void * restrict in, void * restrict out1, void * restrict out2, int n) |
| 22 |
{ |
| 23 |
v_loop(in, out1, n); |
| 24 |
v_loop(in, out2, n); |
| 25 |
} |
| 26 |
|
| 27 |
/* Two V instructions seperated by a function call. |
| 28 |
Both need to have a corresponding vsetvli insn. */ |
| 29 |
void |
| 30 |
vec2 (void * restrict in, void * restrict out1, void * restrict out2, int n) |
| 31 |
{ |
| 32 |
v_loop(in, out1, n); |
| 33 |
can_clobber_vtype(); |
| 34 |
v_loop(in, out2, n); |
| 35 |
} |
| 36 |
|
| 37 |
/* Two V instructions seperated by an inline asm with vtype clobber. |
| 38 |
Both need to have a corresponding vsetvli insn. */ |
| 39 |
void |
| 40 |
vec3 (void * restrict in, void * restrict out1, void * restrict out2, int n) |
| 41 |
{ |
| 42 |
v_loop(in, out1, n); |
| 43 |
asm volatile("":::"vtype"); |
| 44 |
v_loop(in, out2, n); |
| 45 |
} |
| 46 |
|
| 47 |
/* { dg-final { scan-assembler-times {vsetvli} 5 } } */ |