Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / slp-reduc-6.c
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 a[N], b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
9
10 /* Vectorization of reduction. Loop-aware SLP is not possible, because of 
11    different arrays.  */
12
13 __attribute__ ((noinline))
14 int main1 (int n, int res0, int res1)
15 {
16   int i;
17   int sum0 = 0, sum1 = 0;
18
19   for (i = 0; i < n; i++) {
20     sum1 += a[2*i];
21     sum0 += b[2*i];
22   }
23
24   /* Check results:  */
25   if (sum0 != res0
26       || sum1 != res1)
27     abort ();
28
29   return 0;
30 }
31
32 int main (void)
33 {
34   int i;
35
36   check_vect ();
37
38   for (i = 0; i < N; i++)
39     a[i] = b[i] = i;
40
41   main1 (N/2, 4032, 4032);
42   return 0;
43 }
44
45 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_no_int_add || { ! { vect_unpack || vect_strided2 } } } } } } */
46 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */
47 /* { dg-final { scan-tree-dump-times "different interleaving chains in one node" 1 "vect" { target { ! vect_no_int_add } } } } */
48 /* { dg-final { cleanup-tree-dump "vect" } } */
49