Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-3.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-tree-vectorize -fno-inline -fno-tree-loop-distribute-patterns -fpredictive-commoning -fdump-tree-pcom-details-blocks" } */
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
39 void check (int *a, int *res, int len)
40 {
41 int i;
42
43 #pragma GCC novector
44 for (i = 0; i < len; i++)
45 if (a[i] != res[i])
46 abort ();
47 }
48
49 void __attribute__((noinline)) foo1 (int *a)
50 {
51 int i;
52 for (i = 0; i < 100; i++)
53 {
54 a[i] = 0;
55 a[i + 1] = -1;
56 a[i + 2] = -2;
57 a[i + 3] = -3;
58 }
59 }
60
61 void __attribute__((noinline)) foo2 (int *a)
62 {
63 int i;
64 for (i = 0; i < 100; i++)
65 {
66 a[i] = 0;
67 a[i + 2] = -1;
68 a[i + 3] = -2;
69 }
70 }
71
72 void __attribute__((noinline)) foo3 (int *a)
73 {
74 int i;
75 for (i = 0; i < 100; i++)
76 {
77 a[i] = 0;
78 a[i + 1] = -1;
79 a[i + 3] = -2;
80 }
81 }
82
83 void __attribute__((noinline)) foo4 (int *a)
84 {
85 int i;
86 for (i = 0; i < 100; i++)
87 {
88 a[i] = 0;
89 a[i + 3] = -1;
90 }
91 }
92
93 int main (void)
94 {
95 foo1 (arr1);
96 check (arr1, result1, 105);
97
98 foo2 (arr2);
99 check (arr2, result2, 105);
100
101 foo3 (arr3);
102 check (arr3, result3, 105);
103
104 foo4 (arr4);
105 check (arr4, result4, 105);
106
107 return 0;
108 }
109 /* { dg-final { scan-tree-dump-times "Store-stores chain" 4 "pcom"} } */
110 /* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */