| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target avx2 } */ |
| 3 |
/* { dg-options "-mavx2 -O3 -fopenmp-simd -fdump-tree-vect-details -fdisable-tree-thread1 -fno-split-loops" } */ |
| 4 |
|
| 5 |
#include "avx2-check.h" |
| 6 |
#define N 64 |
| 7 |
float a[N]; |
| 8 |
int c[N]; |
| 9 |
|
| 10 |
__attribute__ ((noinline)) int |
| 11 |
foo () |
| 12 |
{ |
| 13 |
int i, res = 0; |
| 14 |
#pragma omp simd safelen(8) |
| 15 |
for (i=0; i<N; i++) |
| 16 |
{ |
| 17 |
float t = a[i]; |
| 18 |
if (t > 0.0f & t < 1.0e+2f) |
| 19 |
if (c[i] != 0) |
| 20 |
res += 1; |
| 21 |
} |
| 22 |
return res; |
| 23 |
} |
| 24 |
|
| 25 |
__attribute__ ((noinline)) float |
| 26 |
hundred () |
| 27 |
{ |
| 28 |
return 100.0f; |
| 29 |
} |
| 30 |
|
| 31 |
static void |
| 32 |
avx2_test (void) |
| 33 |
{ |
| 34 |
int i, res; |
| 35 |
for (i=0; i<N; i++) |
| 36 |
{ |
| 37 |
c[i] = i % 4; |
| 38 |
if (i < N / 2) |
| 39 |
a[i] = (float) (i + 1); |
| 40 |
else |
| 41 |
a[i] = (float) i + hundred (); |
| 42 |
} |
| 43 |
if (foo () != 24) |
| 44 |
abort (); |
| 45 |
} |
| 46 |
|
| 47 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ |
| 48 |
|