blob: 146b76c49f6c36d0cab6e0d1925930fc2bf07b37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized -std=gnu89" } */
extern void link_error (void);
/* check that cprop for variables of different types still works even
if function calls or assignments to different types of data are
interposed. */
int test7 (int *intarr)
{
extern int foo7 (int);
int u = 7, v1;
foo7 (u);
v1 = u;
if (v1 != 7)
link_error ();
return v1;
}
int test77 (int *arr)
{
int u = 7, v1;
arr[0] = 4;
v1 = u;
if (v1 != 7)
link_error ();
return v1 + arr[0];
}
int test777 (void)
{
extern int foo(int *);
int u = 7, v1;
static int sarr[10];
sarr[0] = 4;
v1 = u;
if (v1 != 7)
link_error ();
foo (sarr);
return v1 + sarr[0];
}
int garr[10];
int test7777 (void)
{
int u = 7, v1;
garr[0] = 4;
v1 = u;
if (v1 != 7)
link_error ();
return v1 + garr[0];
}
int test88 (int *arr)
{
static int l;
int v1;
l = 8;
arr[0] = 4;
v1 = l;
if (v1 != 8)
link_error ();
l = foo88 (l);
return v1 + arr[0];
}
int test888 (void)
{
static int l;
extern int foo(int *);
int v1;
static int sarr[10];
l = 8;
sarr[0] = 4;
v1 = l;
if (v1 != 8)
link_error ();
foo (sarr);
l = foo88(l);
return v1 + sarr[0];
}
int test8888 (void)
{
static int l;
int v1;
l = 8;
garr[0] = 4;
v1 = l;
if (v1 != 8)
link_error ();
return v1 + garr[0];
}
/* global var */
int g9;
int garr9[10];
int test9 (int *intarr)
{
extern int foo9 (int) __attribute__ ((const));
int h, v;
g9 = 9;
h = foo9 (g9);
v = g9;
if (v != 9)
link_error ();
return g9;
}
int test99 (int *intarr)
{
extern int foo9 (int) __attribute__ ((pure));
int h, v;
g9 = 9;
h = foo9 (g9);
v = g9;
if (v != 9)
link_error ();
return g9;
}
extern int foo99 (int);
int test999 (int *arr)
{
static int l;
int v1;
g9 = 9;
l = 4;
v1 = g9;
if (v1 != 9)
link_error ();
l = foo99 (l);
return v1 + l;
}
int test9999 (void)
{
int v1;
static int sarr[10];
g9 = 9;
sarr[0] = 4;
v1 = g9;
if (v1 != 9)
link_error ();
foo (sarr);
g9 = foo99 (g9);
return v1 + sarr[0];
}
int test99999 (void)
{
int v1;
g9 = 9;
garr9[0] = 4;
v1 = g9;
if (v1 != 9)
link_error ();
return v1 + garr9[0];
}
/* There should be not link_error calls, if there is any the
optimization has failed */
/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
|