1 /* { dg-require-effective-target vect_int } */
2 
3 #include <stdarg.h>
4 #include "tree-vect.h"
5 
6 #define N 128
7 
8 int
main1(unsigned short a0,unsigned short a1,unsigned short a2,unsigned short a3,unsigned short a4,unsigned short a5,unsigned short a6,unsigned short a7,unsigned short a8,unsigned short a9,unsigned short a10,unsigned short a11,unsigned short a12,unsigned short a13,unsigned short a14,unsigned short a15)9 main1 (unsigned short a0, unsigned short a1, unsigned short a2,
10        unsigned short a3, unsigned short a4, unsigned short a5,
11        unsigned short a6, unsigned short a7, unsigned short a8,
12        unsigned short a9, unsigned short a10, unsigned short a11,
13        unsigned short a12, unsigned short a13, unsigned short a14,
14        unsigned short a15)
15 {
16   int i;
17   unsigned short out[N*16];
18 
19   for (i = 0; i < N; i++)
20     {
21       out[i*4] = a8;
22       out[i*4 + 1] = a1;
23       out[i*4 + 2] = a2;
24       out[i*4 + 3] = a3;
25     }
26 
27   /* check results:  */
28   for (i = 0; i < N; i++)
29     {
30       if (out[i*4] != a8
31          || out[i*4 + 1] != a1
32          || out[i*4 + 2] != a2
33          || out[i*4 + 3] != a3)
34 	abort ();
35     }
36 
37   for (i = 0; i < N; i++)
38     {
39       out[i*16] = a8;
40       out[i*16 + 1] = a7;
41       out[i*16 + 2] = a1;
42       out[i*16 + 3] = a2;
43       out[i*16 + 4] = a8;
44       out[i*16 + 5] = a5;
45       out[i*16 + 6] = a5;
46       out[i*16 + 7] = a4;
47       out[i*16 + 8] = a12;
48       out[i*16 + 9] = a13;
49       out[i*16 + 10] = a14;
50       out[i*16 + 11] = a15;
51       out[i*16 + 12] = a6;
52       out[i*16 + 13] = a9;
53       out[i*16 + 14] = a0;
54       out[i*16 + 15] = a7;
55     }
56 
57   /* check results:  */
58   for (i = 0; i < N; i++)
59     {
60       if (out[i*16] != a8
61           || out[i*16 + 1] != a7
62           || out[i*16 + 2] != a1
63           || out[i*16 + 3] != a2
64           || out[i*16 + 4] != a8
65           || out[i*16 + 5] != a5
66           || out[i*16 + 6] != a5
67           || out[i*16 + 7] != a4
68           || out[i*16 + 8] != a12
69           || out[i*16 + 9] != a13
70           || out[i*16 + 10] != a14
71           || out[i*16 + 11] != a15
72           || out[i*16 + 12] != a6
73           || out[i*16 + 13] != a9
74           || out[i*16 + 14] != a0
75           || out[i*16 + 15] != a7)
76         abort ();
77     }
78 
79   /* SLP with unrolling by 8.  */
80   for (i = 0; i < N; i++)
81     {
82       out[i*3] = a8;
83       out[i*3 + 1] = a1;
84       out[i*3 + 2] = a2;
85     }
86 
87   /* check results:  */
88   for (i = 0; i < N; i++)
89     {
90       if (out[i*3] != a8
91          || out[i*3 + 1] != a1
92          || out[i*3 + 2] != a2)
93         abort ();
94     }
95 
96   /* SLP with unrolling by 8.  */
97   for (i = 0; i < N; i++)
98     {
99       out[i*11] = a8;
100       out[i*11 + 1] = a7;
101       out[i*11 + 2] = a1;
102       out[i*11 + 3] = a2;
103       out[i*11 + 4] = a8;
104       out[i*11 + 5] = a5;
105       out[i*11 + 6] = a5;
106       out[i*11 + 7] = a4;
107       out[i*11 + 8] = a12;
108       out[i*11 + 9] = a13;
109       out[i*11 + 10] = a14;
110     }
111 
112   /* check results:  */
113   for (i = 0; i < N; i++)
114     {
115       if (out[i*11] != a8
116           || out[i*11 + 1] != a7
117           || out[i*11 + 2] != a1
118           || out[i*11 + 3] != a2
119           || out[i*11 + 4] != a8
120           || out[i*11 + 5] != a5
121           || out[i*11 + 6] != a5
122           || out[i*11 + 7] != a4
123           || out[i*11 + 8] != a12
124           || out[i*11 + 9] != a13
125           || out[i*11 + 10] != a14)
126         abort ();
127     }
128 
129 
130   return 0;
131 }
132 
main(void)133 int main (void)
134 {
135   check_vect ();
136 
137   main1 (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0);
138 
139   return 0;
140 }
141 
142 /* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect"  } } */
143 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { xfail vect_variable_length } } } */
144 
145