Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / slp-19c.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 16
7
8 int
9 main1 ()
10 {
11   unsigned int i;
12   unsigned int out[N*8];
13   unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63};
14   unsigned int ia[N*2], a0, a1, a2, a3;
15
16   /* The last stmt requires interleaving of not power of 2 size - not
17      vectorizable.  */
18   for (i = 0; i < N/2; i++)
19     {
20       out[i*12] = in[i*12];
21       out[i*12 + 1] = in[i*12 + 1];
22       out[i*12 + 2] = in[i*12 + 2];
23       out[i*12 + 3] = in[i*12 + 3];
24       out[i*12 + 4] = in[i*12 + 4];
25       out[i*12 + 5] = in[i*12 + 5];
26       out[i*12 + 6] = in[i*12 + 6];
27       out[i*12 + 7] = in[i*12 + 7];
28       out[i*12 + 8] = in[i*12 + 8];
29       out[i*12 + 9] = in[i*12 + 9];
30       out[i*12 + 10] = in[i*12 + 10];
31       out[i*12 + 11] = in[i*12 + 11];
32
33       ia[i] = in[i*12 + 7];
34     }
35
36   /* check results:  */
37   for (i = 0; i < N/2; i++)
38     {
39       if (out[i*12] !=  in[i*12]
40          || out[i*12 + 1] != in[i*12 + 1]
41          || out[i*12 + 2] != in[i*12 + 2]
42          || out[i*12 + 3] != in[i*12 + 3]
43          || out[i*12 + 4] != in[i*12 + 4]
44          || out[i*12 + 5] != in[i*12 + 5]
45          || out[i*12 + 6] != in[i*12 + 6]
46          || out[i*12 + 7] != in[i*12 + 7]
47          || out[i*12 + 8] != in[i*12 + 8]
48          || out[i*12 + 9] != in[i*12 + 9]
49          || out[i*12 + 10] != in[i*12 + 10]
50          || out[i*12 + 11] != in[i*12 + 11]
51          || ia[i] != in[i*12 + 7])
52         abort ();
53     }
54
55   /* Hybrid SLP with unrolling by 2.  */
56   for (i = 0; i < N; i++)
57     {
58       out[i*6] = in[i*6];
59       out[i*6 + 1] = in[i*6 + 1];
60       out[i*6 + 2] = in[i*6 + 2];
61       out[i*6 + 3] = in[i*6 + 3];
62       out[i*6 + 4] = in[i*6 + 4];
63       out[i*6 + 5] = in[i*6 + 5];
64
65       ia[i] = i;
66     }
67
68   /* check results:  */
69   for (i = 0; i < N/2; i++)
70     {
71       if (out[i*6] !=  in[i*6]
72          || out[i*6 + 1] != in[i*6 + 1]
73          || out[i*6 + 2] != in[i*6 + 2]
74          || out[i*6 + 3] != in[i*6 + 3]
75          || out[i*6 + 4] != in[i*6 + 4]
76          || out[i*6 + 5] != in[i*6 + 5]
77          || ia[i] != i)
78         abort ();
79     }
80
81   return 0;
82 }
83
84 int main (void)
85 {
86   check_vect ();
87
88   main1 ();
89
90   return 0;
91 }
92
93 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
94 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */
95 /* { dg-final { cleanup-tree-dump "vect" } } */