| 1 |
/* { dg-require-effective-target vect_double } */ |
| 2 |
/* { dg-additional-options "-ffast-math" } */ |
| 3 |
|
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
extern void abort (void); |
| 7 |
|
| 8 |
typedef __SIZE_TYPE__ size_t; |
| 9 |
|
| 10 |
static double |
| 11 |
compute(size_t n, double const * __restrict a, double const * __restrict b) |
| 12 |
{ |
| 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; |
| 18 |
} |
| 19 |
|
| 20 |
void init(double *, double *); |
| 21 |
|
| 22 |
int |
| 23 |
main() |
| 24 |
{ |
| 25 |
double ary1[1024]; |
| 26 |
double ary2[1024]; |
| 27 |
size_t i; |
| 28 |
|
| 29 |
check_vect (); |
| 30 |
|
| 31 |
// Initialize arrays |
| 32 |
for (i = 0; i < 1024; ++i) |
| 33 |
{ |
| 34 |
ary1[i] = 1 / (double)(i + 1); |
| 35 |
ary2[i] = 1 + 1 / (double) (i + 1); |
| 36 |
__asm__ volatile ("" : : : "memory"); |
| 37 |
} |
| 38 |
|
| 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 (); |
| 43 |
|
| 44 |
return 0; |
| 45 |
} |
| 46 |
|
| 47 |
/* All targets should allow vectorizing this by some means of |
| 48 |
dealing with the known misalignment in loop 2. */ |
| 49 |
|
| 50 |
/* { dg-final { scan-tree-dump-times "loop vectorized" 2 "vect" } } */ |