| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O3 -ftree-loop-distribution -fdump-tree-ldist-details" } */ |
| 3 |
|
| 4 |
extern void abort (void); |
| 5 |
|
| 6 |
int a[130], b[128], c[128]; |
| 7 |
|
| 8 |
int __attribute__((noinline,noclone)) |
| 9 |
foo (int len, int x) |
| 10 |
{ |
| 11 |
int i; |
| 12 |
for (i = 1; i <= len; ++i) |
| 13 |
{ |
| 14 |
a[i] = a[i + 2] + 1; |
| 15 |
b[i] = 0; |
| 16 |
a[i + 1] = a[i] - 3; |
| 17 |
if (i < x) |
| 18 |
c[i] = a[i]; |
| 19 |
} |
| 20 |
return i; |
| 21 |
} |
| 22 |
|
| 23 |
int main() |
| 24 |
{ |
| 25 |
int i; |
| 26 |
for (i = 0; i < 130; ++i) |
| 27 |
a[i] = i; |
| 28 |
foo (127, 67); |
| 29 |
if (a[0] != 0 || a[1] != 4 || a[127] != 130) |
| 30 |
abort (); |
| 31 |
return 0; |
| 32 |
} |
| 33 |
|
| 34 |
/* Loop splitting splits the iteration space so we end up with two |
| 35 |
loops entering loop distribution. Both should have the b[i] = 0 |
| 36 |
part split out as memset. */ |
| 37 |
/* { dg-final { scan-tree-dump-times "distributed: split to 1 loops and 1 library calls" 2 "ldist" } } */ |
| 38 |
/* { dg-final { scan-tree-dump-times "generated memset zero" 2 "ldist" } } */ |