2017-12-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-28.c
blobe66728e1656fa1ea04e2a46d43284f067b4837e3
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #if VECTOR_BITS > 128
7 #define N (VECTOR_BITS * 4 / 16)
8 #else
9 #define N 32
10 #endif
12 unsigned short in[N] = {};
13 unsigned short in2[N] = {};
14 unsigned short in3[N] = {};
16 int
17 main1 ()
19 int i;
21 for (i = 0; i < N; i++)
23 in[i] = in2[i] = in3[i] = i;
24 asm volatile ("" ::: "memory");
27 for (i = 0; i < N/4; i++)
29 in[i*4] = in[i*4] + 5;
30 in[i*4 + 1] = in[i*4 + 1] + 5;
31 in[i*4 + 2] = in[i*4 + 2] + 5;
32 in[i*4 + 3] = in[i*4 + 3] + 5;
36 /* check results: */
37 for (i = 0; i < N; i++)
39 if (in[i] != i+5)
40 abort ();
43 /* Not vectorizable because of data dependencies. */
44 for (i = 1; i < N/4; i++)
46 in2[i*4] = in2[(i-1)*4] + 5;
47 in2[i*4 + 1] = in2[(i-1)*4 + 1] + 5;
48 in2[i*4 + 2] = in2[(i-1)*4 + 2] + 5;
49 in2[i*4 + 3] = in2[(i-1)*4 + 3] + 5;
53 /* check results: */
54 for (i = 0; i < N; i++)
56 if (in2[i] != (i % 4) + (i / 4) * 5)
57 abort ();
60 /* Not vectorizable because of data dependencies: distance 3 is greater than
61 the actual VF with SLP (2), but the analysis fail to detect that for now. */
62 for (i = 3; i < N/4; i++)
64 in3[i*4] = in3[(i-3)*4] + 5;
65 in3[i*4 + 1] = in3[(i-3)*4 + 1] + 5;
66 in3[i*4 + 2] = in3[(i-3)*4 + 2] + 5;
67 in3[i*4 + 3] = in3[(i-3)*4 + 3] + 5;
71 /* check results: */
72 for (i = 0; i < N; i++)
74 if (in3[i] != (i % 12) + (i / 12) * 5)
75 abort ();
79 return 0;
82 int main (void)
84 check_vect ();
86 main1 ();
88 return 0;
91 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
92 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */