PR target/55146
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-2.c
blob69e1ed5e0661afdccf515c797cca4b50df250a5b
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 128
8 int
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)
16 int i;
17 unsigned short out[N*16];
19 for (i = 0; i < N; i++)
21 out[i*4] = a8;
22 out[i*4 + 1] = a1;
23 out[i*4 + 2] = a2;
24 out[i*4 + 3] = a3;
27 /* check results: */
28 for (i = 0; i < N; i++)
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 ();
37 for (i = 0; i < N; i++)
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;
57 /* check results: */
58 for (i = 0; i < N; i++)
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 ();
79 /* SLP with unrolling by 8. */
80 for (i = 0; i < N; i++)
82 out[i*3] = a8;
83 out[i*3 + 1] = a1;
84 out[i*3 + 2] = a2;
87 /* check results: */
88 for (i = 0; i < N; i++)
90 if (out[i*3] != a8
91 || out[i*3 + 1] != a1
92 || out[i*3 + 2] != a2)
93 abort ();
96 /* SLP with unrolling by 8. */
97 for (i = 0; i < N; i++)
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;
112 /* check results: */
113 for (i = 0; i < N; i++)
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 ();
130 return 0;
133 int main (void)
135 check_vect ();
137 main1 (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0);
139 return 0;
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" } } */
144 /* { dg-final { cleanup-tree-dump "vect" } } */