Merge from mainline.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-ccp-2.c
blob19975a39215163690408a8ea4cd01c03347934c3
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
4 extern void link_error (void);
7 /* check that cprop for variables of different types still works even
8 if function calls or assignments to different types of data are
9 interposed. */
11 int test7 (int *intarr)
13 extern int foo7 (int);
14 int u = 7, v1;
15 foo7 (u);
16 v1 = u;
17 if (v1 != 7)
18 link_error ();
19 return v1;
22 int test77 (int *arr)
24 int u = 7, v1;
25 arr[0] = 4;
26 v1 = u;
27 if (v1 != 7)
28 link_error ();
29 return v1 + arr[0];
32 int test777 (void)
34 extern int foo(int *);
35 int u = 7, v1;
36 static int sarr[10];
37 sarr[0] = 4;
38 v1 = u;
39 if (v1 != 7)
40 link_error ();
41 foo (sarr);
42 return v1 + sarr[0];
45 int garr[10];
46 int test7777 (void)
48 int u = 7, v1;
49 garr[0] = 4;
50 v1 = u;
51 if (v1 != 7)
52 link_error ();
53 return v1 + garr[0];
56 int test88 (int *arr)
58 static int l;
59 int v1;
60 l = 8;
61 arr[0] = 4;
62 v1 = l;
63 if (v1 != 8)
64 link_error ();
65 l = foo88 (l);
66 return v1 + arr[0];
69 int test888 (void)
71 static int l;
72 extern int foo(int *);
73 int v1;
74 static int sarr[10];
75 l = 8;
76 sarr[0] = 4;
77 v1 = l;
78 if (v1 != 8)
79 link_error ();
80 foo (sarr);
81 l = foo88(l);
82 return v1 + sarr[0];
85 int test8888 (void)
87 static int l;
88 int v1;
89 l = 8;
90 garr[0] = 4;
91 v1 = l;
92 if (v1 != 8)
93 link_error ();
94 return v1 + garr[0];
99 /* global var */
100 int g9;
101 int garr9[10];
102 int test9 (int *intarr)
104 extern int foo9 (int) __attribute__ ((const));
105 int h, v;
106 g9 = 9;
107 h = foo9 (g9);
108 v = g9;
109 if (v != 9)
110 link_error ();
111 return g9;
114 int test99 (int *intarr)
116 extern int foo9 (int) __attribute__ ((pure));
117 int h, v;
118 g9 = 9;
119 h = foo9 (g9);
120 v = g9;
121 if (v != 9)
122 link_error ();
123 return g9;
126 extern int foo99 (int);
128 int test999 (int *arr)
130 static int l;
131 int v1;
132 g9 = 9;
133 l = 4;
134 v1 = g9;
135 if (v1 != 9)
136 link_error ();
137 l = foo99 (l);
138 return v1 + l;
142 int test9999 (void)
144 int v1;
145 static int sarr[10];
146 g9 = 9;
147 sarr[0] = 4;
148 v1 = g9;
149 if (v1 != 9)
150 link_error ();
151 foo (sarr);
152 g9 = foo99 (g9);
153 return v1 + sarr[0];
157 int test99999 (void)
159 int v1;
160 g9 = 9;
161 garr9[0] = 4;
162 v1 = g9;
163 if (v1 != 9)
164 link_error ();
165 return v1 + garr9[0];
169 /* There should be not link_error calls, if there is any the
170 optimization has failed */
171 /* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
172 /* { dg-final { cleanup-tree-dump "optimized" } } */