2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-11.c
blob29408edcfceb3dded22325e19bb6d5cf556114fc
1 /* { dg-do run } */
2 /* { dg-require-effective-target vect_int } */
4 #include "tree-vect.h"
6 int x[1024], y[1024], z[1024];
8 int __attribute__((noinline,noclone))
9 foo (int n)
11 int sum = 0;
12 /* Can vectorize this. */
13 for (int i = 0; i < n; ++i)
14 sum = (y[i] - (x[i] - sum));
15 return sum;
18 int __attribute__((noinline,noclone))
19 bar (int n)
21 int sum = 0;
22 /* Cannot vectorize this, sum is negated. */
23 for (int i = 0; i < n; ++i)
24 sum = z[i] - (y[i] - (x[i] - sum));
25 return sum;
28 int
29 main()
31 check_vect ();
32 for (int i = 0; i < 1024; ++i)
34 x[i] = i;
35 y[i] = i + 1;
36 z[i] = 0;
37 __asm__ volatile ("" : : : "memory");
39 if (foo (1024) != 1024)
40 __builtin_abort ();
41 if (bar (1023) != -1 || bar (1024) != 0)
42 __builtin_abort ();
43 return 0;
46 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */