OSDN Git Service

PR tree-optimization/40542
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / slp-perm-6.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include <stdio.h>
5 #include "tree-vect.h"
6
7 #define M00 100
8 #define M10 216
9 #define M20 23
10 #define M01 1322
11 #define M11 13
12 #define M21 27271
13 #define M02 74
14 #define M12 191
15 #define M22 500
16
17 #define K00 405
18 #define K10 112
19 #define K01 4322
20 #define K11 135
21
22 #define N 16
23
24 void foo (int *__restrict__ pInput, int *__restrict__ pOutput,
25           int *__restrict__ pInput2, int *__restrict__ pOutput2)
26 {
27   int i, a, b, c, d, e;
28
29   for (i = 0; i < N / 3; i++)
30     {
31        a = *pInput++;
32        b = *pInput++;
33        c = *pInput++;
34
35        d = *pInput2++;
36        e = *pInput2++;
37
38        *pOutput++ = M00 * a + M01 * b + M02 * c;
39        *pOutput++ = M10 * a + M11 * b + M12 * c;
40        *pOutput++ = M20 * a + M21 * b + M22 * c;
41
42        /* Regular SLP - no permutation required.  */
43        *pOutput2++ = K00 * d;
44        *pOutput2++ = K10 * e;
45     }
46 }
47
48 int main (int argc, const char* argv[])
49 {
50   int input[N], output[N], i;
51   int check_results[N] = {1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, 195035, 14934, 4175, 278417, 19422, 5435, 361799, 0};
52   int input2[N], output2[N];
53   int check_results2[N] = {0, 112, 810, 336, 1620, 560, 2430, 784, 3240, 1008, 0, 0, 0, 0, 0, 0};
54
55   check_vect ();
56
57   for (i = 0; i < N; i++)
58     {
59       input[i] = i%256;
60       input2[i] = i%256;
61       output[i] = 0;
62       output2[i] = 0;
63       if (input[i] > 256)
64         abort ();
65     }
66
67   foo (input, output, input2, output2);
68
69   for (i = 0; i < N; i++)
70      if (output[i] != check_results[i] || output2[i] != check_results2[i])
71        abort ();
72
73   return 0;
74 }
75
76 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target vect_perm } } } */
77 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_perm } } } */
78 /* { dg-final { cleanup-tree-dump "vect" } } */
79