| 1 |
/* PR middle-end/66199 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
int u[1024], v[1024], w[1024]; |
| 5 |
|
| 6 |
__attribute__((noinline, noclone)) long |
| 7 |
f1 (long a, long b) |
| 8 |
{ |
| 9 |
long d; |
| 10 |
#pragma omp parallel for simd default(none) firstprivate (a, b) shared(u, v, w) |
| 11 |
for (d = a; d < b; d++) |
| 12 |
u[d] = v[d] + w[d]; |
| 13 |
return d; |
| 14 |
} |
| 15 |
|
| 16 |
__attribute__((noinline, noclone)) long |
| 17 |
f2 (long a, long b, long c) |
| 18 |
{ |
| 19 |
long d, e; |
| 20 |
#pragma omp parallel for simd default(none) firstprivate (a, b) shared(u, v, w) linear(d) linear(c:5) lastprivate(e) |
| 21 |
for (d = a; d < b; d++) |
| 22 |
{ |
| 23 |
u[d] = v[d] + w[d]; |
| 24 |
c += 5; |
| 25 |
e = c; |
| 26 |
} |
| 27 |
return d + c + e; |
| 28 |
} |
| 29 |
|
| 30 |
__attribute__((noinline, noclone)) long |
| 31 |
f3 (long a1, long b1, long a2, long b2) |
| 32 |
{ |
| 33 |
long d1, d2; |
| 34 |
#pragma omp parallel for simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2) |
| 35 |
for (d1 = a1; d1 < b1; d1++) |
| 36 |
for (d2 = a2; d2 < b2; d2++) |
| 37 |
u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2]; |
| 38 |
return d1 + d2; |
| 39 |
} |
| 40 |
|
| 41 |
__attribute__((noinline, noclone)) long |
| 42 |
f4 (long a1, long b1, long a2, long b2) |
| 43 |
{ |
| 44 |
long d1, d2; |
| 45 |
#pragma omp parallel for simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2) |
| 46 |
for (d1 = a1; d1 < b1; d1++) |
| 47 |
for (d2 = a2; d2 < b2; d2++) |
| 48 |
u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2]; |
| 49 |
return d1 + d2; |
| 50 |
} |
| 51 |
|
| 52 |
int |
| 53 |
main () |
| 54 |
{ |
| 55 |
if (f1 (0, 1024) != 1024 |
| 56 |
|| f2 (0, 1024, 17) != 1024 + 2 * (17 + 5 * 1024) |
| 57 |
|| f3 (0, 32, 0, 32) != 64 |
| 58 |
|| f4 (0, 32, 0, 32) != 64) |
| 59 |
__builtin_abort (); |
| 60 |
return 0; |
| 61 |
} |