2017-12-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-22.c
blob394460cbb8873f618fd070c55de1c1b202d1d3cc
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)
13 int i;
14 unsigned short out[N*8], out2[N*8], out3[N*8], b0, b1, b2, b3, b4, b5, b6, b7, b8;
16 for (i = 0; i < N; i++)
18 b0 = a0 + 8;
19 b1 = a1 + 7;
20 b2 = a2 + 6;
21 b3 = a3 + 5;
22 b4 = a4 + 4;
23 b5 = a5 + 3;
25 out[i*4] = b0;
26 out[i*4 + 1] = b1;
27 out[i*4 + 2] = b2;
28 out[i*4 + 3] = b3;
30 out2[i*4] = b0;
31 out2[i*4 + 1] = b1;
32 out2[i*4 + 2] = b4;
33 out2[i*4 + 3] = b5;
35 out3[i*4] = b2;
36 out3[i*4 + 1] = b1;
37 out3[i*4 + 2] = b4;
38 out3[i*4 + 3] = b5;
41 /* check results: */
42 for (i = 0; i < N; i++)
44 if (out[i*4] != b0
45 || out[i*4 + 1] != b1
46 || out[i*4 + 2] != b2
47 || out[i*4 + 3] != b3)
48 abort ();
51 if (out2[i*4] != b0
52 || out2[i*4 + 1] != b1
53 || out2[i*4 + 2] != b4
54 || out2[i*4 + 3] != b5)
55 abort ();
57 if (out3[i*4] != b2
58 || out3[i*4 + 1] != b1
59 || out3[i*4 + 2] != b4
60 || out3[i*4 + 3] != b5)
61 abort ();
64 for (i = 0; i < N; i++)
66 b0 = a0 + 8;
67 b1 = a1 + 7;
68 b2 = a2 + 6;
69 b3 = a3 + 5;
70 b4 = a4 + 4;
71 b5 = a5 + 3;
72 b6 = a6 + 2;
73 b7 = a7 + 1;
74 b8 = a8 + 9;
76 out[i*4] = b0;
77 out[i*4 + 1] = b1;
78 out[i*4 + 2] = b2;
79 out[i*4 + 3] = b3;
81 out2[i*8] = b0;
82 out2[i*8 + 1] = b1;
83 out2[i*8 + 2] = b4;
84 out2[i*8 + 3] = b5;
85 out2[i*8 + 4] = b6;
86 out2[i*8 + 5] = b2;
87 out2[i*8 + 6] = b7;
88 out2[i*8 + 7] = b8;
90 out3[2*i + 1] = a0;
91 out3[2*i] = b8;
94 /* check results: */
95 for (i = 0; i < N; i++)
97 if (out[i*4] != b0
98 || out[i*4 + 1] != b1
99 || out[i*4 + 2] != b2
100 || out[i*4 + 3] != b3)
101 abort ();
103 if (out2[i*8] != b0
104 || out2[i*8 + 1] != b1
105 || out2[i*8 + 2] != b4
106 || out2[i*8 + 3] != b5
107 || out2[i*8 + 4] != b6
108 || out2[i*8 + 5] != b2
109 || out2[i*8 + 6] != b7
110 || out2[i*8 + 7] != b8)
111 abort ();
113 if (out3[2*i] != b8
114 || out3[2*i+1] != a0)
115 abort();
119 return 0;
122 int main (void)
124 check_vect ();
126 main1 (8,7,6,5,4,3,2,1,0);
128 return 0;
131 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
132 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 6 "vect" } } */