| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-additional-options "-O2 -fvect-cost-model=cheap -fdump-tree-vect-details" } */ |
| 3 |
/* { dg-additional-options "-mavx" { target avx_runtime } } */ |
| 4 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" { target avx_runtime } } } */ |
| 5 |
|
| 6 |
int v, x; |
| 7 |
|
| 8 |
__attribute__((noipa)) int |
| 9 |
foo (int *a) |
| 10 |
{ |
| 11 |
#pragma omp parallel for simd lastprivate (conditional: x) schedule(simd: static) |
| 12 |
for (int i = 0; i < 128; i++) |
| 13 |
if (a[i]) |
| 14 |
x = a[i]; |
| 15 |
return x; |
| 16 |
} |
| 17 |
|
| 18 |
__attribute__((noipa)) int |
| 19 |
bar (int *a, int *b) |
| 20 |
{ |
| 21 |
#pragma omp parallel |
| 22 |
#pragma omp for simd lastprivate (conditional: x, v) schedule(static, 16) |
| 23 |
for (int i = 16; i < 128; ++i) |
| 24 |
{ |
| 25 |
if (a[i]) |
| 26 |
x = a[i]; |
| 27 |
if (b[i]) |
| 28 |
v = b[i] + 10; |
| 29 |
} |
| 30 |
return x; |
| 31 |
} |
| 32 |
|
| 33 |
__attribute__((noipa)) int |
| 34 |
baz (int *a) |
| 35 |
{ |
| 36 |
#pragma omp parallel for simd lastprivate (conditional: x) schedule(simd: dynamic, 16) |
| 37 |
for (int i = 0; i < 128; i++) |
| 38 |
if (a[i]) |
| 39 |
x = a[i] + 5; |
| 40 |
return x; |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
main () |
| 45 |
{ |
| 46 |
int a[128], b[128], i; |
| 47 |
for (i = 0; i < 128; i++) |
| 48 |
{ |
| 49 |
a[i] = ((i % 11) == 2) ? i + 10 : 0; |
| 50 |
asm volatile ("" : "+g" (i)); |
| 51 |
b[i] = ((i % 13) == 5) ? i * 2 : 0; |
| 52 |
} |
| 53 |
if (foo (a) != 133) |
| 54 |
__builtin_abort (); |
| 55 |
if (bar (b, a) != 244 || v != 143) |
| 56 |
__builtin_abort (); |
| 57 |
if (baz (b) != 249) |
| 58 |
__builtin_abort (); |
| 59 |
return 0; |
| 60 |
} |