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