| 1 |
/* { dg-additional-options "-ffast-math" } */ |
| 2 |
/* { dg-require-effective-target vect_double } */ |
| 3 |
|
| 4 |
/* need -funsafe-math-optimizations to vectorize the summation. |
| 5 |
also need -ffinite-math-only to create the min/max expr. */ |
| 6 |
|
| 7 |
#include <stdarg.h> |
| 8 |
#include "tree-vect.h" |
| 9 |
|
| 10 |
#define N 16 |
| 11 |
#define DIFF 242 |
| 12 |
|
| 13 |
double b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; |
| 14 |
double c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; |
| 15 |
|
| 16 |
int main1 (double x, double max_result) |
| 17 |
{ |
| 18 |
int i; |
| 19 |
double diff = 2; |
| 20 |
double max = x; |
| 21 |
double min = 10; |
| 22 |
|
| 23 |
for (i = 0; i < N; i++) { |
| 24 |
diff += (b[i] - c[i]); |
| 25 |
} |
| 26 |
|
| 27 |
for (i = 0; i < N; i++) { |
| 28 |
max = max < c[i] ? c[i] : max; |
| 29 |
} |
| 30 |
|
| 31 |
for (i = 0; i < N; i++) { |
| 32 |
min = min > c[i] ? c[i] : min; |
| 33 |
} |
| 34 |
|
| 35 |
/* check results: */ |
| 36 |
if (diff != DIFF) |
| 37 |
abort (); |
| 38 |
if (max != max_result) |
| 39 |
abort (); |
| 40 |
if (min != 0) |
| 41 |
abort (); |
| 42 |
|
| 43 |
return 0; |
| 44 |
} |
| 45 |
|
| 46 |
int main (void) |
| 47 |
{ |
| 48 |
check_vect (); |
| 49 |
|
| 50 |
main1 (100, 100); |
| 51 |
main1 (0, 15); |
| 52 |
return 0; |
| 53 |
} |
| 54 |
|
| 55 |
/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ |