| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#if VECTOR_BITS > 512 |
| 7 |
#define N (VECTOR_BITS * 6 / 16) |
| 8 |
#else |
| 9 |
#define N 200 |
| 10 |
#endif |
| 11 |
|
| 12 |
void __attribute__((noinline)) |
| 13 |
foo (unsigned char *__restrict__ pInput, unsigned char *__restrict__ pOutput) |
| 14 |
{ |
| 15 |
unsigned char a, b, c; |
| 16 |
unsigned int i; |
| 17 |
|
| 18 |
for (i = 0; i < N / 3; i++) |
| 19 |
{ |
| 20 |
a = *pInput++; |
| 21 |
b = *pInput++; |
| 22 |
c = *pInput++; |
| 23 |
|
| 24 |
*pOutput++ = a + b + c + 3; |
| 25 |
*pOutput++ = a + b + c + 12; |
| 26 |
*pOutput++ = a + b + c + 1; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
int main (int argc, const char* argv[]) |
| 31 |
{ |
| 32 |
unsigned char input[N], output[N]; |
| 33 |
unsigned char check_results[N]; |
| 34 |
unsigned int i; |
| 35 |
|
| 36 |
check_vect (); |
| 37 |
|
| 38 |
for (i = 0; i < N; i++) |
| 39 |
{ |
| 40 |
input[i] = i; |
| 41 |
output[i] = 0; |
| 42 |
__asm__ volatile (""); |
| 43 |
} |
| 44 |
|
| 45 |
for (i = 0; i < N / 3; i++) |
| 46 |
{ |
| 47 |
check_results[3*i] = 9 * i + 6; |
| 48 |
check_results[3*i+1] = 9 * i + 15; |
| 49 |
check_results[3*i+2] = 9 * i + 4; |
| 50 |
__asm__ volatile ("" : : : "memory"); |
| 51 |
} |
| 52 |
|
| 53 |
foo (input, output); |
| 54 |
|
| 55 |
#pragma GCC novector |
| 56 |
for (i = 0; i < N - (N % 3); i++) |
| 57 |
if (output[i] != check_results[i]) |
| 58 |
abort (); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm_byte } } } } */ |
| 64 |
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_byte && { { ! vect_partial_vectors_usage_1 } || s390_vx } } } } } */ |
| 65 |
/* The epilogues are vectorized using partial vectors. */ |
| 66 |
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_byte && { vect_partial_vectors_usage_1 && { ! s390_vx } } } } } } */ |
| 67 |
/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ |
| 68 |
/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ |