| 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 |
#define K00 405 |
| 17 |
#define K10 112 |
| 18 |
#define K01 4322 |
| 19 |
#define K11 135 |
| 20 |
|
| 21 |
#if VECTOR_BITS > 128 |
| 22 |
#define N (VECTOR_BITS * 3 / 32 + 4) |
| 23 |
#else |
| 24 |
#define N 16 |
| 25 |
#endif |
| 26 |
|
| 27 |
void foo (int *__restrict__ pInput, int *__restrict__ pOutput, |
| 28 |
int *__restrict__ pInput2, int *__restrict__ pOutput2) |
| 29 |
{ |
| 30 |
int i, a, b, c, d, e; |
| 31 |
|
| 32 |
for (i = 0; i < N / 3; i++) |
| 33 |
{ |
| 34 |
a = *pInput++; |
| 35 |
b = *pInput++; |
| 36 |
c = *pInput++; |
| 37 |
|
| 38 |
d = *pInput2++; |
| 39 |
e = *pInput2++; |
| 40 |
|
| 41 |
*pOutput++ = M00 * a + M01 * b + M02 * c; |
| 42 |
*pOutput++ = M10 * a + M11 * b + M12 * c; |
| 43 |
*pOutput++ = M20 * a + M21 * b + M22 * c; |
| 44 |
|
| 45 |
/* Regular SLP - no permutation required. */ |
| 46 |
*pOutput2++ = K00 * d; |
| 47 |
*pOutput2++ = K10 * e; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
int main (int argc, const char* argv[]) |
| 52 |
{ |
| 53 |
int input[N], output[N], i; |
| 54 |
int input2[N], output2[N]; |
| 55 |
|
| 56 |
check_vect (); |
| 57 |
|
| 58 |
for (i = 0; i < N; i++) |
| 59 |
{ |
| 60 |
input[i] = i%256; |
| 61 |
input2[i] = i%256; |
| 62 |
output[i] = 0; |
| 63 |
output2[i] = 0; |
| 64 |
__asm__ volatile (""); |
| 65 |
} |
| 66 |
|
| 67 |
#if N == 16 |
| 68 |
int check_results[N] = { 1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, |
| 69 |
195035, 14934, 4175, 278417, 19422, 5435, 361799, |
| 70 |
0 }; |
| 71 |
int check_results2[N] = { 0, 112, 810, 336, 1620, 560, 2430, 784, 3240, 1008, |
| 72 |
0, 0, 0, 0, 0, 0 }; |
| 73 |
#else |
| 74 |
volatile int check_results[N] = {}; |
| 75 |
volatile int check_results2[N] = {}; |
| 76 |
|
| 77 |
for (int i = 0; i < N / 3; i++) |
| 78 |
{ |
| 79 |
int a = input[i * 3]; |
| 80 |
int b = input[i * 3 + 1]; |
| 81 |
int c = input[i * 3 + 2]; |
| 82 |
int d = input2[i * 2]; |
| 83 |
int e = input2[i * 2 + 1]; |
| 84 |
|
| 85 |
check_results[i * 3] = M00 * a + M01 * b + M02 * c; |
| 86 |
check_results[i * 3 + 1] = M10 * a + M11 * b + M12 * c; |
| 87 |
check_results[i * 3 + 2] = M20 * a + M21 * b + M22 * c; |
| 88 |
|
| 89 |
check_results2[i * 2] = K00 * d; |
| 90 |
check_results2[i * 2 + 1] = K10 * e; |
| 91 |
|
| 92 |
asm volatile ("" ::: "memory"); |
| 93 |
} |
| 94 |
#endif |
| 95 |
|
| 96 |
foo (input, output, input2, output2); |
| 97 |
|
| 98 |
#pragma GCC novector |
| 99 |
for (i = 0; i < N; i++) |
| 100 |
if (output[i] != check_results[i] || output2[i] != check_results2[i]) |
| 101 |
abort (); |
| 102 |
|
| 103 |
return 0; |
| 104 |
} |
| 105 |
|
| 106 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ |
| 107 |
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_perm3_int } } } */ |
| 108 |
/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } xfail *-*-* } } } */ |
| 109 |
/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ |
| 110 |
/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ |