Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-ssa-uncprop.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
51 | 51 |
52 /* This routine finds and records edge equivalences for every edge | 52 /* This routine finds and records edge equivalences for every edge |
53 in the CFG. | 53 in the CFG. |
54 | 54 |
55 When complete, each edge that creates an equivalency will have an | 55 When complete, each edge that creates an equivalency will have an |
56 EDGE_EQUIVALENCY structure hanging off the edge's AUX field. | 56 EDGE_EQUIVALENCY structure hanging off the edge's AUX field. |
57 The caller is responsible for freeing the AUX fields. */ | 57 The caller is responsible for freeing the AUX fields. */ |
58 | 58 |
59 static void | 59 static void |
60 associate_equivalences_with_edges (void) | 60 associate_equivalences_with_edges (void) |
61 { | 61 { |
155 equivalency = XNEW (struct edge_equivalency); | 155 equivalency = XNEW (struct edge_equivalency); |
156 equivalency->lhs = op0; | 156 equivalency->lhs = op0; |
157 equivalency->rhs = op1; | 157 equivalency->rhs = op1; |
158 if (code == EQ_EXPR) | 158 if (code == EQ_EXPR) |
159 true_edge->aux = equivalency; | 159 true_edge->aux = equivalency; |
160 else | 160 else |
161 false_edge->aux = equivalency; | 161 false_edge->aux = equivalency; |
162 | 162 |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
175 | 175 |
176 if (TREE_CODE (cond) == SSA_NAME | 176 if (TREE_CODE (cond) == SSA_NAME |
177 && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond)) | 177 && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond)) |
178 { | 178 { |
179 int i, n_labels = gimple_switch_num_labels (stmt); | 179 int i, n_labels = gimple_switch_num_labels (stmt); |
180 tree *info = XCNEWVEC (tree, n_basic_blocks); | 180 tree *info = XCNEWVEC (tree, last_basic_block); |
181 | 181 |
182 /* Walk over the case label vector. Record blocks | 182 /* Walk over the case label vector. Record blocks |
183 which are reached by a single case label which represents | 183 which are reached by a single case label which represents |
184 a single value. */ | 184 a single value. */ |
185 for (i = 0; i < n_labels; i++) | 185 for (i = 0; i < n_labels; i++) |
287 | 287 |
288 /* List of SSA_NAMEs which have the same value/key. */ | 288 /* List of SSA_NAMEs which have the same value/key. */ |
289 VEC(tree,heap) *equivalences; | 289 VEC(tree,heap) *equivalences; |
290 }; | 290 }; |
291 | 291 |
292 static void uncprop_initialize_block (struct dom_walk_data *, basic_block); | 292 static void uncprop_enter_block (struct dom_walk_data *, basic_block); |
293 static void uncprop_finalize_block (struct dom_walk_data *, basic_block); | 293 static void uncprop_leave_block (struct dom_walk_data *, basic_block); |
294 static void uncprop_into_successor_phis (struct dom_walk_data *, basic_block); | 294 static void uncprop_into_successor_phis (basic_block); |
295 | 295 |
296 /* Hashing and equality routines for the hash table. */ | 296 /* Hashing and equality routines for the hash table. */ |
297 | 297 |
298 static hashval_t | 298 static hashval_t |
299 equiv_hash (const void *p) | 299 equiv_hash (const void *p) |
356 *slot = (void *) equiv_hash_elt; | 356 *slot = (void *) equiv_hash_elt; |
357 else | 357 else |
358 free (equiv_hash_elt); | 358 free (equiv_hash_elt); |
359 | 359 |
360 equiv_hash_elt = (struct equiv_hash_elt *) *slot; | 360 equiv_hash_elt = (struct equiv_hash_elt *) *slot; |
361 | 361 |
362 VEC_safe_push (tree, heap, equiv_hash_elt->equivalences, equivalence); | 362 VEC_safe_push (tree, heap, equiv_hash_elt->equivalences, equivalence); |
363 } | 363 } |
364 | 364 |
365 /* Main driver for un-cprop. */ | 365 /* Main driver for un-cprop. */ |
366 | 366 |
379 /* We're going to do a dominator walk, so ensure that we have | 379 /* We're going to do a dominator walk, so ensure that we have |
380 dominance information. */ | 380 dominance information. */ |
381 calculate_dominance_info (CDI_DOMINATORS); | 381 calculate_dominance_info (CDI_DOMINATORS); |
382 | 382 |
383 /* Setup callbacks for the generic dominator tree walker. */ | 383 /* Setup callbacks for the generic dominator tree walker. */ |
384 walk_data.walk_stmts_backward = false; | |
385 walk_data.dom_direction = CDI_DOMINATORS; | 384 walk_data.dom_direction = CDI_DOMINATORS; |
386 walk_data.initialize_block_local_data = NULL; | 385 walk_data.initialize_block_local_data = NULL; |
387 walk_data.before_dom_children_before_stmts = uncprop_initialize_block; | 386 walk_data.before_dom_children = uncprop_enter_block; |
388 walk_data.before_dom_children_walk_stmts = NULL; | 387 walk_data.after_dom_children = uncprop_leave_block; |
389 walk_data.before_dom_children_after_stmts = uncprop_into_successor_phis; | |
390 walk_data.after_dom_children_before_stmts = NULL; | |
391 walk_data.after_dom_children_walk_stmts = NULL; | |
392 walk_data.after_dom_children_after_stmts = uncprop_finalize_block; | |
393 walk_data.global_data = NULL; | 388 walk_data.global_data = NULL; |
394 walk_data.block_local_data_size = 0; | 389 walk_data.block_local_data_size = 0; |
395 walk_data.interesting_blocks = NULL; | |
396 | 390 |
397 /* Now initialize the dominator walker. */ | 391 /* Now initialize the dominator walker. */ |
398 init_walk_dominator_tree (&walk_data); | 392 init_walk_dominator_tree (&walk_data); |
399 | 393 |
400 /* Recursively walk the dominator tree undoing unprofitable | 394 /* Recursively walk the dominator tree undoing unprofitable |
430 /* We have finished processing the dominator children of BB, perform | 424 /* We have finished processing the dominator children of BB, perform |
431 any finalization actions in preparation for leaving this node in | 425 any finalization actions in preparation for leaving this node in |
432 the dominator tree. */ | 426 the dominator tree. */ |
433 | 427 |
434 static void | 428 static void |
435 uncprop_finalize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, | 429 uncprop_leave_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, |
436 basic_block bb ATTRIBUTE_UNUSED) | 430 basic_block bb ATTRIBUTE_UNUSED) |
437 { | 431 { |
438 /* Pop the topmost value off the equiv stack. */ | 432 /* Pop the topmost value off the equiv stack. */ |
439 tree value = VEC_pop (tree, equiv_stack); | 433 tree value = VEC_pop (tree, equiv_stack); |
440 | 434 |
441 /* If that value was non-null, then pop the topmost equivalency off | 435 /* If that value was non-null, then pop the topmost equivalency off |
445 } | 439 } |
446 | 440 |
447 /* Unpropagate values from PHI nodes in successor blocks of BB. */ | 441 /* Unpropagate values from PHI nodes in successor blocks of BB. */ |
448 | 442 |
449 static void | 443 static void |
450 uncprop_into_successor_phis (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, | 444 uncprop_into_successor_phis (basic_block bb) |
451 basic_block bb) | |
452 { | 445 { |
453 edge e; | 446 edge e; |
454 edge_iterator ei; | 447 edge_iterator ei; |
455 | 448 |
456 /* For each successor edge, first temporarily record any equivalence | 449 /* For each successor edge, first temporarily record any equivalence |
474 } | 467 } |
475 | 468 |
476 /* Walk over the PHI nodes, unpropagating values. */ | 469 /* Walk over the PHI nodes, unpropagating values. */ |
477 for (gsi = gsi_start (phis) ; !gsi_end_p (gsi); gsi_next (&gsi)) | 470 for (gsi = gsi_start (phis) ; !gsi_end_p (gsi); gsi_next (&gsi)) |
478 { | 471 { |
479 /* Sigh. We'll have more efficient access to this one day. */ | |
480 gimple phi = gsi_stmt (gsi); | 472 gimple phi = gsi_stmt (gsi); |
481 tree arg = PHI_ARG_DEF (phi, e->dest_idx); | 473 tree arg = PHI_ARG_DEF (phi, e->dest_idx); |
482 struct equiv_hash_elt equiv_hash_elt; | 474 struct equiv_hash_elt equiv_hash_elt; |
483 void **slot; | 475 void **slot; |
484 | 476 |
554 | 546 |
555 return retval; | 547 return retval; |
556 } | 548 } |
557 | 549 |
558 static void | 550 static void |
559 uncprop_initialize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, | 551 uncprop_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, |
560 basic_block bb) | 552 basic_block bb) |
561 { | 553 { |
562 basic_block parent; | 554 basic_block parent; |
563 edge e; | 555 edge e; |
564 bool recorded = false; | 556 bool recorded = false; |
565 | 557 |
581 } | 573 } |
582 } | 574 } |
583 | 575 |
584 if (!recorded) | 576 if (!recorded) |
585 VEC_safe_push (tree, heap, equiv_stack, NULL_TREE); | 577 VEC_safe_push (tree, heap, equiv_stack, NULL_TREE); |
578 | |
579 uncprop_into_successor_phis (bb); | |
586 } | 580 } |
587 | 581 |
588 static bool | 582 static bool |
589 gate_uncprop (void) | 583 gate_uncprop (void) |
590 { | 584 { |
591 return flag_tree_dom != 0; | 585 return flag_tree_dom != 0; |
592 } | 586 } |
593 | 587 |
594 struct gimple_opt_pass pass_uncprop = | 588 struct gimple_opt_pass pass_uncprop = |
595 { | 589 { |
596 { | 590 { |
597 GIMPLE_PASS, | 591 GIMPLE_PASS, |
598 "uncprop", /* name */ | 592 "uncprop", /* name */ |
599 gate_uncprop, /* gate */ | 593 gate_uncprop, /* gate */ |