| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target avx } */ |
| 3 |
/* { dg-options "-O2 -ftree-vectorize -mavx -mtune=generic -ffast-math" } */ |
| 4 |
|
| 5 |
#include "avx-check.h" |
| 6 |
|
| 7 |
#define N 16 |
| 8 |
#define DIFF 242 |
| 9 |
|
| 10 |
double b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; |
| 11 |
double c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; |
| 12 |
|
| 13 |
void |
| 14 |
main1 (double x, double max_result) |
| 15 |
{ |
| 16 |
int i; |
| 17 |
double diff = 2; |
| 18 |
double max = x; |
| 19 |
double min = 10; |
| 20 |
|
| 21 |
for (i = 0; i < N; i++) { |
| 22 |
diff += (b[i] - c[i]); |
| 23 |
} |
| 24 |
|
| 25 |
for (i = 0; i < N; i++) { |
| 26 |
max = max < c[i] ? c[i] : max; |
| 27 |
} |
| 28 |
|
| 29 |
for (i = 0; i < N; i++) { |
| 30 |
min = min > c[i] ? c[i] : min; |
| 31 |
} |
| 32 |
|
| 33 |
/* check results: */ |
| 34 |
if (diff != DIFF) |
| 35 |
abort (); |
| 36 |
if (max != max_result) |
| 37 |
abort (); |
| 38 |
if (min != 0) |
| 39 |
abort (); |
| 40 |
} |
| 41 |
|
| 42 |
static void |
| 43 |
avx_test (void) |
| 44 |
{ |
| 45 |
main1 (100, 100); |
| 46 |
main1 (0, 15); |
| 47 |
} |