OSDN Git Service

PR tree-optimization/40542
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / slp-perm-2.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 M01 1322
10 #define M11 13
11 #define M02 74
12 #define M12 191
13
14 #define N 16
15
16 void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput)
17 {
18   unsigned int i, a, b;
19
20   for (i = 0; i < N / 2; i++)
21     {
22        a = *pInput++;
23        b = *pInput++;
24
25        *pOutput++ = M00 * a + M01 * b;
26        *pOutput++ = M10 * a + M11 * b;
27     }
28 }
29
30 int main (int argc, const char* argv[])
31 {
32   unsigned int input[N], output[N], i;
33   unsigned int check_results[N] = {1322, 13, 4166, 471, 7010, 929, 9854, 1387, 12698, 1845, 15542, 2303, 18386, 2761, 21230, 3219};
34
35   check_vect ();
36
37   for (i = 0; i < N; i++)
38     {
39       input[i] = i%256;
40       if (input[i] > 200)
41         abort();
42       output[i] = 0;
43     }
44
45   foo (input, output);
46
47   for (i = 0; i < N; i++)
48     if (output[i] != check_results[i])
49       abort ();
50
51   return 0;
52 }
53
54 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target vect_perm } } } */
55 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_perm } } } */
56 /* { dg-final { cleanup-tree-dump "vect" } } */
57