OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / slp-perm-1.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 N 16
18
19 void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput)
20 {
21   unsigned int i, a, b, c;
22
23   for (i = 0; i < N / 3; i++)
24     {
25        a = *pInput++;
26        b = *pInput++;
27        c = *pInput++;
28
29        *pOutput++ = M00 * a + M01 * b + M02 * c;
30        *pOutput++ = M10 * a + M11 * b + M12 * c;
31        *pOutput++ = M20 * a + M21 * b + M22 * c;
32     }
33 }
34
35 int main (int argc, const char* argv[])
36 {
37   unsigned int input[N], output[N], i;
38   unsigned int check_results[N] = {1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, 195035, 14934, 4175, 278417, 19422, 5435, 361799, 0};
39
40   check_vect ();
41
42   for (i = 0; i < N; i++)
43     {
44       input[i] = i%256;
45       if (input[i] > 200)
46         abort();
47       output[i] = 0;
48     }
49
50   foo (input, output);
51
52   for (i = 0; i < N; i++)
53      if (output[i] != check_results[i])
54        abort ();
55
56   return 0;
57 }
58
59 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target vect_perm } } } */
60 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_perm } } } */
61 /* { dg-final { cleanup-tree-dump "vect" } } */
62