| 1 |
/* { dg-additional-options "-fopenmp-simd -fno-tree-vectorize" } */ |
| 2 |
/* { dg-additional-options "-mavx" { target avx_runtime } } */ |
| 3 |
/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target i?86-*-* x86_64-*-* } } } */ |
| 4 |
|
| 5 |
#include "tree-vect.h" |
| 6 |
|
| 7 |
__attribute__((noipa)) int |
| 8 |
foo (int s, int m, int n, int *p) |
| 9 |
{ |
| 10 |
int r = 0, l = 0, i, j; |
| 11 |
#pragma omp simd reduction (+:r) linear(l) collapse(2) |
| 12 |
for (j = 0; j < 7; j++) |
| 13 |
for (i = m; i < n; i += s) |
| 14 |
{ |
| 15 |
p[l++] = i; |
| 16 |
r += i * 3; |
| 17 |
} |
| 18 |
return r; |
| 19 |
} |
| 20 |
|
| 21 |
int p[((10000 / 78) + 1) * 7]; |
| 22 |
|
| 23 |
int |
| 24 |
main () |
| 25 |
{ |
| 26 |
int i, j, r; |
| 27 |
check_vect (); |
| 28 |
r = foo (78, 0, 10000, p); |
| 29 |
for (j = 0; j < 7; j++) |
| 30 |
#pragma GCC novector |
| 31 |
for (i = 0; i < 10000 / 78; i++) |
| 32 |
if (p[j * (10000 / 78 + 1) + i] != 78 * i) |
| 33 |
abort (); |
| 34 |
if (r != (10000 / 78) * (10000 / 78 + 1) / 2 * 78 * 3 * 7) |
| 35 |
abort (); |
| 36 |
r = foo (87, 0, 10000, p); |
| 37 |
for (j = 0; j < 7; j++) |
| 38 |
#pragma GCC novector |
| 39 |
for (i = 0; i < 10000 / 87; i++) |
| 40 |
if (p[j * (10000 / 87 + 1) + i] != 87 * i) |
| 41 |
abort (); |
| 42 |
if (r != (10000 / 87) * (10000 / 87 + 1) / 2 * 87 * 3 * 7) |
| 43 |
abort (); |
| 44 |
return 0; |
| 45 |
} |