| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details-blocks" } */ |
| 3 |
|
| 4 |
int arr[105] = {2, 3, 5, 7, 11}; |
| 5 |
int result0[10] = {2, 3, 5, 7, 11}; |
| 6 |
int result1[10] = {0, -1, 5, -2, 11, 0}; |
| 7 |
int result2[10] = {0, 0, -1, -2, -2, 0}; |
| 8 |
int result3[10] = {0, 0, 0, -1, -2, -2, 0}; |
| 9 |
int result4[10] = {0, 0, 0, 0, -1, -2, -2, 0}; |
| 10 |
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 11 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 12 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 13 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 14 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 15 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 16 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, 0}; |
| 17 |
|
| 18 |
extern void abort (void); |
| 19 |
int sum; |
| 20 |
|
| 21 |
void __attribute__((noinline)) foo (int * restrict a, int len, int t1, int t2) |
| 22 |
{ |
| 23 |
int i; |
| 24 |
for (i = 0; i < len; i++) |
| 25 |
{ |
| 26 |
a[i] = t1; |
| 27 |
a[i + 3] = t2; |
| 28 |
a[i + 1] = -1; |
| 29 |
sum = sum + a[i] + a[i + 3]; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void check (int *a, int *res, int len, int sval) |
| 34 |
{ |
| 35 |
int i; |
| 36 |
|
| 37 |
if (sum != sval) |
| 38 |
abort (); |
| 39 |
|
| 40 |
#pragma GCC novector |
| 41 |
for (i = 0; i < len; i++) |
| 42 |
if (a[i] != res[i]) |
| 43 |
abort (); |
| 44 |
} |
| 45 |
|
| 46 |
int main (void) |
| 47 |
{ |
| 48 |
foo (arr, 0, 0, -2); |
| 49 |
check (arr, result0, 10, 0); |
| 50 |
|
| 51 |
foo (arr, 1, 0, -2); |
| 52 |
check (arr, result1, 10, -2); |
| 53 |
|
| 54 |
foo (arr, 2, 0, -2); |
| 55 |
check (arr, result2, 10, -6); |
| 56 |
|
| 57 |
foo (arr, 3, 0, -2); |
| 58 |
check (arr, result3, 10, -12); |
| 59 |
|
| 60 |
foo (arr, 4, 0, -2); |
| 61 |
check (arr, result4, 10, -20); |
| 62 |
|
| 63 |
foo (arr, 100, 0, -2); |
| 64 |
check (arr, result100, 105, -220); |
| 65 |
|
| 66 |
return 0; |
| 67 |
} |
| 68 |
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */ |
| 69 |
/* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */ |