1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
3
4 int arr1[105] = {2, 3, 5, 7, 11, 13, 17, 19};
5 int arr2[105] = {2, 3, 5, 7, 11, 13, 17, 19};
6 int arr3[105] = {2, 3, 5, 7, 11, 13, 17, 19};
7
8 int result1[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10 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, -1, -2, -3, -4, -5};
15 int result2[105] = {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, 0, 0, 0, 0, 0,
17 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -3, -3, -5, -5};
22 int result3[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, -5};
29
30 extern void abort (void);
31
foo1(int * a)32 void __attribute__((noinline)) foo1 (int *a)
33 {
34 int i;
35 for (i = 0; i < 100; i++)
36 {
37 a[i] = 0;
38 a[i + 1] = -1;
39 a[i + 2] = -2;
40 a[i + 3] = -3;
41 a[i + 4] = -4;
42 a[i + 5] = -5;
43 }
44 }
45
foo2(int * a)46 void __attribute__((noinline)) foo2 (int *a)
47 {
48 int i;
49 for (i = 0; i < 100; i++)
50 {
51 a[i] = 0;
52 a[i + 1] = -1;
53 a[i + 3] = -3;
54 a[i + 5] = -5;
55 }
56 }
57
foo3(int * a)58 void __attribute__((noinline)) foo3 (int *a)
59 {
60 int i;
61 for (i = 0; i < 100; i++)
62 {
63 a[i] = 0;
64 a[i + 5] = -5;
65 }
66 }
67
check(int * a,int * res,int len)68 void check (int *a, int *res, int len)
69 {
70 int i;
71
72 for (i = 0; i < len; i++)
73 if (a[i] != res[i])
74 abort ();
75 }
76
main(void)77 int main (void)
78 {
79 foo1 (arr1);
80 check (arr1, result1, 10);
81
82 foo2 (arr2);
83 check (arr2, result2, 10);
84
85 foo3 (arr3);
86 check (arr3, result3, 10);
87
88 return 0;
89 }
90 /* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
91