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, 0};
5 int arr2[105] = {2, 3, 5, 7, 11, 13, 0};
6 int arr3[105] = {2, 3, 5, 7, 11, 13, 0};
7 int arr4[105] = {2, 3, 5, 7, 11, 13, 0};
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, 0};
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, -1, -2, 0};
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, -1, -2, -2, 0};
29 int result4[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0};
36
37 extern void abort (void);
38
check(int * a,int * res,int len)39 void check (int *a, int *res, int len)
40 {
41 int i;
42
43 for (i = 0; i < len; i++)
44 if (a[i] != res[i])
45 abort ();
46 }
47
foo1(int * a)48 void __attribute__((noinline)) foo1 (int *a)
49 {
50 int i;
51 for (i = 0; i < 100; i++)
52 {
53 a[i] = 0;
54 a[i + 1] = -1;
55 a[i + 2] = -2;
56 a[i + 3] = -3;
57 }
58 }
59
foo2(int * a)60 void __attribute__((noinline)) foo2 (int *a)
61 {
62 int i;
63 for (i = 0; i < 100; i++)
64 {
65 a[i] = 0;
66 a[i + 2] = -1;
67 a[i + 3] = -2;
68 }
69 }
70
foo3(int * a)71 void __attribute__((noinline)) foo3 (int *a)
72 {
73 int i;
74 for (i = 0; i < 100; i++)
75 {
76 a[i] = 0;
77 a[i + 1] = -1;
78 a[i + 3] = -2;
79 }
80 }
81
foo4(int * a)82 void __attribute__((noinline)) foo4 (int *a)
83 {
84 int i;
85 for (i = 0; i < 100; i++)
86 {
87 a[i] = 0;
88 a[i + 3] = -1;
89 }
90 }
91
main(void)92 int main (void)
93 {
94 foo1 (arr1);
95 check (arr1, result1, 105);
96
97 foo2 (arr2);
98 check (arr2, result2, 105);
99
100 foo3 (arr3);
101 check (arr3, result3, 105);
102
103 foo4 (arr4);
104 check (arr4, result4, 105);
105
106 return 0;
107 }
108 /* { dg-final { scan-tree-dump-times "Store-stores chain" 4 "pcom"} } */
109