OSDN Git Service

PR tree-optimization/40238
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / slp-perm-3.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 M30 237
11 #define M01 1322
12 #define M11 13
13 #define M21 27271
14 #define M31 2280
15 #define M02 74
16 #define M12 191
17 #define M22 500
18 #define M32 111
19 #define M03 134
20 #define M13 117
21 #define M23 11
22 #define M33 771
23
24 #define N 16
25
26 void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput)
27 {
28   unsigned int i, a, b, c, d;
29
30   for (i = 0; i < N / 4; i++)
31     {
32        a = *pInput++;
33        b = *pInput++;
34        c = *pInput++;
35        d = *pInput++;
36
37        *pOutput++ = M00 * a + M01 * b + M02 * c + M03 * d;
38        *pOutput++ = M10 * a + M11 * b + M12 * c + M13 * d;
39        *pOutput++ = M20 * a + M21 * b + M22 * c + M23 * d;
40        *pOutput++ = M30 * a + M31 * b + M32 * c + M33 * d;
41     }
42 }
43
44 int main (int argc, const char* argv[])
45 {
46   unsigned int input[N], output[N], i;
47   unsigned int check_results[N] = {1872, 746, 28304, 4815, 8392, 2894, 139524, 18411, 14912, 5042, 250744, 32007, 21432, 7190, 361964, 45603};
48
49   check_vect ();
50
51   for (i = 0; i < N; i++)
52     {
53       input[i] = i%256;
54       if (input[i] > 200)
55         abort();
56       output[i] = 0;
57     }
58
59   foo (input, output);
60
61   for (i = 0; i < N - N; i++)
62     if (output[i] != check_results[i])
63       abort ();
64
65   return 0;
66 }
67
68 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target vect_perm } } } */
69 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_perm } } } */
70 /* { dg-final { cleanup-tree-dump "vect" } } */
71
72