2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr64844.c
blobcd3eacd99aa2f6d586d08fb54967c3b8e07c4d88
1 /* { dg-require-effective-target vect_double } */
2 /* { dg-additional-options "-ffast-math" } */
4 #include "tree-vect.h"
6 extern void abort (void);
8 typedef __SIZE_TYPE__ size_t;
10 static double
11 compute(size_t n, double const * __restrict a, double const * __restrict b)
13 double res = 0.0;
14 size_t i;
15 for (i = 0; i < n; ++i)
16 res += a[i] + b[i];
17 return res;
20 void init(double *, double *);
22 int
23 main()
25 double ary1[1024];
26 double ary2[1024];
27 size_t i;
29 check_vect ();
31 // Initialize arrays
32 for (i = 0; i < 1024; ++i)
34 ary1[i] = 1 / (double)(i + 1);
35 ary2[i] = 1 + 1 / (double) (i + 1);
36 __asm__ volatile ("" : : : "memory");
39 // Compute two results using different starting elements
40 if ((int) compute (512, &ary1[0], &ary2[0]) != 525
41 || (int) compute(512, &ary1[1], &ary2[1]) != 523)
42 abort ();
44 return 0;
47 /* All targets should allow vectorizing this by some means of
48 dealing with the known misalignment in loop 2. */
50 /* { dg-final { scan-tree-dump-times "loop vectorized" 2 "vect" } } */