| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops2-details -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
#include <stdlib.h> |
| 5 |
#include <stdio.h> |
| 6 |
|
| 7 |
int main() |
| 8 |
{ |
| 9 |
unsigned int x, y, idx, H = 1024, W = 1024; |
| 10 |
|
| 11 |
int * tmps = (int *)malloc(H*W*sizeof(int)); |
| 12 |
|
| 13 |
/* This loop gets parallelized even though output dependences exist |
| 14 |
between writes to 'tmps' that prevent parallelization. |
| 15 |
For example: tmps[1] = 1, ..., tmps[1] = 17. */ |
| 16 |
|
| 17 |
for(x = 1; x < H; x++) |
| 18 |
{ |
| 19 |
for(y = 1; y < W; y++) |
| 20 |
{ |
| 21 |
idx = x*W+y; |
| 22 |
tmps[idx % 4096] = idx; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
for(x = 1; x < 8; x++) |
| 27 |
printf("tmps[%d]=%d\n", x, tmps[x]); |
| 28 |
|
| 29 |
return 0; |
| 30 |
} |
| 31 |
/* Check that no loop gets parallelized. */ |
| 32 |
|
| 33 |
/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops2" } } */ |
| 34 |
/* { dg-final { scan-tree-dump-times "loopfn" 0 "optimized" } } */ |