Mercurial > hg > CbC > CbC_gcc
annotate gcc/tree-ssa-forwprop.c @ 128:fe568345ddd5
fix CbC-example
author | mir3636 |
---|---|
date | Wed, 11 Apr 2018 19:32:28 +0900 |
parents | 04ced10e8804 |
children | 84e7813d76e9 |
rev | line source |
---|---|
0 | 1 /* Forward propagation of expressions for single use variables. |
111 | 2 Copyright (C) 2004-2017 Free Software Foundation, Inc. |
0 | 3 |
4 This file is part of GCC. | |
5 | |
6 GCC is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 3, or (at your option) | |
9 any later version. | |
10 | |
11 GCC is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GCC; see the file COPYING3. If not see | |
18 <http://www.gnu.org/licenses/>. */ | |
19 | |
20 #include "config.h" | |
21 #include "system.h" | |
22 #include "coretypes.h" | |
111 | 23 #include "backend.h" |
24 #include "rtl.h" | |
0 | 25 #include "tree.h" |
111 | 26 #include "gimple.h" |
27 #include "cfghooks.h" | |
0 | 28 #include "tree-pass.h" |
111 | 29 #include "ssa.h" |
30 #include "expmed.h" | |
31 #include "optabs-query.h" | |
32 #include "gimple-pretty-print.h" | |
33 #include "fold-const.h" | |
34 #include "stor-layout.h" | |
35 #include "gimple-fold.h" | |
36 #include "tree-eh.h" | |
37 #include "gimplify.h" | |
38 #include "gimple-iterator.h" | |
39 #include "gimplify-me.h" | |
40 #include "tree-cfg.h" | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
41 #include "expr.h" |
111 | 42 #include "tree-dfa.h" |
43 #include "tree-ssa-propagate.h" | |
44 #include "tree-ssa-dom.h" | |
45 #include "builtins.h" | |
46 #include "tree-cfgcleanup.h" | |
47 #include "cfganal.h" | |
48 #include "optabs-tree.h" | |
0 | 49 |
50 /* This pass propagates the RHS of assignment statements into use | |
51 sites of the LHS of the assignment. It's basically a specialized | |
52 form of tree combination. It is hoped all of this can disappear | |
53 when we have a generalized tree combiner. | |
54 | |
55 One class of common cases we handle is forward propagating a single use | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
56 variable into a COND_EXPR. |
0 | 57 |
58 bb0: | |
59 x = a COND b; | |
60 if (x) goto ... else goto ... | |
61 | |
62 Will be transformed into: | |
63 | |
64 bb0: | |
65 if (a COND b) goto ... else goto ... | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
66 |
0 | 67 Similarly for the tests (x == 0), (x != 0), (x == 1) and (x != 1). |
68 | |
69 Or (assuming c1 and c2 are constants): | |
70 | |
71 bb0: | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
72 x = a + c1; |
0 | 73 if (x EQ/NEQ c2) goto ... else goto ... |
74 | |
75 Will be transformed into: | |
76 | |
77 bb0: | |
78 if (a EQ/NEQ (c2 - c1)) goto ... else goto ... | |
79 | |
80 Similarly for x = a - c1. | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
81 |
0 | 82 Or |
83 | |
84 bb0: | |
85 x = !a | |
86 if (x) goto ... else goto ... | |
87 | |
88 Will be transformed into: | |
89 | |
90 bb0: | |
91 if (a == 0) goto ... else goto ... | |
92 | |
93 Similarly for the tests (x == 0), (x != 0), (x == 1) and (x != 1). | |
94 For these cases, we propagate A into all, possibly more than one, | |
95 COND_EXPRs that use X. | |
96 | |
97 Or | |
98 | |
99 bb0: | |
100 x = (typecast) a | |
101 if (x) goto ... else goto ... | |
102 | |
103 Will be transformed into: | |
104 | |
105 bb0: | |
106 if (a != 0) goto ... else goto ... | |
107 | |
108 (Assuming a is an integral type and x is a boolean or x is an | |
109 integral and a is a boolean.) | |
110 | |
111 Similarly for the tests (x == 0), (x != 0), (x == 1) and (x != 1). | |
112 For these cases, we propagate A into all, possibly more than one, | |
113 COND_EXPRs that use X. | |
114 | |
115 In addition to eliminating the variable and the statement which assigns | |
116 a value to the variable, we may be able to later thread the jump without | |
117 adding insane complexity in the dominator optimizer. | |
118 | |
119 Also note these transformations can cascade. We handle this by having | |
120 a worklist of COND_EXPR statements to examine. As we make a change to | |
121 a statement, we put it back on the worklist to examine on the next | |
122 iteration of the main loop. | |
123 | |
124 A second class of propagation opportunities arises for ADDR_EXPR | |
125 nodes. | |
126 | |
127 ptr = &x->y->z; | |
128 res = *ptr; | |
129 | |
130 Will get turned into | |
131 | |
132 res = x->y->z; | |
133 | |
134 Or | |
135 ptr = (type1*)&type2var; | |
136 res = *ptr | |
137 | |
138 Will get turned into (if type1 and type2 are the same size | |
139 and neither have volatile on them): | |
140 res = VIEW_CONVERT_EXPR<type1>(type2var) | |
141 | |
142 Or | |
143 | |
144 ptr = &x[0]; | |
145 ptr2 = ptr + <constant>; | |
146 | |
147 Will get turned into | |
148 | |
149 ptr2 = &x[constant/elementsize]; | |
150 | |
151 Or | |
152 | |
153 ptr = &x[0]; | |
154 offset = index * element_size; | |
155 offset_p = (pointer) offset; | |
156 ptr2 = ptr + offset_p | |
157 | |
158 Will get turned into: | |
159 | |
160 ptr2 = &x[index]; | |
161 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
162 Or |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
163 ssa = (int) decl |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
164 res = ssa & 1 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
165 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
166 Provided that decl has known alignment >= 2, will get turned into |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
167 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
168 res = 0 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
169 |
0 | 170 We also propagate casts into SWITCH_EXPR and COND_EXPR conditions to |
171 allow us to remove the cast and {NOT_EXPR,NEG_EXPR} into a subsequent | |
172 {NOT_EXPR,NEG_EXPR}. | |
173 | |
174 This will (of course) be extended as other needs arise. */ | |
175 | |
111 | 176 static bool forward_propagate_addr_expr (tree, tree, bool); |
0 | 177 |
111 | 178 /* Set to true if we delete dead edges during the optimization. */ |
0 | 179 static bool cfg_changed; |
180 | |
111 | 181 static tree rhs_to_tree (tree type, gimple *stmt); |
0 | 182 |
111 | 183 static bitmap to_purge; |
0 | 184 |
111 | 185 /* Const-and-copy lattice. */ |
186 static vec<tree> lattice; | |
0 | 187 |
111 | 188 /* Set the lattice entry for NAME to VAL. */ |
189 static void | |
190 fwprop_set_lattice_val (tree name, tree val) | |
191 { | |
192 if (TREE_CODE (name) == SSA_NAME) | |
193 { | |
194 if (SSA_NAME_VERSION (name) >= lattice.length ()) | |
195 { | |
196 lattice.reserve (num_ssa_names - lattice.length ()); | |
197 lattice.quick_grow_cleared (num_ssa_names); | |
198 } | |
199 lattice[SSA_NAME_VERSION (name)] = val; | |
200 } | |
201 } | |
0 | 202 |
111 | 203 /* Invalidate the lattice entry for NAME, done when releasing SSA names. */ |
204 static void | |
205 fwprop_invalidate_lattice (tree name) | |
206 { | |
207 if (name | |
208 && TREE_CODE (name) == SSA_NAME | |
209 && SSA_NAME_VERSION (name) < lattice.length ()) | |
210 lattice[SSA_NAME_VERSION (name)] = NULL_TREE; | |
211 } | |
0 | 212 |
213 | |
214 /* Get the statement we can propagate from into NAME skipping | |
215 trivial copies. Returns the statement which defines the | |
216 propagation source or NULL_TREE if there is no such one. | |
217 If SINGLE_USE_ONLY is set considers only sources which have | |
218 a single use chain up to NAME. If SINGLE_USE_P is non-null, | |
219 it is set to whether the chain to NAME is a single use chain | |
220 or not. SINGLE_USE_P is not written to if SINGLE_USE_ONLY is set. */ | |
221 | |
111 | 222 static gimple * |
0 | 223 get_prop_source_stmt (tree name, bool single_use_only, bool *single_use_p) |
224 { | |
225 bool single_use = true; | |
226 | |
227 do { | |
111 | 228 gimple *def_stmt = SSA_NAME_DEF_STMT (name); |
0 | 229 |
230 if (!has_single_use (name)) | |
231 { | |
232 single_use = false; | |
233 if (single_use_only) | |
234 return NULL; | |
235 } | |
236 | |
237 /* If name is defined by a PHI node or is the default def, bail out. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
238 if (!is_gimple_assign (def_stmt)) |
0 | 239 return NULL; |
240 | |
111 | 241 /* If def_stmt is a simple copy, continue looking. */ |
242 if (gimple_assign_rhs_code (def_stmt) == SSA_NAME) | |
243 name = gimple_assign_rhs1 (def_stmt); | |
244 else | |
0 | 245 { |
246 if (!single_use_only && single_use_p) | |
247 *single_use_p = single_use; | |
248 | |
111 | 249 return def_stmt; |
0 | 250 } |
251 } while (1); | |
252 } | |
253 | |
254 /* Checks if the destination ssa name in DEF_STMT can be used as | |
255 propagation source. Returns true if so, otherwise false. */ | |
256 | |
257 static bool | |
111 | 258 can_propagate_from (gimple *def_stmt) |
0 | 259 { |
260 gcc_assert (is_gimple_assign (def_stmt)); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
261 |
0 | 262 /* If the rhs has side-effects we cannot propagate from it. */ |
263 if (gimple_has_volatile_ops (def_stmt)) | |
264 return false; | |
265 | |
266 /* If the rhs is a load we cannot propagate from it. */ | |
267 if (TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) == tcc_reference | |
268 || TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) == tcc_declaration) | |
269 return false; | |
270 | |
271 /* Constants can be always propagated. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
272 if (gimple_assign_single_p (def_stmt) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
273 && is_gimple_min_invariant (gimple_assign_rhs1 (def_stmt))) |
0 | 274 return true; |
275 | |
276 /* We cannot propagate ssa names that occur in abnormal phi nodes. */ | |
111 | 277 if (stmt_references_abnormal_ssa_name (def_stmt)) |
278 return false; | |
0 | 279 |
280 /* If the definition is a conversion of a pointer to a function type, | |
281 then we can not apply optimizations as some targets require | |
282 function pointers to be canonicalized and in this case this | |
283 optimization could eliminate a necessary canonicalization. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
284 if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))) |
0 | 285 { |
286 tree rhs = gimple_assign_rhs1 (def_stmt); | |
287 if (POINTER_TYPE_P (TREE_TYPE (rhs)) | |
288 && TREE_CODE (TREE_TYPE (TREE_TYPE (rhs))) == FUNCTION_TYPE) | |
289 return false; | |
290 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
291 |
0 | 292 return true; |
293 } | |
294 | |
111 | 295 /* Remove a chain of dead statements starting at the definition of |
296 NAME. The chain is linked via the first operand of the defining statements. | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
297 If NAME was replaced in its only use then this function can be used |
111 | 298 to clean up dead stmts. The function handles already released SSA |
299 names gracefully. | |
300 Returns true if cleanup-cfg has to run. */ | |
0 | 301 |
302 static bool | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
303 remove_prop_source_from_use (tree name) |
0 | 304 { |
305 gimple_stmt_iterator gsi; | |
111 | 306 gimple *stmt; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
307 bool cfg_changed = false; |
0 | 308 |
309 do { | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
310 basic_block bb; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
311 |
111 | 312 if (SSA_NAME_IN_FREE_LIST (name) |
313 || SSA_NAME_IS_DEFAULT_DEF (name) | |
314 || !has_zero_uses (name)) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
315 return cfg_changed; |
0 | 316 |
317 stmt = SSA_NAME_DEF_STMT (name); | |
111 | 318 if (gimple_code (stmt) == GIMPLE_PHI |
319 || gimple_has_side_effects (stmt)) | |
320 return cfg_changed; | |
321 | |
322 bb = gimple_bb (stmt); | |
0 | 323 gsi = gsi_for_stmt (stmt); |
111 | 324 unlink_stmt_vdef (stmt); |
325 if (gsi_remove (&gsi, true)) | |
326 bitmap_set_bit (to_purge, bb->index); | |
327 fwprop_invalidate_lattice (gimple_get_lhs (stmt)); | |
0 | 328 release_defs (stmt); |
329 | |
111 | 330 name = is_gimple_assign (stmt) ? gimple_assign_rhs1 (stmt) : NULL_TREE; |
0 | 331 } while (name && TREE_CODE (name) == SSA_NAME); |
332 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
333 return cfg_changed; |
0 | 334 } |
335 | |
111 | 336 /* Return the rhs of a gassign *STMT in a form of a single tree, |
0 | 337 converted to type TYPE. |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
338 |
0 | 339 This should disappear, but is needed so we can combine expressions and use |
340 the fold() interfaces. Long term, we need to develop folding and combine | |
341 routines that deal with gimple exclusively . */ | |
342 | |
343 static tree | |
111 | 344 rhs_to_tree (tree type, gimple *stmt) |
0 | 345 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
346 location_t loc = gimple_location (stmt); |
0 | 347 enum tree_code code = gimple_assign_rhs_code (stmt); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
348 if (get_gimple_rhs_class (code) == GIMPLE_TERNARY_RHS) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
349 return fold_build3_loc (loc, code, type, gimple_assign_rhs1 (stmt), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
350 gimple_assign_rhs2 (stmt), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
351 gimple_assign_rhs3 (stmt)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
352 else if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
353 return fold_build2_loc (loc, code, type, gimple_assign_rhs1 (stmt), |
0 | 354 gimple_assign_rhs2 (stmt)); |
355 else if (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS) | |
356 return build1 (code, type, gimple_assign_rhs1 (stmt)); | |
357 else if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS) | |
358 return gimple_assign_rhs1 (stmt); | |
359 else | |
360 gcc_unreachable (); | |
361 } | |
362 | |
363 /* Combine OP0 CODE OP1 in the context of a COND_EXPR. Returns | |
364 the folded result in a form suitable for COND_EXPR_COND or | |
365 NULL_TREE, if there is no suitable simplified form. If | |
366 INVARIANT_ONLY is true only gimple_min_invariant results are | |
367 considered simplified. */ | |
368 | |
369 static tree | |
111 | 370 combine_cond_expr_cond (gimple *stmt, enum tree_code code, tree type, |
0 | 371 tree op0, tree op1, bool invariant_only) |
372 { | |
373 tree t; | |
374 | |
375 gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison); | |
376 | |
111 | 377 fold_defer_overflow_warnings (); |
378 t = fold_binary_loc (gimple_location (stmt), code, type, op0, op1); | |
0 | 379 if (!t) |
111 | 380 { |
381 fold_undefer_overflow_warnings (false, NULL, 0); | |
382 return NULL_TREE; | |
383 } | |
0 | 384 |
385 /* Require that we got a boolean type out if we put one in. */ | |
386 gcc_assert (TREE_CODE (TREE_TYPE (t)) == TREE_CODE (type)); | |
387 | |
388 /* Canonicalize the combined condition for use in a COND_EXPR. */ | |
389 t = canonicalize_cond_expr_cond (t); | |
390 | |
391 /* Bail out if we required an invariant but didn't get one. */ | |
392 if (!t || (invariant_only && !is_gimple_min_invariant (t))) | |
111 | 393 { |
394 fold_undefer_overflow_warnings (false, NULL, 0); | |
395 return NULL_TREE; | |
396 } | |
397 | |
398 fold_undefer_overflow_warnings (!gimple_no_warning_p (stmt), stmt, 0); | |
0 | 399 |
400 return t; | |
401 } | |
402 | |
111 | 403 /* Combine the comparison OP0 CODE OP1 at LOC with the defining statements |
404 of its operand. Return a new comparison tree or NULL_TREE if there | |
405 were no simplifying combines. */ | |
406 | |
407 static tree | |
408 forward_propagate_into_comparison_1 (gimple *stmt, | |
409 enum tree_code code, tree type, | |
410 tree op0, tree op1) | |
411 { | |
412 tree tmp = NULL_TREE; | |
413 tree rhs0 = NULL_TREE, rhs1 = NULL_TREE; | |
414 bool single_use0_p = false, single_use1_p = false; | |
415 | |
416 /* For comparisons use the first operand, that is likely to | |
417 simplify comparisons against constants. */ | |
418 if (TREE_CODE (op0) == SSA_NAME) | |
419 { | |
420 gimple *def_stmt = get_prop_source_stmt (op0, false, &single_use0_p); | |
421 if (def_stmt && can_propagate_from (def_stmt)) | |
422 { | |
423 enum tree_code def_code = gimple_assign_rhs_code (def_stmt); | |
424 bool invariant_only_p = !single_use0_p; | |
425 | |
426 rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt); | |
427 | |
428 /* Always combine comparisons or conversions from booleans. */ | |
429 if (TREE_CODE (op1) == INTEGER_CST | |
430 && ((CONVERT_EXPR_CODE_P (def_code) | |
431 && TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs0, 0))) | |
432 == BOOLEAN_TYPE) | |
433 || TREE_CODE_CLASS (def_code) == tcc_comparison)) | |
434 invariant_only_p = false; | |
435 | |
436 tmp = combine_cond_expr_cond (stmt, code, type, | |
437 rhs0, op1, invariant_only_p); | |
438 if (tmp) | |
439 return tmp; | |
440 } | |
441 } | |
442 | |
443 /* If that wasn't successful, try the second operand. */ | |
444 if (TREE_CODE (op1) == SSA_NAME) | |
445 { | |
446 gimple *def_stmt = get_prop_source_stmt (op1, false, &single_use1_p); | |
447 if (def_stmt && can_propagate_from (def_stmt)) | |
448 { | |
449 rhs1 = rhs_to_tree (TREE_TYPE (op0), def_stmt); | |
450 tmp = combine_cond_expr_cond (stmt, code, type, | |
451 op0, rhs1, !single_use1_p); | |
452 if (tmp) | |
453 return tmp; | |
454 } | |
455 } | |
456 | |
457 /* If that wasn't successful either, try both operands. */ | |
458 if (rhs0 != NULL_TREE | |
459 && rhs1 != NULL_TREE) | |
460 tmp = combine_cond_expr_cond (stmt, code, type, | |
461 rhs0, rhs1, | |
462 !(single_use0_p && single_use1_p)); | |
463 | |
464 return tmp; | |
465 } | |
466 | |
467 /* Propagate from the ssa name definition statements of the assignment | |
468 from a comparison at *GSI into the conditional if that simplifies it. | |
469 Returns 1 if the stmt was modified and 2 if the CFG needs cleanup, | |
470 otherwise returns 0. */ | |
471 | |
472 static int | |
473 forward_propagate_into_comparison (gimple_stmt_iterator *gsi) | |
474 { | |
475 gimple *stmt = gsi_stmt (*gsi); | |
476 tree tmp; | |
477 bool cfg_changed = false; | |
478 tree type = TREE_TYPE (gimple_assign_lhs (stmt)); | |
479 tree rhs1 = gimple_assign_rhs1 (stmt); | |
480 tree rhs2 = gimple_assign_rhs2 (stmt); | |
481 | |
482 /* Combine the comparison with defining statements. */ | |
483 tmp = forward_propagate_into_comparison_1 (stmt, | |
484 gimple_assign_rhs_code (stmt), | |
485 type, rhs1, rhs2); | |
486 if (tmp && useless_type_conversion_p (type, TREE_TYPE (tmp))) | |
487 { | |
488 gimple_assign_set_rhs_from_tree (gsi, tmp); | |
489 fold_stmt (gsi); | |
490 update_stmt (gsi_stmt (*gsi)); | |
491 | |
492 if (TREE_CODE (rhs1) == SSA_NAME) | |
493 cfg_changed |= remove_prop_source_from_use (rhs1); | |
494 if (TREE_CODE (rhs2) == SSA_NAME) | |
495 cfg_changed |= remove_prop_source_from_use (rhs2); | |
496 return cfg_changed ? 2 : 1; | |
497 } | |
498 | |
499 return 0; | |
500 } | |
501 | |
0 | 502 /* Propagate from the ssa name definition statements of COND_EXPR |
503 in GIMPLE_COND statement STMT into the conditional if that simplifies it. | |
504 Returns zero if no statement was changed, one if there were | |
505 changes and two if cfg_cleanup needs to run. | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
506 |
0 | 507 This must be kept in sync with forward_propagate_into_cond. */ |
508 | |
509 static int | |
111 | 510 forward_propagate_into_gimple_cond (gcond *stmt) |
0 | 511 { |
111 | 512 tree tmp; |
513 enum tree_code code = gimple_cond_code (stmt); | |
514 bool cfg_changed = false; | |
515 tree rhs1 = gimple_cond_lhs (stmt); | |
516 tree rhs2 = gimple_cond_rhs (stmt); | |
0 | 517 |
111 | 518 /* We can do tree combining on SSA_NAME and comparison expressions. */ |
519 if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison) | |
520 return 0; | |
0 | 521 |
111 | 522 tmp = forward_propagate_into_comparison_1 (stmt, code, |
523 boolean_type_node, | |
524 rhs1, rhs2); | |
525 if (tmp) | |
526 { | |
527 if (dump_file && tmp) | |
528 { | |
529 fprintf (dump_file, " Replaced '"); | |
530 print_gimple_expr (dump_file, stmt, 0); | |
531 fprintf (dump_file, "' with '"); | |
532 print_generic_expr (dump_file, tmp); | |
533 fprintf (dump_file, "'\n"); | |
534 } | |
0 | 535 |
111 | 536 gimple_cond_set_condition_from_tree (stmt, unshare_expr (tmp)); |
537 update_stmt (stmt); | |
538 | |
539 if (TREE_CODE (rhs1) == SSA_NAME) | |
540 cfg_changed |= remove_prop_source_from_use (rhs1); | |
541 if (TREE_CODE (rhs2) == SSA_NAME) | |
542 cfg_changed |= remove_prop_source_from_use (rhs2); | |
543 return (cfg_changed || is_gimple_min_invariant (tmp)) ? 2 : 1; | |
544 } | |
0 | 545 |
111 | 546 /* Canonicalize _Bool == 0 and _Bool != 1 to _Bool != 0 by swapping edges. */ |
547 if ((TREE_CODE (TREE_TYPE (rhs1)) == BOOLEAN_TYPE | |
548 || (INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) | |
549 && TYPE_PRECISION (TREE_TYPE (rhs1)) == 1)) | |
550 && ((code == EQ_EXPR | |
551 && integer_zerop (rhs2)) | |
552 || (code == NE_EXPR | |
553 && integer_onep (rhs2)))) | |
554 { | |
555 basic_block bb = gimple_bb (stmt); | |
556 gimple_cond_set_code (stmt, NE_EXPR); | |
557 gimple_cond_set_rhs (stmt, build_zero_cst (TREE_TYPE (rhs1))); | |
558 EDGE_SUCC (bb, 0)->flags ^= (EDGE_TRUE_VALUE|EDGE_FALSE_VALUE); | |
559 EDGE_SUCC (bb, 1)->flags ^= (EDGE_TRUE_VALUE|EDGE_FALSE_VALUE); | |
560 return 1; | |
561 } | |
0 | 562 |
111 | 563 return 0; |
0 | 564 } |
565 | |
566 | |
567 /* Propagate from the ssa name definition statements of COND_EXPR | |
568 in the rhs of statement STMT into the conditional if that simplifies it. | |
111 | 569 Returns true zero if the stmt was changed. */ |
0 | 570 |
111 | 571 static bool |
0 | 572 forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) |
573 { | |
111 | 574 gimple *stmt = gsi_stmt (*gsi_p); |
575 tree tmp = NULL_TREE; | |
576 tree cond = gimple_assign_rhs1 (stmt); | |
577 enum tree_code code = gimple_assign_rhs_code (stmt); | |
0 | 578 |
111 | 579 /* We can do tree combining on SSA_NAME and comparison expressions. */ |
580 if (COMPARISON_CLASS_P (cond)) | |
581 tmp = forward_propagate_into_comparison_1 (stmt, TREE_CODE (cond), | |
582 TREE_TYPE (cond), | |
583 TREE_OPERAND (cond, 0), | |
584 TREE_OPERAND (cond, 1)); | |
585 else if (TREE_CODE (cond) == SSA_NAME) | |
586 { | |
587 enum tree_code def_code; | |
588 tree name = cond; | |
589 gimple *def_stmt = get_prop_source_stmt (name, true, NULL); | |
590 if (!def_stmt || !can_propagate_from (def_stmt)) | |
591 return 0; | |
0 | 592 |
111 | 593 def_code = gimple_assign_rhs_code (def_stmt); |
594 if (TREE_CODE_CLASS (def_code) == tcc_comparison) | |
595 tmp = fold_build2_loc (gimple_location (def_stmt), | |
596 def_code, | |
597 TREE_TYPE (cond), | |
598 gimple_assign_rhs1 (def_stmt), | |
599 gimple_assign_rhs2 (def_stmt)); | |
600 } | |
0 | 601 |
111 | 602 if (tmp |
603 && is_gimple_condexpr (tmp)) | |
604 { | |
605 if (dump_file && tmp) | |
606 { | |
607 fprintf (dump_file, " Replaced '"); | |
608 print_generic_expr (dump_file, cond); | |
609 fprintf (dump_file, "' with '"); | |
610 print_generic_expr (dump_file, tmp); | |
611 fprintf (dump_file, "'\n"); | |
612 } | |
0 | 613 |
111 | 614 if ((code == VEC_COND_EXPR) ? integer_all_onesp (tmp) |
615 : integer_onep (tmp)) | |
616 gimple_assign_set_rhs_from_tree (gsi_p, gimple_assign_rhs2 (stmt)); | |
617 else if (integer_zerop (tmp)) | |
618 gimple_assign_set_rhs_from_tree (gsi_p, gimple_assign_rhs3 (stmt)); | |
619 else | |
620 gimple_assign_set_rhs1 (stmt, unshare_expr (tmp)); | |
621 stmt = gsi_stmt (*gsi_p); | |
622 update_stmt (stmt); | |
0 | 623 |
111 | 624 return true; |
625 } | |
0 | 626 |
111 | 627 return 0; |
0 | 628 } |
629 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
630 /* We've just substituted an ADDR_EXPR into stmt. Update all the |
0 | 631 relevant data structures to match. */ |
632 | |
633 static void | |
111 | 634 tidy_after_forward_propagate_addr (gimple *stmt) |
0 | 635 { |
636 /* We may have turned a trapping insn into a non-trapping insn. */ | |
111 | 637 if (maybe_clean_or_replace_eh_stmt (stmt, stmt)) |
638 bitmap_set_bit (to_purge, gimple_bb (stmt)->index); | |
0 | 639 |
640 if (TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR) | |
641 recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt)); | |
642 } | |
643 | |
644 /* NAME is a SSA_NAME representing DEF_RHS which is of the form | |
645 ADDR_EXPR <whatever>. | |
646 | |
647 Try to forward propagate the ADDR_EXPR into the use USE_STMT. | |
648 Often this will allow for removal of an ADDR_EXPR and INDIRECT_REF | |
649 node or for recovery of array indexing from pointer arithmetic. | |
650 | |
651 Return true if the propagation was successful (the propagation can | |
652 be not totally successful, yet things may have been changed). */ | |
653 | |
654 static bool | |
655 forward_propagate_addr_expr_1 (tree name, tree def_rhs, | |
656 gimple_stmt_iterator *use_stmt_gsi, | |
657 bool single_use_p) | |
658 { | |
659 tree lhs, rhs, rhs2, array_ref; | |
111 | 660 gimple *use_stmt = gsi_stmt (*use_stmt_gsi); |
0 | 661 enum tree_code rhs_code; |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
662 bool res = true; |
0 | 663 |
664 gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR); | |
665 | |
666 lhs = gimple_assign_lhs (use_stmt); | |
667 rhs_code = gimple_assign_rhs_code (use_stmt); | |
668 rhs = gimple_assign_rhs1 (use_stmt); | |
669 | |
111 | 670 /* Do not perform copy-propagation but recurse through copy chains. */ |
671 if (TREE_CODE (lhs) == SSA_NAME | |
672 && rhs_code == SSA_NAME) | |
673 return forward_propagate_addr_expr (lhs, def_rhs, single_use_p); | |
674 | |
675 /* The use statement could be a conversion. Recurse to the uses of the | |
676 lhs as copyprop does not copy through pointer to integer to pointer | |
677 conversions and FRE does not catch all cases either. | |
678 Treat the case of a single-use name and | |
0 | 679 a conversion to def_rhs type separate, though. */ |
680 if (TREE_CODE (lhs) == SSA_NAME | |
111 | 681 && CONVERT_EXPR_CODE_P (rhs_code)) |
0 | 682 { |
111 | 683 /* If there is a point in a conversion chain where the types match |
684 so we can remove a conversion re-materialize the address here | |
685 and stop. */ | |
686 if (single_use_p | |
687 && useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (def_rhs))) | |
688 { | |
689 gimple_assign_set_rhs1 (use_stmt, unshare_expr (def_rhs)); | |
690 gimple_assign_set_rhs_code (use_stmt, TREE_CODE (def_rhs)); | |
691 return true; | |
692 } | |
0 | 693 |
111 | 694 /* Else recurse if the conversion preserves the address value. */ |
695 if ((INTEGRAL_TYPE_P (TREE_TYPE (lhs)) | |
696 || POINTER_TYPE_P (TREE_TYPE (lhs))) | |
697 && (TYPE_PRECISION (TREE_TYPE (lhs)) | |
698 >= TYPE_PRECISION (TREE_TYPE (def_rhs)))) | |
699 return forward_propagate_addr_expr (lhs, def_rhs, single_use_p); | |
700 | |
701 return false; | |
0 | 702 } |
703 | |
111 | 704 /* If this isn't a conversion chain from this on we only can propagate |
705 into compatible pointer contexts. */ | |
706 if (!types_compatible_p (TREE_TYPE (name), TREE_TYPE (def_rhs))) | |
707 return false; | |
708 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
709 /* Propagate through constant pointer adjustments. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
710 if (TREE_CODE (lhs) == SSA_NAME |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
711 && rhs_code == POINTER_PLUS_EXPR |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
712 && rhs == name |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
713 && TREE_CODE (gimple_assign_rhs2 (use_stmt)) == INTEGER_CST) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
714 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
715 tree new_def_rhs; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
716 /* As we come here with non-invariant addresses in def_rhs we need |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
717 to make sure we can build a valid constant offsetted address |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
718 for further propagation. Simply rely on fold building that |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
719 and check after the fact. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
720 new_def_rhs = fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (rhs)), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
721 def_rhs, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
722 fold_convert (ptr_type_node, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
723 gimple_assign_rhs2 (use_stmt))); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
724 if (TREE_CODE (new_def_rhs) == MEM_REF |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
725 && !is_gimple_mem_ref_addr (TREE_OPERAND (new_def_rhs, 0))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
726 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
727 new_def_rhs = build_fold_addr_expr_with_type (new_def_rhs, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
728 TREE_TYPE (rhs)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
729 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
730 /* Recurse. If we could propagate into all uses of lhs do not |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
731 bother to replace into the current use but just pretend we did. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
732 if (TREE_CODE (new_def_rhs) == ADDR_EXPR |
111 | 733 && forward_propagate_addr_expr (lhs, new_def_rhs, single_use_p)) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
734 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
735 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
736 if (useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (new_def_rhs))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
737 gimple_assign_set_rhs_with_ops (use_stmt_gsi, TREE_CODE (new_def_rhs), |
111 | 738 new_def_rhs); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
739 else if (is_gimple_min_invariant (new_def_rhs)) |
111 | 740 gimple_assign_set_rhs_with_ops (use_stmt_gsi, NOP_EXPR, new_def_rhs); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
741 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
742 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
743 gcc_assert (gsi_stmt (*use_stmt_gsi) == use_stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
744 update_stmt (use_stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
745 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
746 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
747 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
748 /* Now strip away any outer COMPONENT_REF/ARRAY_REF nodes from the LHS. |
0 | 749 ADDR_EXPR will not appear on the LHS. */ |
111 | 750 tree *lhsp = gimple_assign_lhs_ptr (use_stmt); |
751 while (handled_component_p (*lhsp)) | |
752 lhsp = &TREE_OPERAND (*lhsp, 0); | |
753 lhs = *lhsp; | |
0 | 754 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
755 /* Now see if the LHS node is a MEM_REF using NAME. If so, |
0 | 756 propagate the ADDR_EXPR into the use of NAME and fold the result. */ |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
757 if (TREE_CODE (lhs) == MEM_REF |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
758 && TREE_OPERAND (lhs, 0) == name) |
0 | 759 { |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
760 tree def_rhs_base; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
761 HOST_WIDE_INT def_rhs_offset; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
762 /* If the address is invariant we can always fold it. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
763 if ((def_rhs_base = get_addr_base_and_unit_offset (TREE_OPERAND (def_rhs, 0), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
764 &def_rhs_offset))) |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
765 { |
111 | 766 offset_int off = mem_ref_offset (lhs); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
767 tree new_ptr; |
111 | 768 off += def_rhs_offset; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
769 if (TREE_CODE (def_rhs_base) == MEM_REF) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
770 { |
111 | 771 off += mem_ref_offset (def_rhs_base); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
772 new_ptr = TREE_OPERAND (def_rhs_base, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
773 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
774 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
775 new_ptr = build_fold_addr_expr (def_rhs_base); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
776 TREE_OPERAND (lhs, 0) = new_ptr; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
777 TREE_OPERAND (lhs, 1) |
111 | 778 = wide_int_to_tree (TREE_TYPE (TREE_OPERAND (lhs, 1)), off); |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
779 tidy_after_forward_propagate_addr (use_stmt); |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
780 /* Continue propagating into the RHS if this was not the only use. */ |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
781 if (single_use_p) |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
782 return true; |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
783 } |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
784 /* If the LHS is a plain dereference and the value type is the same as |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
785 that of the pointed-to type of the address we can put the |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
786 dereferenced address on the LHS preserving the original alias-type. */ |
111 | 787 else if (integer_zerop (TREE_OPERAND (lhs, 1)) |
788 && ((gimple_assign_lhs (use_stmt) == lhs | |
789 && useless_type_conversion_p | |
790 (TREE_TYPE (TREE_OPERAND (def_rhs, 0)), | |
791 TREE_TYPE (gimple_assign_rhs1 (use_stmt)))) | |
792 || types_compatible_p (TREE_TYPE (lhs), | |
793 TREE_TYPE (TREE_OPERAND (def_rhs, 0)))) | |
794 /* Don't forward anything into clobber stmts if it would result | |
795 in the lhs no longer being a MEM_REF. */ | |
796 && (!gimple_clobber_p (use_stmt) | |
797 || TREE_CODE (TREE_OPERAND (def_rhs, 0)) == MEM_REF)) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
798 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
799 tree *def_rhs_basep = &TREE_OPERAND (def_rhs, 0); |
111 | 800 tree new_offset, new_base, saved, new_lhs; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
801 while (handled_component_p (*def_rhs_basep)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
802 def_rhs_basep = &TREE_OPERAND (*def_rhs_basep, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
803 saved = *def_rhs_basep; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
804 if (TREE_CODE (*def_rhs_basep) == MEM_REF) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
805 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
806 new_base = TREE_OPERAND (*def_rhs_basep, 0); |
111 | 807 new_offset = fold_convert (TREE_TYPE (TREE_OPERAND (lhs, 1)), |
808 TREE_OPERAND (*def_rhs_basep, 1)); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
809 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
810 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
811 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
812 new_base = build_fold_addr_expr (*def_rhs_basep); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
813 new_offset = TREE_OPERAND (lhs, 1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
814 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
815 *def_rhs_basep = build2 (MEM_REF, TREE_TYPE (*def_rhs_basep), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
816 new_base, new_offset); |
111 | 817 TREE_THIS_VOLATILE (*def_rhs_basep) = TREE_THIS_VOLATILE (lhs); |
818 TREE_SIDE_EFFECTS (*def_rhs_basep) = TREE_SIDE_EFFECTS (lhs); | |
819 TREE_THIS_NOTRAP (*def_rhs_basep) = TREE_THIS_NOTRAP (lhs); | |
820 new_lhs = unshare_expr (TREE_OPERAND (def_rhs, 0)); | |
821 *lhsp = new_lhs; | |
822 TREE_THIS_VOLATILE (new_lhs) = TREE_THIS_VOLATILE (lhs); | |
823 TREE_SIDE_EFFECTS (new_lhs) = TREE_SIDE_EFFECTS (lhs); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
824 *def_rhs_basep = saved; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
825 tidy_after_forward_propagate_addr (use_stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
826 /* Continue propagating into the RHS if this was not the |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
827 only use. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
828 if (single_use_p) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
829 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
830 } |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
831 else |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
832 /* We can have a struct assignment dereferencing our name twice. |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
833 Note that we didn't propagate into the lhs to not falsely |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
834 claim we did when propagating into the rhs. */ |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
835 res = false; |
0 | 836 } |
837 | |
838 /* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR | |
839 nodes from the RHS. */ | |
111 | 840 tree *rhsp = gimple_assign_rhs1_ptr (use_stmt); |
841 if (TREE_CODE (*rhsp) == ADDR_EXPR) | |
842 rhsp = &TREE_OPERAND (*rhsp, 0); | |
843 while (handled_component_p (*rhsp)) | |
844 rhsp = &TREE_OPERAND (*rhsp, 0); | |
845 rhs = *rhsp; | |
0 | 846 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
847 /* Now see if the RHS node is a MEM_REF using NAME. If so, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
848 propagate the ADDR_EXPR into the use of NAME and fold the result. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
849 if (TREE_CODE (rhs) == MEM_REF |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
850 && TREE_OPERAND (rhs, 0) == name) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
851 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
852 tree def_rhs_base; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
853 HOST_WIDE_INT def_rhs_offset; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
854 if ((def_rhs_base = get_addr_base_and_unit_offset (TREE_OPERAND (def_rhs, 0), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
855 &def_rhs_offset))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
856 { |
111 | 857 offset_int off = mem_ref_offset (rhs); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
858 tree new_ptr; |
111 | 859 off += def_rhs_offset; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
860 if (TREE_CODE (def_rhs_base) == MEM_REF) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
861 { |
111 | 862 off += mem_ref_offset (def_rhs_base); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
863 new_ptr = TREE_OPERAND (def_rhs_base, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
864 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
865 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
866 new_ptr = build_fold_addr_expr (def_rhs_base); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
867 TREE_OPERAND (rhs, 0) = new_ptr; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
868 TREE_OPERAND (rhs, 1) |
111 | 869 = wide_int_to_tree (TREE_TYPE (TREE_OPERAND (rhs, 1)), off); |
870 fold_stmt_inplace (use_stmt_gsi); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
871 tidy_after_forward_propagate_addr (use_stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
872 return res; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
873 } |
111 | 874 /* If the RHS is a plain dereference and the value type is the same as |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
875 that of the pointed-to type of the address we can put the |
111 | 876 dereferenced address on the RHS preserving the original alias-type. */ |
877 else if (integer_zerop (TREE_OPERAND (rhs, 1)) | |
878 && ((gimple_assign_rhs1 (use_stmt) == rhs | |
879 && useless_type_conversion_p | |
880 (TREE_TYPE (gimple_assign_lhs (use_stmt)), | |
881 TREE_TYPE (TREE_OPERAND (def_rhs, 0)))) | |
882 || types_compatible_p (TREE_TYPE (rhs), | |
883 TREE_TYPE (TREE_OPERAND (def_rhs, 0))))) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
884 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
885 tree *def_rhs_basep = &TREE_OPERAND (def_rhs, 0); |
111 | 886 tree new_offset, new_base, saved, new_rhs; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
887 while (handled_component_p (*def_rhs_basep)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
888 def_rhs_basep = &TREE_OPERAND (*def_rhs_basep, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
889 saved = *def_rhs_basep; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
890 if (TREE_CODE (*def_rhs_basep) == MEM_REF) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
891 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
892 new_base = TREE_OPERAND (*def_rhs_basep, 0); |
111 | 893 new_offset = fold_convert (TREE_TYPE (TREE_OPERAND (rhs, 1)), |
894 TREE_OPERAND (*def_rhs_basep, 1)); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
895 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
896 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
897 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
898 new_base = build_fold_addr_expr (*def_rhs_basep); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
899 new_offset = TREE_OPERAND (rhs, 1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
900 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
901 *def_rhs_basep = build2 (MEM_REF, TREE_TYPE (*def_rhs_basep), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
902 new_base, new_offset); |
111 | 903 TREE_THIS_VOLATILE (*def_rhs_basep) = TREE_THIS_VOLATILE (rhs); |
904 TREE_SIDE_EFFECTS (*def_rhs_basep) = TREE_SIDE_EFFECTS (rhs); | |
905 TREE_THIS_NOTRAP (*def_rhs_basep) = TREE_THIS_NOTRAP (rhs); | |
906 new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0)); | |
907 *rhsp = new_rhs; | |
908 TREE_THIS_VOLATILE (new_rhs) = TREE_THIS_VOLATILE (rhs); | |
909 TREE_SIDE_EFFECTS (new_rhs) = TREE_SIDE_EFFECTS (rhs); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
910 *def_rhs_basep = saved; |
111 | 911 fold_stmt_inplace (use_stmt_gsi); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
912 tidy_after_forward_propagate_addr (use_stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
913 return res; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
914 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
915 } |
0 | 916 |
917 /* If the use of the ADDR_EXPR is not a POINTER_PLUS_EXPR, there | |
918 is nothing to do. */ | |
919 if (gimple_assign_rhs_code (use_stmt) != POINTER_PLUS_EXPR | |
920 || gimple_assign_rhs1 (use_stmt) != name) | |
921 return false; | |
922 | |
923 /* The remaining cases are all for turning pointer arithmetic into | |
924 array indexing. They only apply when we have the address of | |
925 element zero in an array. If that is not the case then there | |
926 is nothing to do. */ | |
927 array_ref = TREE_OPERAND (def_rhs, 0); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
928 if ((TREE_CODE (array_ref) != ARRAY_REF |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
929 || TREE_CODE (TREE_TYPE (TREE_OPERAND (array_ref, 0))) != ARRAY_TYPE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
930 || TREE_CODE (TREE_OPERAND (array_ref, 1)) != INTEGER_CST) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
931 && TREE_CODE (TREE_TYPE (array_ref)) != ARRAY_TYPE) |
0 | 932 return false; |
933 | |
934 rhs2 = gimple_assign_rhs2 (use_stmt); | |
111 | 935 /* Optimize &x[C1] p+ C2 to &x p+ C3 with C3 = C1 * element_size + C2. */ |
0 | 936 if (TREE_CODE (rhs2) == INTEGER_CST) |
937 { | |
111 | 938 tree new_rhs = build1_loc (gimple_location (use_stmt), |
939 ADDR_EXPR, TREE_TYPE (def_rhs), | |
940 fold_build2 (MEM_REF, | |
941 TREE_TYPE (TREE_TYPE (def_rhs)), | |
942 unshare_expr (def_rhs), | |
943 fold_convert (ptr_type_node, | |
944 rhs2))); | |
945 gimple_assign_set_rhs_from_tree (use_stmt_gsi, new_rhs); | |
946 use_stmt = gsi_stmt (*use_stmt_gsi); | |
947 update_stmt (use_stmt); | |
948 tidy_after_forward_propagate_addr (use_stmt); | |
949 return true; | |
0 | 950 } |
951 | |
952 return false; | |
953 } | |
954 | |
955 /* STMT is a statement of the form SSA_NAME = ADDR_EXPR <whatever>. | |
956 | |
957 Try to forward propagate the ADDR_EXPR into all uses of the SSA_NAME. | |
958 Often this will allow for removal of an ADDR_EXPR and INDIRECT_REF | |
959 node or for recovery of array indexing from pointer arithmetic. | |
111 | 960 |
961 PARENT_SINGLE_USE_P tells if, when in a recursive invocation, NAME was | |
962 the single use in the previous invocation. Pass true when calling | |
963 this as toplevel. | |
964 | |
0 | 965 Returns true, if all uses have been propagated into. */ |
966 | |
967 static bool | |
111 | 968 forward_propagate_addr_expr (tree name, tree rhs, bool parent_single_use_p) |
0 | 969 { |
970 imm_use_iterator iter; | |
111 | 971 gimple *use_stmt; |
0 | 972 bool all = true; |
111 | 973 bool single_use_p = parent_single_use_p && has_single_use (name); |
0 | 974 |
975 FOR_EACH_IMM_USE_STMT (use_stmt, iter, name) | |
976 { | |
977 bool result; | |
978 tree use_rhs; | |
979 | |
980 /* If the use is not in a simple assignment statement, then | |
981 there is nothing we can do. */ | |
111 | 982 if (!is_gimple_assign (use_stmt)) |
0 | 983 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
984 if (!is_gimple_debug (use_stmt)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
985 all = false; |
0 | 986 continue; |
987 } | |
988 | |
111 | 989 gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt); |
990 result = forward_propagate_addr_expr_1 (name, rhs, &gsi, | |
991 single_use_p); | |
992 /* If the use has moved to a different statement adjust | |
993 the update machinery for the old statement too. */ | |
994 if (use_stmt != gsi_stmt (gsi)) | |
0 | 995 { |
111 | 996 update_stmt (use_stmt); |
997 use_stmt = gsi_stmt (gsi); | |
0 | 998 } |
111 | 999 update_stmt (use_stmt); |
0 | 1000 all &= result; |
1001 | |
1002 /* Remove intermediate now unused copy and conversion chains. */ | |
1003 use_rhs = gimple_assign_rhs1 (use_stmt); | |
1004 if (result | |
1005 && TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1006 && TREE_CODE (use_rhs) == SSA_NAME |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1007 && has_zero_uses (gimple_assign_lhs (use_stmt))) |
0 | 1008 { |
1009 gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt); | |
111 | 1010 fwprop_invalidate_lattice (gimple_get_lhs (use_stmt)); |
0 | 1011 release_defs (use_stmt); |
1012 gsi_remove (&gsi, true); | |
1013 } | |
1014 } | |
1015 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1016 return all && has_zero_uses (name); |
0 | 1017 } |
1018 | |
111 | 1019 |
1020 /* Helper function for simplify_gimple_switch. Remove case labels that | |
1021 have values outside the range of the new type. */ | |
0 | 1022 |
111 | 1023 static void |
1024 simplify_gimple_switch_label_vec (gswitch *stmt, tree index_type) | |
0 | 1025 { |
111 | 1026 unsigned int branch_num = gimple_switch_num_labels (stmt); |
1027 auto_vec<tree> labels (branch_num); | |
1028 unsigned int i, len; | |
1029 | |
1030 /* Collect the existing case labels in a VEC, and preprocess it as if | |
1031 we are gimplifying a GENERIC SWITCH_EXPR. */ | |
1032 for (i = 1; i < branch_num; i++) | |
1033 labels.quick_push (gimple_switch_label (stmt, i)); | |
1034 preprocess_case_label_vec_for_gimple (labels, index_type, NULL); | |
0 | 1035 |
111 | 1036 /* If any labels were removed, replace the existing case labels |
1037 in the GIMPLE_SWITCH statement with the correct ones. | |
1038 Note that the type updates were done in-place on the case labels, | |
1039 so we only have to replace the case labels in the GIMPLE_SWITCH | |
1040 if the number of labels changed. */ | |
1041 len = labels.length (); | |
1042 if (len < branch_num - 1) | |
1043 { | |
1044 bitmap target_blocks; | |
1045 edge_iterator ei; | |
1046 edge e; | |
0 | 1047 |
111 | 1048 /* Corner case: *all* case labels have been removed as being |
1049 out-of-range for INDEX_TYPE. Push one label and let the | |
1050 CFG cleanups deal with this further. */ | |
1051 if (len == 0) | |
0 | 1052 { |
111 | 1053 tree label, elt; |
0 | 1054 |
111 | 1055 label = CASE_LABEL (gimple_switch_default_label (stmt)); |
1056 elt = build_case_label (build_int_cst (index_type, 0), NULL, label); | |
1057 labels.quick_push (elt); | |
1058 len = 1; | |
0 | 1059 } |
1060 | |
111 | 1061 for (i = 0; i < labels.length (); i++) |
1062 gimple_switch_set_label (stmt, i + 1, labels[i]); | |
1063 for (i++ ; i < branch_num; i++) | |
1064 gimple_switch_set_label (stmt, i, NULL_TREE); | |
1065 gimple_switch_set_num_labels (stmt, len + 1); | |
0 | 1066 |
111 | 1067 /* Cleanup any edges that are now dead. */ |
1068 target_blocks = BITMAP_ALLOC (NULL); | |
1069 for (i = 0; i < gimple_switch_num_labels (stmt); i++) | |
1070 { | |
1071 tree elt = gimple_switch_label (stmt, i); | |
1072 basic_block target = label_to_block (CASE_LABEL (elt)); | |
1073 bitmap_set_bit (target_blocks, target->index); | |
1074 } | |
1075 for (ei = ei_start (gimple_bb (stmt)->succs); (e = ei_safe_edge (ei)); ) | |
0 | 1076 { |
111 | 1077 if (! bitmap_bit_p (target_blocks, e->dest->index)) |
1078 { | |
1079 remove_edge (e); | |
1080 cfg_changed = true; | |
1081 free_dominance_info (CDI_DOMINATORS); | |
1082 } | |
1083 else | |
1084 ei_next (&ei); | |
1085 } | |
1086 BITMAP_FREE (target_blocks); | |
0 | 1087 } |
1088 } | |
1089 | |
1090 /* STMT is a SWITCH_EXPR for which we attempt to find equivalent forms of | |
1091 the condition which we may be able to optimize better. */ | |
1092 | |
111 | 1093 static bool |
1094 simplify_gimple_switch (gswitch *stmt) | |
0 | 1095 { |
1096 /* The optimization that we really care about is removing unnecessary | |
1097 casts. That will let us do much better in propagating the inferred | |
1098 constant at the switch target. */ | |
111 | 1099 tree cond = gimple_switch_index (stmt); |
0 | 1100 if (TREE_CODE (cond) == SSA_NAME) |
1101 { | |
111 | 1102 gimple *def_stmt = SSA_NAME_DEF_STMT (cond); |
1103 if (gimple_assign_cast_p (def_stmt)) | |
0 | 1104 { |
111 | 1105 tree def = gimple_assign_rhs1 (def_stmt); |
1106 if (TREE_CODE (def) != SSA_NAME) | |
1107 return false; | |
0 | 1108 |
111 | 1109 /* If we have an extension or sign-change that preserves the |
1110 values we check against then we can copy the source value into | |
1111 the switch. */ | |
1112 tree ti = TREE_TYPE (def); | |
1113 if (INTEGRAL_TYPE_P (ti) | |
1114 && TYPE_PRECISION (ti) <= TYPE_PRECISION (TREE_TYPE (cond))) | |
1115 { | |
1116 size_t n = gimple_switch_num_labels (stmt); | |
1117 tree min = NULL_TREE, max = NULL_TREE; | |
1118 if (n > 1) | |
1119 { | |
1120 min = CASE_LOW (gimple_switch_label (stmt, 1)); | |
1121 if (CASE_HIGH (gimple_switch_label (stmt, n - 1))) | |
1122 max = CASE_HIGH (gimple_switch_label (stmt, n - 1)); | |
1123 else | |
1124 max = CASE_LOW (gimple_switch_label (stmt, n - 1)); | |
1125 } | |
1126 if ((!min || int_fits_type_p (min, ti)) | |
1127 && (!max || int_fits_type_p (max, ti))) | |
0 | 1128 { |
1129 gimple_switch_set_index (stmt, def); | |
111 | 1130 simplify_gimple_switch_label_vec (stmt, ti); |
0 | 1131 update_stmt (stmt); |
111 | 1132 return true; |
0 | 1133 } |
1134 } | |
1135 } | |
1136 } | |
111 | 1137 |
1138 return false; | |
0 | 1139 } |
1140 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1141 /* For pointers p2 and p1 return p2 - p1 if the |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1142 difference is known and constant, otherwise return NULL. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1143 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1144 static tree |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1145 constant_pointer_difference (tree p1, tree p2) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1146 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1147 int i, j; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1148 #define CPD_ITERATIONS 5 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1149 tree exps[2][CPD_ITERATIONS]; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1150 tree offs[2][CPD_ITERATIONS]; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1151 int cnt[2]; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1152 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1153 for (i = 0; i < 2; i++) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1154 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1155 tree p = i ? p1 : p2; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1156 tree off = size_zero_node; |
111 | 1157 gimple *stmt; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1158 enum tree_code code; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1159 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1160 /* For each of p1 and p2 we need to iterate at least |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1161 twice, to handle ADDR_EXPR directly in p1/p2, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1162 SSA_NAME with ADDR_EXPR or POINTER_PLUS_EXPR etc. |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1163 on definition's stmt RHS. Iterate a few extra times. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1164 j = 0; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1165 do |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1166 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1167 if (!POINTER_TYPE_P (TREE_TYPE (p))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1168 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1169 if (TREE_CODE (p) == ADDR_EXPR) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1170 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1171 tree q = TREE_OPERAND (p, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1172 HOST_WIDE_INT offset; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1173 tree base = get_addr_base_and_unit_offset (q, &offset); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1174 if (base) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1175 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1176 q = base; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1177 if (offset) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1178 off = size_binop (PLUS_EXPR, off, size_int (offset)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1179 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1180 if (TREE_CODE (q) == MEM_REF |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1181 && TREE_CODE (TREE_OPERAND (q, 0)) == SSA_NAME) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1182 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1183 p = TREE_OPERAND (q, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1184 off = size_binop (PLUS_EXPR, off, |
111 | 1185 wide_int_to_tree (sizetype, |
1186 mem_ref_offset (q))); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1187 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1188 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1189 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1190 exps[i][j] = q; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1191 offs[i][j++] = off; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1192 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1193 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1194 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1195 if (TREE_CODE (p) != SSA_NAME) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1196 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1197 exps[i][j] = p; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1198 offs[i][j++] = off; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1199 if (j == CPD_ITERATIONS) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1200 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1201 stmt = SSA_NAME_DEF_STMT (p); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1202 if (!is_gimple_assign (stmt) || gimple_assign_lhs (stmt) != p) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1203 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1204 code = gimple_assign_rhs_code (stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1205 if (code == POINTER_PLUS_EXPR) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1206 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1207 if (TREE_CODE (gimple_assign_rhs2 (stmt)) != INTEGER_CST) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1208 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1209 off = size_binop (PLUS_EXPR, off, gimple_assign_rhs2 (stmt)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1210 p = gimple_assign_rhs1 (stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1211 } |
111 | 1212 else if (code == ADDR_EXPR || CONVERT_EXPR_CODE_P (code)) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1213 p = gimple_assign_rhs1 (stmt); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1214 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1215 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1216 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1217 while (1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1218 cnt[i] = j; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1219 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1220 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1221 for (i = 0; i < cnt[0]; i++) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1222 for (j = 0; j < cnt[1]; j++) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1223 if (exps[0][i] == exps[1][j]) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1224 return size_binop (MINUS_EXPR, offs[0][i], offs[1][j]); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1225 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1226 return NULL_TREE; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1227 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1228 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1229 /* *GSI_P is a GIMPLE_CALL to a builtin function. |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1230 Optimize |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1231 memcpy (p, "abcd", 4); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1232 memset (p + 4, ' ', 3); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1233 into |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1234 memcpy (p, "abcd ", 7); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1235 call if the latter can be stored by pieces during expansion. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1236 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1237 static bool |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1238 simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1239 { |
111 | 1240 gimple *stmt1, *stmt2 = gsi_stmt (*gsi_p); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1241 tree vuse = gimple_vuse (stmt2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1242 if (vuse == NULL) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1243 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1244 stmt1 = SSA_NAME_DEF_STMT (vuse); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1245 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1246 switch (DECL_FUNCTION_CODE (callee2)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1247 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1248 case BUILT_IN_MEMSET: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1249 if (gimple_call_num_args (stmt2) != 3 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1250 || gimple_call_lhs (stmt2) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1251 || CHAR_BIT != 8 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1252 || BITS_PER_UNIT != 8) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1253 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1254 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1255 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1256 tree callee1; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1257 tree ptr1, src1, str1, off1, len1, lhs1; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1258 tree ptr2 = gimple_call_arg (stmt2, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1259 tree val2 = gimple_call_arg (stmt2, 1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1260 tree len2 = gimple_call_arg (stmt2, 2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1261 tree diff, vdef, new_str_cst; |
111 | 1262 gimple *use_stmt; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1263 unsigned int ptr1_align; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1264 unsigned HOST_WIDE_INT src_len; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1265 char *src_buf; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1266 use_operand_p use_p; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1267 |
111 | 1268 if (!tree_fits_shwi_p (val2) |
1269 || !tree_fits_uhwi_p (len2) | |
1270 || compare_tree_int (len2, 1024) == 1) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1271 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1272 if (is_gimple_call (stmt1)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1273 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1274 /* If first stmt is a call, it needs to be memcpy |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1275 or mempcpy, with string literal as second argument and |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1276 constant length. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1277 callee1 = gimple_call_fndecl (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1278 if (callee1 == NULL_TREE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1279 || DECL_BUILT_IN_CLASS (callee1) != BUILT_IN_NORMAL |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1280 || gimple_call_num_args (stmt1) != 3) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1281 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1282 if (DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMCPY |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1283 && DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMPCPY) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1284 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1285 ptr1 = gimple_call_arg (stmt1, 0); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1286 src1 = gimple_call_arg (stmt1, 1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1287 len1 = gimple_call_arg (stmt1, 2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1288 lhs1 = gimple_call_lhs (stmt1); |
111 | 1289 if (!tree_fits_uhwi_p (len1)) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1290 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1291 str1 = string_constant (src1, &off1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1292 if (str1 == NULL_TREE) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1293 break; |
111 | 1294 if (!tree_fits_uhwi_p (off1) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1295 || compare_tree_int (off1, TREE_STRING_LENGTH (str1) - 1) > 0 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1296 || compare_tree_int (len1, TREE_STRING_LENGTH (str1) |
111 | 1297 - tree_to_uhwi (off1)) > 0 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1298 || TREE_CODE (TREE_TYPE (str1)) != ARRAY_TYPE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1299 || TYPE_MODE (TREE_TYPE (TREE_TYPE (str1))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1300 != TYPE_MODE (char_type_node)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1301 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1302 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1303 else if (gimple_assign_single_p (stmt1)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1304 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1305 /* Otherwise look for length 1 memcpy optimized into |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1306 assignment. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1307 ptr1 = gimple_assign_lhs (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1308 src1 = gimple_assign_rhs1 (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1309 if (TREE_CODE (ptr1) != MEM_REF |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1310 || TYPE_MODE (TREE_TYPE (ptr1)) != TYPE_MODE (char_type_node) |
111 | 1311 || !tree_fits_shwi_p (src1)) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1312 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1313 ptr1 = build_fold_addr_expr (ptr1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1314 callee1 = NULL_TREE; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1315 len1 = size_one_node; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1316 lhs1 = NULL_TREE; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1317 off1 = size_zero_node; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1318 str1 = NULL_TREE; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1319 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1320 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1321 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1322 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1323 diff = constant_pointer_difference (ptr1, ptr2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1324 if (diff == NULL && lhs1 != NULL) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1325 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1326 diff = constant_pointer_difference (lhs1, ptr2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1327 if (DECL_FUNCTION_CODE (callee1) == BUILT_IN_MEMPCPY |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1328 && diff != NULL) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1329 diff = size_binop (PLUS_EXPR, diff, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1330 fold_convert (sizetype, len1)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1331 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1332 /* If the difference between the second and first destination pointer |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1333 is not constant, or is bigger than memcpy length, bail out. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1334 if (diff == NULL |
111 | 1335 || !tree_fits_uhwi_p (diff) |
1336 || tree_int_cst_lt (len1, diff) | |
1337 || compare_tree_int (diff, 1024) == 1) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1338 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1339 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1340 /* Use maximum of difference plus memset length and memcpy length |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1341 as the new memcpy length, if it is too big, bail out. */ |
111 | 1342 src_len = tree_to_uhwi (diff); |
1343 src_len += tree_to_uhwi (len2); | |
1344 if (src_len < tree_to_uhwi (len1)) | |
1345 src_len = tree_to_uhwi (len1); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1346 if (src_len > 1024) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1347 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1348 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1349 /* If mempcpy value is used elsewhere, bail out, as mempcpy |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1350 with bigger length will return different result. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1351 if (lhs1 != NULL_TREE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1352 && DECL_FUNCTION_CODE (callee1) == BUILT_IN_MEMPCPY |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1353 && (TREE_CODE (lhs1) != SSA_NAME |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1354 || !single_imm_use (lhs1, &use_p, &use_stmt) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1355 || use_stmt != stmt2)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1356 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1357 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1358 /* If anything reads memory in between memcpy and memset |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1359 call, the modified memcpy call might change it. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1360 vdef = gimple_vdef (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1361 if (vdef != NULL |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1362 && (!single_imm_use (vdef, &use_p, &use_stmt) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1363 || use_stmt != stmt2)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1364 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1365 |
111 | 1366 ptr1_align = get_pointer_alignment (ptr1); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1367 /* Construct the new source string literal. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1368 src_buf = XALLOCAVEC (char, src_len + 1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1369 if (callee1) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1370 memcpy (src_buf, |
111 | 1371 TREE_STRING_POINTER (str1) + tree_to_uhwi (off1), |
1372 tree_to_uhwi (len1)); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1373 else |
111 | 1374 src_buf[0] = tree_to_shwi (src1); |
1375 memset (src_buf + tree_to_uhwi (diff), | |
1376 tree_to_shwi (val2), tree_to_uhwi (len2)); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1377 src_buf[src_len] = '\0'; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1378 /* Neither builtin_strncpy_read_str nor builtin_memcpy_read_str |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1379 handle embedded '\0's. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1380 if (strlen (src_buf) != src_len) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1381 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1382 rtl_profile_for_bb (gimple_bb (stmt2)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1383 /* If the new memcpy wouldn't be emitted by storing the literal |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1384 by pieces, this optimization might enlarge .rodata too much, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1385 as commonly used string literals couldn't be shared any |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1386 longer. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1387 if (!can_store_by_pieces (src_len, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1388 builtin_strncpy_read_str, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1389 src_buf, ptr1_align, false)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1390 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1391 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1392 new_str_cst = build_string_literal (src_len, src_buf); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1393 if (callee1) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1394 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1395 /* If STMT1 is a mem{,p}cpy call, adjust it and remove |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1396 memset call. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1397 if (lhs1 && DECL_FUNCTION_CODE (callee1) == BUILT_IN_MEMPCPY) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1398 gimple_call_set_lhs (stmt1, NULL_TREE); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1399 gimple_call_set_arg (stmt1, 1, new_str_cst); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1400 gimple_call_set_arg (stmt1, 2, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1401 build_int_cst (TREE_TYPE (len1), src_len)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1402 update_stmt (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1403 unlink_stmt_vdef (stmt2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1404 gsi_remove (gsi_p, true); |
111 | 1405 fwprop_invalidate_lattice (gimple_get_lhs (stmt2)); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1406 release_defs (stmt2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1407 if (lhs1 && DECL_FUNCTION_CODE (callee1) == BUILT_IN_MEMPCPY) |
111 | 1408 { |
1409 fwprop_invalidate_lattice (lhs1); | |
1410 release_ssa_name (lhs1); | |
1411 } | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1412 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1413 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1414 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1415 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1416 /* Otherwise, if STMT1 is length 1 memcpy optimized into |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1417 assignment, remove STMT1 and change memset call into |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1418 memcpy call. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1419 gimple_stmt_iterator gsi = gsi_for_stmt (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1420 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1421 if (!is_gimple_val (ptr1)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1422 ptr1 = force_gimple_operand_gsi (gsi_p, ptr1, true, NULL_TREE, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1423 true, GSI_SAME_STMT); |
111 | 1424 gimple_call_set_fndecl (stmt2, |
1425 builtin_decl_explicit (BUILT_IN_MEMCPY)); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1426 gimple_call_set_arg (stmt2, 0, ptr1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1427 gimple_call_set_arg (stmt2, 1, new_str_cst); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1428 gimple_call_set_arg (stmt2, 2, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1429 build_int_cst (TREE_TYPE (len2), src_len)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1430 unlink_stmt_vdef (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1431 gsi_remove (&gsi, true); |
111 | 1432 fwprop_invalidate_lattice (gimple_get_lhs (stmt1)); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1433 release_defs (stmt1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1434 update_stmt (stmt2); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1435 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1436 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1437 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1438 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1439 default: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1440 break; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1441 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1442 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1443 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1444 |
111 | 1445 /* Given a ssa_name in NAME see if it was defined by an assignment and |
1446 set CODE to be the code and ARG1 to the first operand on the rhs and ARG2 | |
1447 to the second operand on the rhs. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1448 |
111 | 1449 static inline void |
1450 defcodefor_name (tree name, enum tree_code *code, tree *arg1, tree *arg2) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1451 { |
111 | 1452 gimple *def; |
1453 enum tree_code code1; | |
1454 tree arg11; | |
1455 tree arg21; | |
1456 tree arg31; | |
1457 enum gimple_rhs_class grhs_class; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1458 |
111 | 1459 code1 = TREE_CODE (name); |
1460 arg11 = name; | |
1461 arg21 = NULL_TREE; | |
1462 arg31 = NULL_TREE; | |
1463 grhs_class = get_gimple_rhs_class (code1); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1464 |
111 | 1465 if (code1 == SSA_NAME) |
1466 { | |
1467 def = SSA_NAME_DEF_STMT (name); | |
1468 | |
1469 if (def && is_gimple_assign (def) | |
1470 && can_propagate_from (def)) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1471 { |
111 | 1472 code1 = gimple_assign_rhs_code (def); |
1473 arg11 = gimple_assign_rhs1 (def); | |
1474 arg21 = gimple_assign_rhs2 (def); | |
1475 arg31 = gimple_assign_rhs3 (def); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1476 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1477 } |
111 | 1478 else if (grhs_class != GIMPLE_SINGLE_RHS) |
1479 code1 = ERROR_MARK; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1480 |
111 | 1481 *code = code1; |
1482 *arg1 = arg11; | |
1483 if (arg2) | |
1484 *arg2 = arg21; | |
1485 if (arg31) | |
1486 *code = ERROR_MARK; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1487 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
1488 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1489 |
111 | 1490 /* Recognize rotation patterns. Return true if a transformation |
1491 applied, otherwise return false. | |
1492 | |
1493 We are looking for X with unsigned type T with bitsize B, OP being | |
1494 +, | or ^, some type T2 wider than T. For: | |
1495 (X << CNT1) OP (X >> CNT2) iff CNT1 + CNT2 == B | |
1496 ((T) ((T2) X << CNT1)) OP ((T) ((T2) X >> CNT2)) iff CNT1 + CNT2 == B | |
1497 | |
1498 transform these into: | |
1499 X r<< CNT1 | |
1500 | |
1501 Or for: | |
1502 (X << Y) OP (X >> (B - Y)) | |
1503 (X << (int) Y) OP (X >> (int) (B - Y)) | |
1504 ((T) ((T2) X << Y)) OP ((T) ((T2) X >> (B - Y))) | |
1505 ((T) ((T2) X << (int) Y)) OP ((T) ((T2) X >> (int) (B - Y))) | |
1506 (X << Y) | (X >> ((-Y) & (B - 1))) | |
1507 (X << (int) Y) | (X >> (int) ((-Y) & (B - 1))) | |
1508 ((T) ((T2) X << Y)) | ((T) ((T2) X >> ((-Y) & (B - 1)))) | |
1509 ((T) ((T2) X << (int) Y)) | ((T) ((T2) X >> (int) ((-Y) & (B - 1)))) | |
1510 | |
1511 transform these into: | |
1512 X r<< Y | |
1513 | |
1514 Or for: | |
1515 (X << (Y & (B - 1))) | (X >> ((-Y) & (B - 1))) | |
1516 (X << (int) (Y & (B - 1))) | (X >> (int) ((-Y) & (B - 1))) | |
1517 ((T) ((T2) X << (Y & (B - 1)))) | ((T) ((T2) X >> ((-Y) & (B - 1)))) | |
1518 ((T) ((T2) X << (int) (Y & (B - 1)))) \ | |
1519 | ((T) ((T2) X >> (int) ((-Y) & (B - 1)))) | |
1520 | |
1521 transform these into: | |
1522 X r<< (Y & (B - 1)) | |
1523 | |
1524 Note, in the patterns with T2 type, the type of OP operands | |
1525 might be even a signed type, but should have precision B. | |
1526 Expressions with & (B - 1) should be recognized only if B is | |
1527 a power of 2. */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1528 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1529 static bool |
111 | 1530 simplify_rotate (gimple_stmt_iterator *gsi) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1531 { |
111 | 1532 gimple *stmt = gsi_stmt (*gsi); |
1533 tree arg[2], rtype, rotcnt = NULL_TREE; | |
1534 tree def_arg1[2], def_arg2[2]; | |
1535 enum tree_code def_code[2]; | |
1536 tree lhs; | |
1537 int i; | |
1538 bool swapped_p = false; | |
1539 gimple *g; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1540 |
111 | 1541 arg[0] = gimple_assign_rhs1 (stmt); |
1542 arg[1] = gimple_assign_rhs2 (stmt); | |
1543 rtype = TREE_TYPE (arg[0]); | |
1544 | |
1545 /* Only create rotates in complete modes. Other cases are not | |
1546 expanded properly. */ | |
1547 if (!INTEGRAL_TYPE_P (rtype) | |
1548 || !type_has_mode_precision_p (rtype)) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1549 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1550 |
111 | 1551 for (i = 0; i < 2; i++) |
1552 defcodefor_name (arg[i], &def_code[i], &def_arg1[i], &def_arg2[i]); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1553 |
111 | 1554 /* Look through narrowing conversions. */ |
1555 if (CONVERT_EXPR_CODE_P (def_code[0]) | |
1556 && CONVERT_EXPR_CODE_P (def_code[1]) | |
1557 && INTEGRAL_TYPE_P (TREE_TYPE (def_arg1[0])) | |
1558 && INTEGRAL_TYPE_P (TREE_TYPE (def_arg1[1])) | |
1559 && TYPE_PRECISION (TREE_TYPE (def_arg1[0])) | |
1560 == TYPE_PRECISION (TREE_TYPE (def_arg1[1])) | |
1561 && TYPE_PRECISION (TREE_TYPE (def_arg1[0])) > TYPE_PRECISION (rtype) | |
1562 && has_single_use (arg[0]) | |
1563 && has_single_use (arg[1])) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1564 { |
111 | 1565 for (i = 0; i < 2; i++) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1566 { |
111 | 1567 arg[i] = def_arg1[i]; |
1568 defcodefor_name (arg[i], &def_code[i], &def_arg1[i], &def_arg2[i]); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1569 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1570 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1571 |
111 | 1572 /* One operand has to be LSHIFT_EXPR and one RSHIFT_EXPR. */ |
1573 for (i = 0; i < 2; i++) | |
1574 if (def_code[i] != LSHIFT_EXPR && def_code[i] != RSHIFT_EXPR) | |
1575 return false; | |
1576 else if (!has_single_use (arg[i])) | |
1577 return false; | |
1578 if (def_code[0] == def_code[1]) | |
1579 return false; | |
1580 | |
1581 /* If we've looked through narrowing conversions before, look through | |
1582 widening conversions from unsigned type with the same precision | |
1583 as rtype here. */ | |
1584 if (TYPE_PRECISION (TREE_TYPE (def_arg1[0])) != TYPE_PRECISION (rtype)) | |
1585 for (i = 0; i < 2; i++) | |
1586 { | |
1587 tree tem; | |
1588 enum tree_code code; | |
1589 defcodefor_name (def_arg1[i], &code, &tem, NULL); | |
1590 if (!CONVERT_EXPR_CODE_P (code) | |
1591 || !INTEGRAL_TYPE_P (TREE_TYPE (tem)) | |
1592 || TYPE_PRECISION (TREE_TYPE (tem)) != TYPE_PRECISION (rtype)) | |
1593 return false; | |
1594 def_arg1[i] = tem; | |
1595 } | |
1596 /* Both shifts have to use the same first operand. */ | |
1597 if (!operand_equal_for_phi_arg_p (def_arg1[0], def_arg1[1]) | |
1598 || !types_compatible_p (TREE_TYPE (def_arg1[0]), | |
1599 TREE_TYPE (def_arg1[1]))) | |
1600 return false; | |
1601 if (!TYPE_UNSIGNED (TREE_TYPE (def_arg1[0]))) | |
1602 return false; | |
1603 | |
1604 /* CNT1 + CNT2 == B case above. */ | |
1605 if (tree_fits_uhwi_p (def_arg2[0]) | |
1606 && tree_fits_uhwi_p (def_arg2[1]) | |
1607 && tree_to_uhwi (def_arg2[0]) | |
1608 + tree_to_uhwi (def_arg2[1]) == TYPE_PRECISION (rtype)) | |
1609 rotcnt = def_arg2[0]; | |
1610 else if (TREE_CODE (def_arg2[0]) != SSA_NAME | |
1611 || TREE_CODE (def_arg2[1]) != SSA_NAME) | |
1612 return false; | |
1613 else | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1614 { |
111 | 1615 tree cdef_arg1[2], cdef_arg2[2], def_arg2_alt[2]; |
1616 enum tree_code cdef_code[2]; | |
1617 /* Look through conversion of the shift count argument. | |
1618 The C/C++ FE cast any shift count argument to integer_type_node. | |
1619 The only problem might be if the shift count type maximum value | |
1620 is equal or smaller than number of bits in rtype. */ | |
1621 for (i = 0; i < 2; i++) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1622 { |
111 | 1623 def_arg2_alt[i] = def_arg2[i]; |
1624 defcodefor_name (def_arg2[i], &cdef_code[i], | |
1625 &cdef_arg1[i], &cdef_arg2[i]); | |
1626 if (CONVERT_EXPR_CODE_P (cdef_code[i]) | |
1627 && INTEGRAL_TYPE_P (TREE_TYPE (cdef_arg1[i])) | |
1628 && TYPE_PRECISION (TREE_TYPE (cdef_arg1[i])) | |
1629 > floor_log2 (TYPE_PRECISION (rtype)) | |
1630 && type_has_mode_precision_p (TREE_TYPE (cdef_arg1[i]))) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1631 { |
111 | 1632 def_arg2_alt[i] = cdef_arg1[i]; |
1633 defcodefor_name (def_arg2_alt[i], &cdef_code[i], | |
1634 &cdef_arg1[i], &cdef_arg2[i]); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1635 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1636 } |
111 | 1637 for (i = 0; i < 2; i++) |
1638 /* Check for one shift count being Y and the other B - Y, | |
1639 with optional casts. */ | |
1640 if (cdef_code[i] == MINUS_EXPR | |
1641 && tree_fits_shwi_p (cdef_arg1[i]) | |
1642 && tree_to_shwi (cdef_arg1[i]) == TYPE_PRECISION (rtype) | |
1643 && TREE_CODE (cdef_arg2[i]) == SSA_NAME) | |
1644 { | |
1645 tree tem; | |
1646 enum tree_code code; | |
1647 | |
1648 if (cdef_arg2[i] == def_arg2[1 - i] | |
1649 || cdef_arg2[i] == def_arg2_alt[1 - i]) | |
1650 { | |
1651 rotcnt = cdef_arg2[i]; | |
1652 break; | |
1653 } | |
1654 defcodefor_name (cdef_arg2[i], &code, &tem, NULL); | |
1655 if (CONVERT_EXPR_CODE_P (code) | |
1656 && INTEGRAL_TYPE_P (TREE_TYPE (tem)) | |
1657 && TYPE_PRECISION (TREE_TYPE (tem)) | |
1658 > floor_log2 (TYPE_PRECISION (rtype)) | |
1659 && type_has_mode_precision_p (TREE_TYPE (tem)) | |
1660 && (tem == def_arg2[1 - i] | |
1661 || tem == def_arg2_alt[1 - i])) | |
1662 { | |
1663 rotcnt = tem; | |
1664 break; | |
1665 } | |
1666 } | |
1667 /* The above sequence isn't safe for Y being 0, | |
1668 because then one of the shifts triggers undefined behavior. | |
1669 This alternative is safe even for rotation count of 0. | |
1670 One shift count is Y and the other (-Y) & (B - 1). | |
1671 Or one shift count is Y & (B - 1) and the other (-Y) & (B - 1). */ | |
1672 else if (cdef_code[i] == BIT_AND_EXPR | |
1673 && pow2p_hwi (TYPE_PRECISION (rtype)) | |
1674 && tree_fits_shwi_p (cdef_arg2[i]) | |
1675 && tree_to_shwi (cdef_arg2[i]) | |
1676 == TYPE_PRECISION (rtype) - 1 | |
1677 && TREE_CODE (cdef_arg1[i]) == SSA_NAME | |
1678 && gimple_assign_rhs_code (stmt) == BIT_IOR_EXPR) | |
1679 { | |
1680 tree tem; | |
1681 enum tree_code code; | |
1682 | |
1683 defcodefor_name (cdef_arg1[i], &code, &tem, NULL); | |
1684 if (CONVERT_EXPR_CODE_P (code) | |
1685 && INTEGRAL_TYPE_P (TREE_TYPE (tem)) | |
1686 && TYPE_PRECISION (TREE_TYPE (tem)) | |
1687 > floor_log2 (TYPE_PRECISION (rtype)) | |
1688 && type_has_mode_precision_p (TREE_TYPE (tem))) | |
1689 defcodefor_name (tem, &code, &tem, NULL); | |
1690 | |
1691 if (code == NEGATE_EXPR) | |
1692 { | |
1693 if (tem == def_arg2[1 - i] || tem == def_arg2_alt[1 - i]) | |
1694 { | |
1695 rotcnt = tem; | |
1696 break; | |
1697 } | |
1698 tree tem2; | |
1699 defcodefor_name (tem, &code, &tem2, NULL); | |
1700 if (CONVERT_EXPR_CODE_P (code) | |
1701 && INTEGRAL_TYPE_P (TREE_TYPE (tem2)) | |
1702 && TYPE_PRECISION (TREE_TYPE (tem2)) | |
1703 > floor_log2 (TYPE_PRECISION (rtype)) | |
1704 && type_has_mode_precision_p (TREE_TYPE (tem2))) | |
1705 { | |
1706 if (tem2 == def_arg2[1 - i] | |
1707 || tem2 == def_arg2_alt[1 - i]) | |
1708 { | |
1709 rotcnt = tem2; | |
1710 break; | |
1711 } | |
1712 } | |
1713 else | |
1714 tem2 = NULL_TREE; | |
1715 | |
1716 if (cdef_code[1 - i] == BIT_AND_EXPR | |
1717 && tree_fits_shwi_p (cdef_arg2[1 - i]) | |
1718 && tree_to_shwi (cdef_arg2[1 - i]) | |
1719 == TYPE_PRECISION (rtype) - 1 | |
1720 && TREE_CODE (cdef_arg1[1 - i]) == SSA_NAME) | |
1721 { | |
1722 if (tem == cdef_arg1[1 - i] | |
1723 || tem2 == cdef_arg1[1 - i]) | |
1724 { | |
1725 rotcnt = def_arg2[1 - i]; | |
1726 break; | |
1727 } | |
1728 tree tem3; | |
1729 defcodefor_name (cdef_arg1[1 - i], &code, &tem3, NULL); | |
1730 if (CONVERT_EXPR_CODE_P (code) | |
1731 && INTEGRAL_TYPE_P (TREE_TYPE (tem3)) | |
1732 && TYPE_PRECISION (TREE_TYPE (tem3)) | |
1733 > floor_log2 (TYPE_PRECISION (rtype)) | |
1734 && type_has_mode_precision_p (TREE_TYPE (tem3))) | |
1735 { | |
1736 if (tem == tem3 || tem2 == tem3) | |
1737 { | |
1738 rotcnt = def_arg2[1 - i]; | |
1739 break; | |
1740 } | |
1741 } | |
1742 } | |
1743 } | |
1744 } | |
1745 if (rotcnt == NULL_TREE) | |
1746 return false; | |
1747 swapped_p = i != 1; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1748 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1749 |
111 | 1750 if (!useless_type_conversion_p (TREE_TYPE (def_arg2[0]), |
1751 TREE_TYPE (rotcnt))) | |
1752 { | |
1753 g = gimple_build_assign (make_ssa_name (TREE_TYPE (def_arg2[0])), | |
1754 NOP_EXPR, rotcnt); | |
1755 gsi_insert_before (gsi, g, GSI_SAME_STMT); | |
1756 rotcnt = gimple_assign_lhs (g); | |
1757 } | |
1758 lhs = gimple_assign_lhs (stmt); | |
1759 if (!useless_type_conversion_p (rtype, TREE_TYPE (def_arg1[0]))) | |
1760 lhs = make_ssa_name (TREE_TYPE (def_arg1[0])); | |
1761 g = gimple_build_assign (lhs, | |
1762 ((def_code[0] == LSHIFT_EXPR) ^ swapped_p) | |
1763 ? LROTATE_EXPR : RROTATE_EXPR, def_arg1[0], rotcnt); | |
1764 if (!useless_type_conversion_p (rtype, TREE_TYPE (def_arg1[0]))) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1765 { |
111 | 1766 gsi_insert_before (gsi, g, GSI_SAME_STMT); |
1767 g = gimple_build_assign (gimple_assign_lhs (stmt), NOP_EXPR, lhs); | |
1768 } | |
1769 gsi_replace (gsi, g, false); | |
1770 return true; | |
1771 } | |
1772 | |
1773 /* Combine an element access with a shuffle. Returns true if there were | |
1774 any changes made, else it returns false. */ | |
1775 | |
1776 static bool | |
1777 simplify_bitfield_ref (gimple_stmt_iterator *gsi) | |
1778 { | |
1779 gimple *stmt = gsi_stmt (*gsi); | |
1780 gimple *def_stmt; | |
1781 tree op, op0, op1, op2; | |
1782 tree elem_type; | |
1783 unsigned idx, n, size; | |
1784 enum tree_code code; | |
1785 | |
1786 op = gimple_assign_rhs1 (stmt); | |
1787 gcc_checking_assert (TREE_CODE (op) == BIT_FIELD_REF); | |
1788 | |
1789 op0 = TREE_OPERAND (op, 0); | |
1790 if (TREE_CODE (op0) != SSA_NAME | |
1791 || TREE_CODE (TREE_TYPE (op0)) != VECTOR_TYPE) | |
1792 return false; | |
1793 | |
1794 def_stmt = get_prop_source_stmt (op0, false, NULL); | |
1795 if (!def_stmt || !can_propagate_from (def_stmt)) | |
1796 return false; | |
1797 | |
1798 op1 = TREE_OPERAND (op, 1); | |
1799 op2 = TREE_OPERAND (op, 2); | |
1800 code = gimple_assign_rhs_code (def_stmt); | |
1801 | |
1802 if (code == CONSTRUCTOR) | |
1803 { | |
1804 tree tem = fold_ternary (BIT_FIELD_REF, TREE_TYPE (op), | |
1805 gimple_assign_rhs1 (def_stmt), op1, op2); | |
1806 if (!tem || !valid_gimple_rhs_p (tem)) | |
1807 return false; | |
1808 gimple_assign_set_rhs_from_tree (gsi, tem); | |
1809 update_stmt (gsi_stmt (*gsi)); | |
1810 return true; | |
1811 } | |
1812 | |
1813 elem_type = TREE_TYPE (TREE_TYPE (op0)); | |
1814 if (TREE_TYPE (op) != elem_type) | |
1815 return false; | |
1816 | |
1817 size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type)); | |
1818 n = TREE_INT_CST_LOW (op1) / size; | |
1819 if (n != 1) | |
1820 return false; | |
1821 idx = TREE_INT_CST_LOW (op2) / size; | |
1822 | |
1823 if (code == VEC_PERM_EXPR) | |
1824 { | |
1825 tree p, m, tem; | |
1826 unsigned nelts; | |
1827 m = gimple_assign_rhs3 (def_stmt); | |
1828 if (TREE_CODE (m) != VECTOR_CST) | |
1829 return false; | |
1830 nelts = VECTOR_CST_NELTS (m); | |
1831 idx = TREE_INT_CST_LOW (VECTOR_CST_ELT (m, idx)); | |
1832 idx %= 2 * nelts; | |
1833 if (idx < nelts) | |
1834 { | |
1835 p = gimple_assign_rhs1 (def_stmt); | |
1836 } | |
1837 else | |
1838 { | |
1839 p = gimple_assign_rhs2 (def_stmt); | |
1840 idx -= nelts; | |
1841 } | |
1842 tem = build3 (BIT_FIELD_REF, TREE_TYPE (op), | |
1843 unshare_expr (p), op1, bitsize_int (idx * size)); | |
1844 gimple_assign_set_rhs1 (stmt, tem); | |
1845 fold_stmt (gsi); | |
1846 update_stmt (gsi_stmt (*gsi)); | |
1847 return true; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1848 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1849 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1850 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1851 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1852 |
111 | 1853 /* Determine whether applying the 2 permutations (mask1 then mask2) |
1854 gives back one of the input. */ | |
1855 | |
1856 static int | |
1857 is_combined_permutation_identity (tree mask1, tree mask2) | |
1858 { | |
1859 tree mask; | |
1860 unsigned int nelts, i, j; | |
1861 bool maybe_identity1 = true; | |
1862 bool maybe_identity2 = true; | |
1863 | |
1864 gcc_checking_assert (TREE_CODE (mask1) == VECTOR_CST | |
1865 && TREE_CODE (mask2) == VECTOR_CST); | |
1866 mask = fold_ternary (VEC_PERM_EXPR, TREE_TYPE (mask1), mask1, mask1, mask2); | |
1867 gcc_assert (TREE_CODE (mask) == VECTOR_CST); | |
1868 | |
1869 nelts = VECTOR_CST_NELTS (mask); | |
1870 for (i = 0; i < nelts; i++) | |
1871 { | |
1872 tree val = VECTOR_CST_ELT (mask, i); | |
1873 gcc_assert (TREE_CODE (val) == INTEGER_CST); | |
1874 j = TREE_INT_CST_LOW (val) & (2 * nelts - 1); | |
1875 if (j == i) | |
1876 maybe_identity2 = false; | |
1877 else if (j == i + nelts) | |
1878 maybe_identity1 = false; | |
1879 else | |
1880 return 0; | |
1881 } | |
1882 return maybe_identity1 ? 1 : maybe_identity2 ? 2 : 0; | |
1883 } | |
1884 | |
1885 /* Combine a shuffle with its arguments. Returns 1 if there were any | |
1886 changes made, 2 if cfg-cleanup needs to run. Else it returns 0. */ | |
1887 | |
1888 static int | |
1889 simplify_permutation (gimple_stmt_iterator *gsi) | |
1890 { | |
1891 gimple *stmt = gsi_stmt (*gsi); | |
1892 gimple *def_stmt; | |
1893 tree op0, op1, op2, op3, arg0, arg1; | |
1894 enum tree_code code; | |
1895 bool single_use_op0 = false; | |
1896 | |
1897 gcc_checking_assert (gimple_assign_rhs_code (stmt) == VEC_PERM_EXPR); | |
1898 | |
1899 op0 = gimple_assign_rhs1 (stmt); | |
1900 op1 = gimple_assign_rhs2 (stmt); | |
1901 op2 = gimple_assign_rhs3 (stmt); | |
1902 | |
1903 if (TREE_CODE (op2) != VECTOR_CST) | |
1904 return 0; | |
1905 | |
1906 if (TREE_CODE (op0) == VECTOR_CST) | |
1907 { | |
1908 code = VECTOR_CST; | |
1909 arg0 = op0; | |
1910 } | |
1911 else if (TREE_CODE (op0) == SSA_NAME) | |
1912 { | |
1913 def_stmt = get_prop_source_stmt (op0, false, &single_use_op0); | |
1914 if (!def_stmt || !can_propagate_from (def_stmt)) | |
1915 return 0; | |
1916 | |
1917 code = gimple_assign_rhs_code (def_stmt); | |
1918 arg0 = gimple_assign_rhs1 (def_stmt); | |
1919 } | |
1920 else | |
1921 return 0; | |
1922 | |
1923 /* Two consecutive shuffles. */ | |
1924 if (code == VEC_PERM_EXPR) | |
1925 { | |
1926 tree orig; | |
1927 int ident; | |
1928 | |
1929 if (op0 != op1) | |
1930 return 0; | |
1931 op3 = gimple_assign_rhs3 (def_stmt); | |
1932 if (TREE_CODE (op3) != VECTOR_CST) | |
1933 return 0; | |
1934 ident = is_combined_permutation_identity (op3, op2); | |
1935 if (!ident) | |
1936 return 0; | |
1937 orig = (ident == 1) ? gimple_assign_rhs1 (def_stmt) | |
1938 : gimple_assign_rhs2 (def_stmt); | |
1939 gimple_assign_set_rhs1 (stmt, unshare_expr (orig)); | |
1940 gimple_assign_set_rhs_code (stmt, TREE_CODE (orig)); | |
1941 gimple_set_num_ops (stmt, 2); | |
1942 update_stmt (stmt); | |
1943 return remove_prop_source_from_use (op0) ? 2 : 1; | |
1944 } | |
1945 | |
1946 /* Shuffle of a constructor. */ | |
1947 else if (code == CONSTRUCTOR || code == VECTOR_CST) | |
1948 { | |
1949 tree opt; | |
1950 bool ret = false; | |
1951 if (op0 != op1) | |
1952 { | |
1953 if (TREE_CODE (op0) == SSA_NAME && !single_use_op0) | |
1954 return 0; | |
1955 | |
1956 if (TREE_CODE (op1) == VECTOR_CST) | |
1957 arg1 = op1; | |
1958 else if (TREE_CODE (op1) == SSA_NAME) | |
1959 { | |
1960 enum tree_code code2; | |
1961 | |
1962 gimple *def_stmt2 = get_prop_source_stmt (op1, true, NULL); | |
1963 if (!def_stmt2 || !can_propagate_from (def_stmt2)) | |
1964 return 0; | |
1965 | |
1966 code2 = gimple_assign_rhs_code (def_stmt2); | |
1967 if (code2 != CONSTRUCTOR && code2 != VECTOR_CST) | |
1968 return 0; | |
1969 arg1 = gimple_assign_rhs1 (def_stmt2); | |
1970 } | |
1971 else | |
1972 return 0; | |
1973 } | |
1974 else | |
1975 { | |
1976 /* Already used twice in this statement. */ | |
1977 if (TREE_CODE (op0) == SSA_NAME && num_imm_uses (op0) > 2) | |
1978 return 0; | |
1979 arg1 = arg0; | |
1980 } | |
1981 opt = fold_ternary (VEC_PERM_EXPR, TREE_TYPE (op0), arg0, arg1, op2); | |
1982 if (!opt | |
1983 || (TREE_CODE (opt) != CONSTRUCTOR && TREE_CODE (opt) != VECTOR_CST)) | |
1984 return 0; | |
1985 gimple_assign_set_rhs_from_tree (gsi, opt); | |
1986 update_stmt (gsi_stmt (*gsi)); | |
1987 if (TREE_CODE (op0) == SSA_NAME) | |
1988 ret = remove_prop_source_from_use (op0); | |
1989 if (op0 != op1 && TREE_CODE (op1) == SSA_NAME) | |
1990 ret |= remove_prop_source_from_use (op1); | |
1991 return ret ? 2 : 1; | |
1992 } | |
1993 | |
1994 return 0; | |
1995 } | |
1996 | |
1997 /* Recognize a VEC_PERM_EXPR. Returns true if there were any changes. */ | |
1998 | |
1999 static bool | |
2000 simplify_vector_constructor (gimple_stmt_iterator *gsi) | |
2001 { | |
2002 gimple *stmt = gsi_stmt (*gsi); | |
2003 gimple *def_stmt; | |
2004 tree op, op2, orig, type, elem_type; | |
2005 unsigned elem_size, nelts, i; | |
2006 enum tree_code code, conv_code; | |
2007 constructor_elt *elt; | |
2008 bool maybe_ident; | |
2009 | |
2010 gcc_checking_assert (gimple_assign_rhs_code (stmt) == CONSTRUCTOR); | |
2011 | |
2012 op = gimple_assign_rhs1 (stmt); | |
2013 type = TREE_TYPE (op); | |
2014 gcc_checking_assert (TREE_CODE (type) == VECTOR_TYPE); | |
2015 | |
2016 nelts = TYPE_VECTOR_SUBPARTS (type); | |
2017 elem_type = TREE_TYPE (type); | |
2018 elem_size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type)); | |
0 | 2019 |
111 | 2020 auto_vec_perm_indices sel (nelts); |
2021 orig = NULL; | |
2022 conv_code = ERROR_MARK; | |
2023 maybe_ident = true; | |
2024 FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (op), i, elt) | |
2025 { | |
2026 tree ref, op1; | |
2027 | |
2028 if (i >= nelts) | |
2029 return false; | |
2030 | |
2031 if (TREE_CODE (elt->value) != SSA_NAME) | |
2032 return false; | |
2033 def_stmt = get_prop_source_stmt (elt->value, false, NULL); | |
2034 if (!def_stmt) | |
2035 return false; | |
2036 code = gimple_assign_rhs_code (def_stmt); | |
2037 if (code == FLOAT_EXPR | |
2038 || code == FIX_TRUNC_EXPR) | |
2039 { | |
2040 op1 = gimple_assign_rhs1 (def_stmt); | |
2041 if (conv_code == ERROR_MARK) | |
2042 { | |
2043 if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (elt->value))) | |
2044 != GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1)))) | |
2045 return false; | |
2046 conv_code = code; | |
2047 } | |
2048 else if (conv_code != code) | |
2049 return false; | |
2050 if (TREE_CODE (op1) != SSA_NAME) | |
2051 return false; | |
2052 def_stmt = SSA_NAME_DEF_STMT (op1); | |
2053 if (! is_gimple_assign (def_stmt)) | |
2054 return false; | |
2055 code = gimple_assign_rhs_code (def_stmt); | |
2056 } | |
2057 if (code != BIT_FIELD_REF) | |
2058 return false; | |
2059 op1 = gimple_assign_rhs1 (def_stmt); | |
2060 ref = TREE_OPERAND (op1, 0); | |
2061 if (orig) | |
2062 { | |
2063 if (ref != orig) | |
2064 return false; | |
2065 } | |
2066 else | |
2067 { | |
2068 if (TREE_CODE (ref) != SSA_NAME) | |
2069 return false; | |
2070 if (! VECTOR_TYPE_P (TREE_TYPE (ref)) | |
2071 || ! useless_type_conversion_p (TREE_TYPE (op1), | |
2072 TREE_TYPE (TREE_TYPE (ref)))) | |
2073 return false; | |
2074 orig = ref; | |
2075 } | |
2076 if (TREE_INT_CST_LOW (TREE_OPERAND (op1, 1)) != elem_size) | |
2077 return false; | |
2078 unsigned int elt = TREE_INT_CST_LOW (TREE_OPERAND (op1, 2)) / elem_size; | |
2079 if (elt != i) | |
2080 maybe_ident = false; | |
2081 sel.quick_push (elt); | |
2082 } | |
2083 if (i < nelts) | |
2084 return false; | |
2085 | |
2086 if (! VECTOR_TYPE_P (TREE_TYPE (orig)) | |
2087 || (TYPE_VECTOR_SUBPARTS (type) | |
2088 != TYPE_VECTOR_SUBPARTS (TREE_TYPE (orig)))) | |
2089 return false; | |
2090 | |
2091 tree tem; | |
2092 if (conv_code != ERROR_MARK | |
2093 && (! supportable_convert_operation (conv_code, type, TREE_TYPE (orig), | |
2094 &tem, &conv_code) | |
2095 || conv_code == CALL_EXPR)) | |
2096 return false; | |
2097 | |
2098 if (maybe_ident) | |
2099 { | |
2100 if (conv_code == ERROR_MARK) | |
2101 gimple_assign_set_rhs_from_tree (gsi, orig); | |
2102 else | |
2103 gimple_assign_set_rhs_with_ops (gsi, conv_code, orig, | |
2104 NULL_TREE, NULL_TREE); | |
2105 } | |
2106 else | |
2107 { | |
2108 tree mask_type; | |
2109 | |
2110 if (!can_vec_perm_p (TYPE_MODE (type), false, &sel)) | |
2111 return false; | |
2112 mask_type | |
2113 = build_vector_type (build_nonstandard_integer_type (elem_size, 1), | |
2114 nelts); | |
2115 if (GET_MODE_CLASS (TYPE_MODE (mask_type)) != MODE_VECTOR_INT | |
2116 || GET_MODE_SIZE (TYPE_MODE (mask_type)) | |
2117 != GET_MODE_SIZE (TYPE_MODE (type))) | |
2118 return false; | |
2119 auto_vec<tree, 32> mask_elts (nelts); | |
2120 for (i = 0; i < nelts; i++) | |
2121 mask_elts.quick_push (build_int_cst (TREE_TYPE (mask_type), sel[i])); | |
2122 op2 = build_vector (mask_type, mask_elts); | |
2123 if (conv_code == ERROR_MARK) | |
2124 gimple_assign_set_rhs_with_ops (gsi, VEC_PERM_EXPR, orig, orig, op2); | |
2125 else | |
2126 { | |
2127 gimple *perm | |
2128 = gimple_build_assign (make_ssa_name (TREE_TYPE (orig)), | |
2129 VEC_PERM_EXPR, orig, orig, op2); | |
2130 orig = gimple_assign_lhs (perm); | |
2131 gsi_insert_before (gsi, perm, GSI_SAME_STMT); | |
2132 gimple_assign_set_rhs_with_ops (gsi, conv_code, orig, | |
2133 NULL_TREE, NULL_TREE); | |
2134 } | |
2135 } | |
2136 update_stmt (gsi_stmt (*gsi)); | |
2137 return true; | |
2138 } | |
2139 | |
2140 | |
2141 /* Primitive "lattice" function for gimple_simplify. */ | |
2142 | |
2143 static tree | |
2144 fwprop_ssa_val (tree name) | |
0 | 2145 { |
111 | 2146 /* First valueize NAME. */ |
2147 if (TREE_CODE (name) == SSA_NAME | |
2148 && SSA_NAME_VERSION (name) < lattice.length ()) | |
2149 { | |
2150 tree val = lattice[SSA_NAME_VERSION (name)]; | |
2151 if (val) | |
2152 name = val; | |
2153 } | |
2154 /* We continue matching along SSA use-def edges for SSA names | |
2155 that are not single-use. Currently there are no patterns | |
2156 that would cause any issues with that. */ | |
2157 return name; | |
2158 } | |
2159 | |
2160 /* Main entry point for the forward propagation and statement combine | |
2161 optimizer. */ | |
2162 | |
2163 namespace { | |
2164 | |
2165 const pass_data pass_data_forwprop = | |
2166 { | |
2167 GIMPLE_PASS, /* type */ | |
2168 "forwprop", /* name */ | |
2169 OPTGROUP_NONE, /* optinfo_flags */ | |
2170 TV_TREE_FORWPROP, /* tv_id */ | |
2171 ( PROP_cfg | PROP_ssa ), /* properties_required */ | |
2172 0, /* properties_provided */ | |
2173 0, /* properties_destroyed */ | |
2174 0, /* todo_flags_start */ | |
2175 TODO_update_ssa, /* todo_flags_finish */ | |
2176 }; | |
2177 | |
2178 class pass_forwprop : public gimple_opt_pass | |
2179 { | |
2180 public: | |
2181 pass_forwprop (gcc::context *ctxt) | |
2182 : gimple_opt_pass (pass_data_forwprop, ctxt) | |
2183 {} | |
2184 | |
2185 /* opt_pass methods: */ | |
2186 opt_pass * clone () { return new pass_forwprop (m_ctxt); } | |
2187 virtual bool gate (function *) { return flag_tree_forwprop; } | |
2188 virtual unsigned int execute (function *); | |
2189 | |
2190 }; // class pass_forwprop | |
2191 | |
2192 unsigned int | |
2193 pass_forwprop::execute (function *fun) | |
2194 { | |
0 | 2195 unsigned int todoflags = 0; |
2196 | |
2197 cfg_changed = false; | |
2198 | |
111 | 2199 /* Combine stmts with the stmts defining their operands. Do that |
2200 in an order that guarantees visiting SSA defs before SSA uses. */ | |
2201 lattice.create (num_ssa_names); | |
2202 lattice.quick_grow_cleared (num_ssa_names); | |
2203 int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (fun)); | |
2204 int postorder_num = pre_and_rev_post_order_compute_fn (cfun, NULL, | |
2205 postorder, false); | |
2206 auto_vec<gimple *, 4> to_fixup; | |
2207 to_purge = BITMAP_ALLOC (NULL); | |
2208 for (int i = 0; i < postorder_num; ++i) | |
0 | 2209 { |
2210 gimple_stmt_iterator gsi; | |
111 | 2211 basic_block bb = BASIC_BLOCK_FOR_FN (fun, postorder[i]); |
0 | 2212 |
111 | 2213 /* Propagate into PHIs and record degenerate ones in the lattice. */ |
2214 for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); | |
2215 gsi_next (&si)) | |
2216 { | |
2217 gphi *phi = si.phi (); | |
2218 tree res = gimple_phi_result (phi); | |
2219 if (virtual_operand_p (res)) | |
2220 continue; | |
2221 | |
2222 use_operand_p use_p; | |
2223 ssa_op_iter it; | |
2224 tree first = NULL_TREE; | |
2225 bool all_same = true; | |
2226 FOR_EACH_PHI_ARG (use_p, phi, it, SSA_OP_USE) | |
2227 { | |
2228 tree use = USE_FROM_PTR (use_p); | |
2229 tree tem = fwprop_ssa_val (use); | |
2230 if (! first) | |
2231 first = tem; | |
2232 else if (! operand_equal_p (first, tem, 0)) | |
2233 all_same = false; | |
2234 if (tem != use | |
2235 && may_propagate_copy (use, tem)) | |
2236 propagate_value (use_p, tem); | |
2237 } | |
2238 if (all_same) | |
2239 fwprop_set_lattice_val (res, first); | |
2240 } | |
2241 | |
2242 /* Apply forward propagation to all stmts in the basic-block. | |
2243 Note we update GSI within the loop as necessary. */ | |
0 | 2244 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) |
2245 { | |
111 | 2246 gimple *stmt = gsi_stmt (gsi); |
2247 tree lhs, rhs; | |
2248 enum tree_code code; | |
2249 | |
2250 if (!is_gimple_assign (stmt)) | |
2251 { | |
2252 gsi_next (&gsi); | |
2253 continue; | |
2254 } | |
2255 | |
2256 lhs = gimple_assign_lhs (stmt); | |
2257 rhs = gimple_assign_rhs1 (stmt); | |
2258 code = gimple_assign_rhs_code (stmt); | |
2259 if (TREE_CODE (lhs) != SSA_NAME | |
2260 || has_zero_uses (lhs)) | |
2261 { | |
2262 gsi_next (&gsi); | |
2263 continue; | |
2264 } | |
0 | 2265 |
2266 /* If this statement sets an SSA_NAME to an address, | |
2267 try to propagate the address into the uses of the SSA_NAME. */ | |
111 | 2268 if (code == ADDR_EXPR |
2269 /* Handle pointer conversions on invariant addresses | |
2270 as well, as this is valid gimple. */ | |
2271 || (CONVERT_EXPR_CODE_P (code) | |
2272 && TREE_CODE (rhs) == ADDR_EXPR | |
2273 && POINTER_TYPE_P (TREE_TYPE (lhs)))) | |
0 | 2274 { |
111 | 2275 tree base = get_base_address (TREE_OPERAND (rhs, 0)); |
2276 if ((!base | |
2277 || !DECL_P (base) | |
2278 || decl_address_invariant_p (base)) | |
2279 && !stmt_references_abnormal_ssa_name (stmt) | |
2280 && forward_propagate_addr_expr (lhs, rhs, true)) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
19
diff
changeset
|
2281 { |
111 | 2282 fwprop_invalidate_lattice (gimple_get_lhs (stmt)); |
2283 release_defs (stmt); | |
2284 gsi_remove (&gsi, true); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2285 } |
0 | 2286 else |
2287 gsi_next (&gsi); | |
2288 } | |
111 | 2289 else if (code == POINTER_PLUS_EXPR) |
0 | 2290 { |
111 | 2291 tree off = gimple_assign_rhs2 (stmt); |
2292 if (TREE_CODE (off) == INTEGER_CST | |
2293 && can_propagate_from (stmt) | |
2294 && !simple_iv_increment_p (stmt) | |
2295 /* ??? Better adjust the interface to that function | |
2296 instead of building new trees here. */ | |
2297 && forward_propagate_addr_expr | |
2298 (lhs, | |
2299 build1_loc (gimple_location (stmt), | |
2300 ADDR_EXPR, TREE_TYPE (rhs), | |
2301 fold_build2 (MEM_REF, | |
2302 TREE_TYPE (TREE_TYPE (rhs)), | |
2303 rhs, | |
2304 fold_convert (ptr_type_node, | |
2305 off))), true)) | |
2306 { | |
2307 fwprop_invalidate_lattice (gimple_get_lhs (stmt)); | |
2308 release_defs (stmt); | |
2309 gsi_remove (&gsi, true); | |
2310 } | |
2311 else if (is_gimple_min_invariant (rhs)) | |
2312 { | |
2313 /* Make sure to fold &a[0] + off_1 here. */ | |
2314 fold_stmt_inplace (&gsi); | |
2315 update_stmt (stmt); | |
2316 if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR) | |
2317 gsi_next (&gsi); | |
2318 } | |
2319 else | |
2320 gsi_next (&gsi); | |
0 | 2321 } |
111 | 2322 else if (TREE_CODE (TREE_TYPE (lhs)) == COMPLEX_TYPE |
2323 && gimple_assign_load_p (stmt) | |
2324 && !gimple_has_volatile_ops (stmt) | |
2325 && (TREE_CODE (gimple_assign_rhs1 (stmt)) | |
2326 != TARGET_MEM_REF) | |
2327 && !stmt_can_throw_internal (stmt)) | |
0 | 2328 { |
111 | 2329 /* Rewrite loads used only in real/imagpart extractions to |
2330 component-wise loads. */ | |
2331 use_operand_p use_p; | |
2332 imm_use_iterator iter; | |
2333 bool rewrite = true; | |
2334 FOR_EACH_IMM_USE_FAST (use_p, iter, lhs) | |
2335 { | |
2336 gimple *use_stmt = USE_STMT (use_p); | |
2337 if (is_gimple_debug (use_stmt)) | |
2338 continue; | |
2339 if (!is_gimple_assign (use_stmt) | |
2340 || (gimple_assign_rhs_code (use_stmt) != REALPART_EXPR | |
2341 && gimple_assign_rhs_code (use_stmt) != IMAGPART_EXPR)) | |
2342 { | |
2343 rewrite = false; | |
2344 break; | |
2345 } | |
2346 } | |
2347 if (rewrite) | |
2348 { | |
2349 gimple *use_stmt; | |
2350 FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs) | |
2351 { | |
2352 if (is_gimple_debug (use_stmt)) | |
2353 { | |
2354 if (gimple_debug_bind_p (use_stmt)) | |
2355 { | |
2356 gimple_debug_bind_reset_value (use_stmt); | |
2357 update_stmt (use_stmt); | |
2358 } | |
2359 continue; | |
2360 } | |
2361 | |
2362 tree new_rhs = build1 (gimple_assign_rhs_code (use_stmt), | |
2363 TREE_TYPE (TREE_TYPE (rhs)), | |
2364 unshare_expr (rhs)); | |
2365 gimple *new_stmt | |
2366 = gimple_build_assign (gimple_assign_lhs (use_stmt), | |
2367 new_rhs); | |
2368 | |
2369 location_t loc = gimple_location (use_stmt); | |
2370 gimple_set_location (new_stmt, loc); | |
2371 gimple_stmt_iterator gsi2 = gsi_for_stmt (use_stmt); | |
2372 unlink_stmt_vdef (use_stmt); | |
2373 gsi_remove (&gsi2, true); | |
2374 | |
2375 gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT); | |
2376 } | |
2377 | |
2378 release_defs (stmt); | |
2379 gsi_remove (&gsi, true); | |
2380 } | |
2381 else | |
2382 gsi_next (&gsi); | |
0 | 2383 } |
111 | 2384 else if (code == COMPLEX_EXPR) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2385 { |
111 | 2386 /* Rewrite stores of a single-use complex build expression |
2387 to component-wise stores. */ | |
2388 use_operand_p use_p; | |
2389 gimple *use_stmt; | |
2390 if (single_imm_use (lhs, &use_p, &use_stmt) | |
2391 && gimple_store_p (use_stmt) | |
2392 && !gimple_has_volatile_ops (use_stmt) | |
2393 && is_gimple_assign (use_stmt) | |
2394 && (TREE_CODE (gimple_assign_lhs (use_stmt)) | |
2395 != TARGET_MEM_REF)) | |
2396 { | |
2397 tree use_lhs = gimple_assign_lhs (use_stmt); | |
2398 tree new_lhs = build1 (REALPART_EXPR, | |
2399 TREE_TYPE (TREE_TYPE (use_lhs)), | |
2400 unshare_expr (use_lhs)); | |
2401 gimple *new_stmt = gimple_build_assign (new_lhs, rhs); | |
2402 location_t loc = gimple_location (use_stmt); | |
2403 gimple_set_location (new_stmt, loc); | |
2404 gimple_set_vuse (new_stmt, gimple_vuse (use_stmt)); | |
2405 gimple_set_vdef (new_stmt, make_ssa_name (gimple_vop (cfun))); | |
2406 SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt; | |
2407 gimple_set_vuse (use_stmt, gimple_vdef (new_stmt)); | |
2408 gimple_stmt_iterator gsi2 = gsi_for_stmt (use_stmt); | |
2409 gsi_insert_before (&gsi2, new_stmt, GSI_SAME_STMT); | |
2410 | |
2411 new_lhs = build1 (IMAGPART_EXPR, | |
2412 TREE_TYPE (TREE_TYPE (use_lhs)), | |
2413 unshare_expr (use_lhs)); | |
2414 gimple_assign_set_lhs (use_stmt, new_lhs); | |
2415 gimple_assign_set_rhs1 (use_stmt, gimple_assign_rhs2 (stmt)); | |
2416 update_stmt (use_stmt); | |
2417 | |
2418 release_defs (stmt); | |
2419 gsi_remove (&gsi, true); | |
2420 } | |
2421 else | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2422 gsi_next (&gsi); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2423 } |
0 | 2424 else |
2425 gsi_next (&gsi); | |
2426 } | |
111 | 2427 |
2428 /* Combine stmts with the stmts defining their operands. | |
2429 Note we update GSI within the loop as necessary. */ | |
2430 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) | |
2431 { | |
2432 gimple *stmt = gsi_stmt (gsi); | |
2433 gimple *orig_stmt = stmt; | |
2434 bool changed = false; | |
2435 bool was_noreturn = (is_gimple_call (stmt) | |
2436 && gimple_call_noreturn_p (stmt)); | |
2437 | |
2438 /* Mark stmt as potentially needing revisiting. */ | |
2439 gimple_set_plf (stmt, GF_PLF_1, false); | |
2440 | |
2441 if (fold_stmt (&gsi, fwprop_ssa_val)) | |
2442 { | |
2443 changed = true; | |
2444 stmt = gsi_stmt (gsi); | |
2445 if (maybe_clean_or_replace_eh_stmt (orig_stmt, stmt)) | |
2446 bitmap_set_bit (to_purge, bb->index); | |
2447 if (!was_noreturn | |
2448 && is_gimple_call (stmt) && gimple_call_noreturn_p (stmt)) | |
2449 to_fixup.safe_push (stmt); | |
2450 /* Cleanup the CFG if we simplified a condition to | |
2451 true or false. */ | |
2452 if (gcond *cond = dyn_cast <gcond *> (stmt)) | |
2453 if (gimple_cond_true_p (cond) | |
2454 || gimple_cond_false_p (cond)) | |
2455 cfg_changed = true; | |
2456 update_stmt (stmt); | |
2457 } | |
2458 | |
2459 switch (gimple_code (stmt)) | |
2460 { | |
2461 case GIMPLE_ASSIGN: | |
2462 { | |
2463 tree rhs1 = gimple_assign_rhs1 (stmt); | |
2464 enum tree_code code = gimple_assign_rhs_code (stmt); | |
2465 | |
2466 if (code == COND_EXPR | |
2467 || code == VEC_COND_EXPR) | |
2468 { | |
2469 /* In this case the entire COND_EXPR is in rhs1. */ | |
2470 if (forward_propagate_into_cond (&gsi)) | |
2471 { | |
2472 changed = true; | |
2473 stmt = gsi_stmt (gsi); | |
2474 } | |
2475 } | |
2476 else if (TREE_CODE_CLASS (code) == tcc_comparison) | |
2477 { | |
2478 int did_something; | |
2479 did_something = forward_propagate_into_comparison (&gsi); | |
2480 if (did_something == 2) | |
2481 cfg_changed = true; | |
2482 changed = did_something != 0; | |
2483 } | |
2484 else if ((code == PLUS_EXPR | |
2485 || code == BIT_IOR_EXPR | |
2486 || code == BIT_XOR_EXPR) | |
2487 && simplify_rotate (&gsi)) | |
2488 changed = true; | |
2489 else if (code == VEC_PERM_EXPR) | |
2490 { | |
2491 int did_something = simplify_permutation (&gsi); | |
2492 if (did_something == 2) | |
2493 cfg_changed = true; | |
2494 changed = did_something != 0; | |
2495 } | |
2496 else if (code == BIT_FIELD_REF) | |
2497 changed = simplify_bitfield_ref (&gsi); | |
2498 else if (code == CONSTRUCTOR | |
2499 && TREE_CODE (TREE_TYPE (rhs1)) == VECTOR_TYPE) | |
2500 changed = simplify_vector_constructor (&gsi); | |
2501 break; | |
2502 } | |
2503 | |
2504 case GIMPLE_SWITCH: | |
2505 changed = simplify_gimple_switch (as_a <gswitch *> (stmt)); | |
2506 break; | |
2507 | |
2508 case GIMPLE_COND: | |
2509 { | |
2510 int did_something | |
2511 = forward_propagate_into_gimple_cond (as_a <gcond *> (stmt)); | |
2512 if (did_something == 2) | |
2513 cfg_changed = true; | |
2514 changed = did_something != 0; | |
2515 break; | |
2516 } | |
2517 | |
2518 case GIMPLE_CALL: | |
2519 { | |
2520 tree callee = gimple_call_fndecl (stmt); | |
2521 if (callee != NULL_TREE | |
2522 && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL) | |
2523 changed = simplify_builtin_call (&gsi, callee); | |
2524 break; | |
2525 } | |
2526 | |
2527 default:; | |
2528 } | |
2529 | |
2530 if (changed) | |
2531 { | |
2532 /* If the stmt changed then re-visit it and the statements | |
2533 inserted before it. */ | |
2534 for (; !gsi_end_p (gsi); gsi_prev (&gsi)) | |
2535 if (gimple_plf (gsi_stmt (gsi), GF_PLF_1)) | |
2536 break; | |
2537 if (gsi_end_p (gsi)) | |
2538 gsi = gsi_start_bb (bb); | |
2539 else | |
2540 gsi_next (&gsi); | |
2541 } | |
2542 else | |
2543 { | |
2544 /* Stmt no longer needs to be revisited. */ | |
2545 gimple_set_plf (stmt, GF_PLF_1, true); | |
2546 | |
2547 /* Fill up the lattice. */ | |
2548 if (gimple_assign_single_p (stmt)) | |
2549 { | |
2550 tree lhs = gimple_assign_lhs (stmt); | |
2551 tree rhs = gimple_assign_rhs1 (stmt); | |
2552 if (TREE_CODE (lhs) == SSA_NAME) | |
2553 { | |
2554 tree val = lhs; | |
2555 if (TREE_CODE (rhs) == SSA_NAME) | |
2556 val = fwprop_ssa_val (rhs); | |
2557 else if (is_gimple_min_invariant (rhs)) | |
2558 val = rhs; | |
2559 fwprop_set_lattice_val (lhs, val); | |
2560 } | |
2561 } | |
2562 | |
2563 gsi_next (&gsi); | |
2564 } | |
2565 } | |
0 | 2566 } |
111 | 2567 free (postorder); |
2568 lattice.release (); | |
2569 | |
2570 /* Fixup stmts that became noreturn calls. This may require splitting | |
2571 blocks and thus isn't possible during the walk. Do this | |
2572 in reverse order so we don't inadvertedly remove a stmt we want to | |
2573 fixup by visiting a dominating now noreturn call first. */ | |
2574 while (!to_fixup.is_empty ()) | |
2575 { | |
2576 gimple *stmt = to_fixup.pop (); | |
2577 if (dump_file && dump_flags & TDF_DETAILS) | |
2578 { | |
2579 fprintf (dump_file, "Fixing up noreturn call "); | |
2580 print_gimple_stmt (dump_file, stmt, 0); | |
2581 fprintf (dump_file, "\n"); | |
2582 } | |
2583 cfg_changed |= fixup_noreturn_call (stmt); | |
2584 } | |
2585 | |
2586 cfg_changed |= gimple_purge_all_dead_eh_edges (to_purge); | |
2587 BITMAP_FREE (to_purge); | |
0 | 2588 |
2589 if (cfg_changed) | |
2590 todoflags |= TODO_cleanup_cfg; | |
111 | 2591 |
0 | 2592 return todoflags; |
2593 } | |
2594 | |
111 | 2595 } // anon namespace |
0 | 2596 |
111 | 2597 gimple_opt_pass * |
2598 make_pass_forwprop (gcc::context *ctxt) | |
0 | 2599 { |
111 | 2600 return new pass_forwprop (ctxt); |
2601 } |