| 1 |
/* { dg-do compile { target { ! riscv_abi_e } } } */ |
| 2 |
/* { dg-add-options riscv_v } */ |
| 3 |
/* { dg-additional-options "-O3 -mrvv-max-lmul=dynamic" } */ |
| 4 |
/* { dg-final { check-function-bodies "**" "" } } */ |
| 5 |
|
| 6 |
#define MIN_VECTOR_BYTES (__riscv_v_min_vlen / 8) |
| 7 |
|
| 8 |
/* Tiny memmoves should not be vectorised. |
| 9 |
** f1: |
| 10 |
** lbu\s+[ta][0-7],0\(a1\) |
| 11 |
** sb\s+[ta][0-7],0\(a0\) |
| 12 |
** ret |
| 13 |
*/ |
| 14 |
char * |
| 15 |
f1 (char *a, char const *b) |
| 16 |
{ |
| 17 |
return __builtin_memmove (a, b, 1); |
| 18 |
} |
| 19 |
|
| 20 |
/* Vectorise+inline minimum vector register width with LMUL=1 |
| 21 |
** f2: |
| 22 |
** ( |
| 23 |
** vsetivli\s+zero,16,e8,m1,ta,ma |
| 24 |
** | |
| 25 |
** li\s+[ta][0-7],\d+ |
| 26 |
** vsetvli\s+zero,[ta][0-7],e8,m1,ta,ma |
| 27 |
** ) |
| 28 |
** vle8\.v\s+v\d+,0\(a1\) |
| 29 |
** vse8\.v\s+v\d+,0\(a0\) |
| 30 |
** ret |
| 31 |
*/ |
| 32 |
char * |
| 33 |
f2 (char *a, char const *b) |
| 34 |
{ |
| 35 |
return __builtin_memmove (a, b, MIN_VECTOR_BYTES); |
| 36 |
} |
| 37 |
|
| 38 |
/* Vectorise+inline up to LMUL=8 |
| 39 |
** f3: |
| 40 |
** li\s+[ta][0-7],\d+ |
| 41 |
** vsetvli\s+zero,[ta][0-7],e8,m8,ta,ma |
| 42 |
** vle8\.v\s+v\d+,0\(a1\) |
| 43 |
** vse8\.v\s+v\d+,0\(a0\) |
| 44 |
** ret |
| 45 |
*/ |
| 46 |
char * |
| 47 |
f3 (char *a, char const *b) |
| 48 |
{ |
| 49 |
return __builtin_memmove (a, b, MIN_VECTOR_BYTES * 8); |
| 50 |
} |
| 51 |
|
| 52 |
/* Don't vectorise if the move is too large for one operation |
| 53 |
** f4: |
| 54 |
** li\s+a2,\d+ |
| 55 |
** tail\s+memmove(?:@plt)? |
| 56 |
*/ |
| 57 |
char * |
| 58 |
f4 (char *a, char const *b) |
| 59 |
{ |
| 60 |
return __builtin_memmove (a, b, MIN_VECTOR_BYTES * 8 + 1); |
| 61 |
} |