| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#define M00 100 |
| 7 |
#define M10 216 |
| 8 |
#define M20 23 |
| 9 |
#define M01 1322 |
| 10 |
#define M11 13 |
| 11 |
#define M21 27271 |
| 12 |
#define M02 74 |
| 13 |
#define M12 191 |
| 14 |
#define M22 500 |
| 15 |
|
| 16 |
#if VECTOR_BITS > 128 |
| 17 |
#define N (VECTOR_BITS * 3 / 32 + 4) |
| 18 |
#else |
| 19 |
#define N 16 |
| 20 |
#endif |
| 21 |
|
| 22 |
void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput) |
| 23 |
{ |
| 24 |
unsigned int i, a, b, c; |
| 25 |
|
| 26 |
for (i = 0; i < N / 3; i++) |
| 27 |
{ |
| 28 |
a = *pInput++; |
| 29 |
b = *pInput++; |
| 30 |
c = *pInput++; |
| 31 |
|
| 32 |
*pOutput++ = M00 * a + M01 * b + M02 * c; |
| 33 |
*pOutput++ = M10 * a + M11 * b + M12 * c; |
| 34 |
*pOutput++ = M20 * a + M21 * b + M22 * c; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
int main (int argc, const char* argv[]) |
| 39 |
{ |
| 40 |
unsigned int input[N], output[N], i; |
| 41 |
|
| 42 |
check_vect (); |
| 43 |
|
| 44 |
for (i = 0; i < N; i++) |
| 45 |
{ |
| 46 |
input[i] = i%256; |
| 47 |
output[i] = 0; |
| 48 |
__asm__ volatile (""); |
| 49 |
} |
| 50 |
|
| 51 |
#if N == 16 |
| 52 |
unsigned int check_results[N] = {1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, 195035, 14934, 4175, 278417, 19422, 5435, 361799, 0}; |
| 53 |
#else |
| 54 |
volatile unsigned int check_results[N] = {}; |
| 55 |
|
| 56 |
for (unsigned int i = 0; i < N / 3; i++) |
| 57 |
{ |
| 58 |
unsigned int a = input[i * 3]; |
| 59 |
unsigned int b = input[i * 3 + 1]; |
| 60 |
unsigned int c = input[i * 3 + 2]; |
| 61 |
|
| 62 |
check_results[i * 3] = M00 * a + M01 * b + M02 * c; |
| 63 |
check_results[i * 3 + 1] = M10 * a + M11 * b + M12 * c; |
| 64 |
check_results[i * 3 + 2] = M20 * a + M21 * b + M22 * c; |
| 65 |
|
| 66 |
asm volatile ("" ::: "memory"); |
| 67 |
} |
| 68 |
#endif |
| 69 |
|
| 70 |
foo (input, output); |
| 71 |
|
| 72 |
#pragma GCC novector |
| 73 |
for (i = 0; i < N; i++) |
| 74 |
{ |
| 75 |
if (output[i] != check_results[i]) |
| 76 |
abort (); |
| 77 |
__asm__ volatile (""); |
| 78 |
} |
| 79 |
|
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ |
| 84 |
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int || vect_load_lanes } } } } */ |
| 85 |
/* { dg-final { scan-tree-dump "can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ |
| 86 |
/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ |
| 87 |
/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ |
| 88 |
|