[PATCH][7/n] into-SSA TLC
Richard Guenther
rguenther@suse.de
Wed Aug 1 08:47:00 GMT 2012
This cleans up the way we rename all virtual operands throughout the
compiler by simply providing an abstraction for that.
mark_sym_for_renaming is gone then.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
I will apply 6/n and 7/n later today.
Richard.
2012-08-01 Richard Guenther <rguenther@suse.de>
* graphite-clast-to-gimple.c (translate_clast_user): Rename
virtual operands.
* sese.c (graphite_copy_stmts_from_block): Do not rename virtual
operands here.
* tree-call-cdce.c (tree_call_cdce): Use
mark_virtual_operands_for_renaming.
* tree-eh.c (sink_clobbers): Simplify.
* tree-flow.h (mark_sym_for_renaming): Remove.
(mark_virtual_operands_for_renaming): New function.
* tree-if-conv.c (tree_if_conversion): Use
mark_virtual_operands_for_renaming.
* tree-inline.c (update_ssa_across_abnormal_edges): Likewise.
* tree-into-ssa.c (mark_sym_for_renaming): Remove.
(mark_virtual_operands_for_renaming): New function.
* tree-loop-distribution.c (tree_loop_distribution): Use
mark_virtual_operands_for_renaming.
* tree-ssa-dce.c (mark_virtual_operand_for_renaming): Do not
update stmts, use mark_virtual_operands_for_renaming.
* tree-ssa-tail-merge.c (release_last_vdef): Remove.
(replace_block_by): Adjust.
(tail_merge_optimize): Use mark_virtual_operands_for_renaming.
* tree-tailcall.c (tree_optimize_tail_calls_1): Use
mark_virtual_operands_for_renaming.
* tree-vect-slp.c (vect_slp_transform_bb): Likewise.
* tree-vectorizer.c (vectorize_loops): Likewise.
Index: trunk/gcc/graphite-clast-to-gimple.c
===================================================================
*** trunk.orig/gcc/graphite-clast-to-gimple.c 2012-07-16 14:10:04.000000000 +0200
--- trunk/gcc/graphite-clast-to-gimple.c 2012-07-31 15:48:12.614559839 +0200
*************** translate_clast_user (struct clast_user_
*** 1099,1104 ****
--- 1099,1105 ----
new_bb = next_e->src;
mark_bb_with_pbb (pbb, new_bb, bb_pbb_mapping);
+ mark_virtual_operands_for_renaming (cfun);
update_ssa (TODO_update_ssa);
return next_e;
Index: trunk/gcc/sese.c
===================================================================
*** trunk.orig/gcc/sese.c 2012-07-16 14:10:03.000000000 +0200
--- trunk/gcc/sese.c 2012-07-31 15:46:35.698563204 +0200
*************** graphite_copy_stmts_from_block (basic_bl
*** 604,610 ****
operands. */
copy = gimple_copy (stmt);
gsi_insert_after (&gsi_tgt, copy, GSI_NEW_STMT);
- mark_sym_for_renaming (gimple_vop (cfun));
maybe_duplicate_eh_stmt (copy, stmt);
gimple_duplicate_stmt_histograms (cfun, copy, cfun, stmt);
--- 604,609 ----
Index: trunk/gcc/tree-call-cdce.c
===================================================================
*** trunk.orig/gcc/tree-call-cdce.c 2012-07-16 14:10:02.000000000 +0200
--- trunk/gcc/tree-call-cdce.c 2012-07-31 15:51:26.601553133 +0200
*************** tree_call_cdce (void)
*** 894,900 ****
free_dominance_info (CDI_POST_DOMINATORS);
/* As we introduced new control-flow we need to insert PHI-nodes
for the call-clobbers of the remaining call. */
! mark_sym_for_renaming (gimple_vop (cfun));
return (TODO_update_ssa | TODO_cleanup_cfg | TODO_ggc_collect
| TODO_remove_unused_locals);
}
--- 894,900 ----
free_dominance_info (CDI_POST_DOMINATORS);
/* As we introduced new control-flow we need to insert PHI-nodes
for the call-clobbers of the remaining call. */
! mark_virtual_operands_for_renaming (cfun);
return (TODO_update_ssa | TODO_cleanup_cfg | TODO_ggc_collect
| TODO_remove_unused_locals);
}
Index: trunk/gcc/tree-eh.c
===================================================================
*** trunk.orig/gcc/tree-eh.c 2012-07-16 14:10:02.000000000 +0200
--- trunk/gcc/tree-eh.c 2012-07-31 16:53:53.072423418 +0200
*************** sink_clobbers (basic_block bb)
*** 3250,3271 ****
for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
{
gimple stmt = gsi_stmt (gsi);
- tree vdef;
if (is_gimple_debug (stmt))
continue;
if (gimple_code (stmt) == GIMPLE_LABEL)
break;
unlink_stmt_vdef (stmt);
gsi_remove (&gsi, false);
! vdef = gimple_vdef (stmt);
! if (vdef && TREE_CODE (vdef) == SSA_NAME)
! {
! release_ssa_name (vdef);
! vdef = SSA_NAME_VAR (vdef);
! mark_sym_for_renaming (vdef);
! gimple_set_vdef (stmt, vdef);
! gimple_set_vuse (stmt, vdef);
! }
gsi_insert_before (&dgsi, stmt, GSI_SAME_STMT);
}
--- 3250,3267 ----
for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
{
gimple stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
continue;
if (gimple_code (stmt) == GIMPLE_LABEL)
break;
unlink_stmt_vdef (stmt);
gsi_remove (&gsi, false);
! /* Trigger the operand scanner to cause renaming for virtual
! operands for this statement.
! ??? Given the simple structure of this code manually
! figuring out the reaching definition should not be too hard. */
! if (gimple_vuse (stmt))
! gimple_set_vuse (stmt, NULL_TREE);
gsi_insert_before (&dgsi, stmt, GSI_SAME_STMT);
}
Index: trunk/gcc/tree-flow.h
===================================================================
*** trunk.orig/gcc/tree-flow.h 2012-07-31 15:42:33.000000000 +0200
--- trunk/gcc/tree-flow.h 2012-07-31 16:14:18.105505646 +0200
*************** bool need_ssa_update_p (struct function
*** 565,571 ****
bool name_registered_for_update_p (tree);
void release_ssa_name_after_update_ssa (tree);
void compute_global_livein (bitmap, bitmap);
! void mark_sym_for_renaming (tree);
tree get_current_def (tree);
void set_current_def (tree, tree);
--- 565,571 ----
bool name_registered_for_update_p (tree);
void release_ssa_name_after_update_ssa (tree);
void compute_global_livein (bitmap, bitmap);
! void mark_virtual_operands_for_renaming (struct function *);
tree get_current_def (tree);
void set_current_def (tree, tree);
Index: trunk/gcc/tree-if-conv.c
===================================================================
*** trunk.orig/gcc/tree-if-conv.c 2012-07-18 10:45:06.000000000 +0200
--- trunk/gcc/tree-if-conv.c 2012-07-31 15:55:18.961545077 +0200
*************** tree_if_conversion (struct loop *loop)
*** 1747,1753 ****
combine_blocks (loop);
if (flag_tree_loop_if_convert_stores)
! mark_sym_for_renaming (gimple_vop (cfun));
changed = true;
--- 1747,1753 ----
combine_blocks (loop);
if (flag_tree_loop_if_convert_stores)
! mark_virtual_operands_for_renaming (cfun);
changed = true;
Index: trunk/gcc/tree-inline.c
===================================================================
*** trunk.orig/gcc/tree-inline.c 2012-07-31 15:42:33.000000000 +0200
--- trunk/gcc/tree-inline.c 2012-07-31 17:09:42.285390552 +0200
*************** update_ssa_across_abnormal_edges (basic_
*** 1843,1849 ****
if (!is_gimple_reg (PHI_RESULT (phi)))
{
! mark_sym_for_renaming (SSA_NAME_VAR (PHI_RESULT (phi)));
continue;
}
--- 1843,1849 ----
if (!is_gimple_reg (PHI_RESULT (phi)))
{
! mark_virtual_operands_for_renaming (cfun);
continue;
}
Index: trunk/gcc/tree-into-ssa.c
===================================================================
*** trunk.orig/gcc/tree-into-ssa.c 2012-07-31 15:42:33.000000000 +0200
--- trunk/gcc/tree-into-ssa.c 2012-07-31 16:14:11.360505878 +0200
*************** register_new_name_mapping (tree new_tree
*** 2944,2960 ****
}
! /* Register symbol SYM to be renamed by update_ssa. */
void
! mark_sym_for_renaming (tree sym)
{
! if (TREE_CODE (sym) == VAR_DECL
! && VAR_DECL_IS_VIRTUAL_OPERAND (sym))
! {
! cfun->gimple_df->ssa_renaming_needed = 1;
! cfun->gimple_df->rename_vops = 1;
! }
}
--- 2944,2956 ----
}
! /* Mark virtual operands of FN for renaming by update_ssa. */
void
! mark_virtual_operands_for_renaming (struct function *fn)
{
! fn->gimple_df->ssa_renaming_needed = 1;
! fn->gimple_df->rename_vops = 1;
}
Index: trunk/gcc/tree-loop-distribution.c
===================================================================
*** trunk.orig/gcc/tree-loop-distribution.c 2012-07-31 15:08:01.000000000 +0200
--- trunk/gcc/tree-loop-distribution.c 2012-07-31 16:01:54.214531393 +0200
*************** tree_loop_distribution (void)
*** 1515,1521 ****
if (changed)
{
! mark_sym_for_renaming (gimple_vop (cfun));
rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
}
--- 1515,1521 ----
if (changed)
{
! mark_virtual_operands_for_renaming (cfun);
rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
}
Index: trunk/gcc/tree-ssa-dce.c
===================================================================
*** trunk.orig/gcc/tree-ssa-dce.c 2012-07-31 15:40:11.000000000 +0200
--- trunk/gcc/tree-ssa-dce.c 2012-07-31 16:14:02.711506168 +0200
*************** propagate_necessity (struct edge_list *e
*** 995,1025 ****
}
/* Replace all uses of NAME by underlying variable and mark it
! for renaming. */
void
mark_virtual_operand_for_renaming (tree name)
{
bool used = false;
imm_use_iterator iter;
use_operand_p use_p;
gimple stmt;
- tree name_var;
! name_var = SSA_NAME_VAR (name);
FOR_EACH_IMM_USE_STMT (stmt, iter, name)
{
FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
SET_USE (use_p, name_var);
- update_stmt (stmt);
used = true;
}
if (used)
! mark_sym_for_renaming (name_var);
}
! /* Replace all uses of result of PHI by underlying variable and mark it
! for renaming. */
void
mark_virtual_phi_result_for_renaming (gimple phi)
--- 995,1026 ----
}
/* Replace all uses of NAME by underlying variable and mark it
! for renaming. This assumes the defining statement of NAME is
! going to be removed. */
void
mark_virtual_operand_for_renaming (tree name)
{
+ tree name_var = SSA_NAME_VAR (name);
bool used = false;
imm_use_iterator iter;
use_operand_p use_p;
gimple stmt;
! gcc_assert (VAR_DECL_IS_VIRTUAL_OPERAND (name_var));
FOR_EACH_IMM_USE_STMT (stmt, iter, name)
{
FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
SET_USE (use_p, name_var);
used = true;
}
if (used)
! mark_virtual_operands_for_renaming (cfun);
}
! /* Replace all uses of the virtual PHI result by its underlying variable
! and mark it for renaming. This assumes the PHI node is going to be
! removed. */
void
mark_virtual_phi_result_for_renaming (gimple phi)
Index: trunk/gcc/tree-ssa-tail-merge.c
===================================================================
*** trunk.orig/gcc/tree-ssa-tail-merge.c 2012-07-31 15:58:56.000000000 +0200
--- trunk/gcc/tree-ssa-tail-merge.c 2012-07-31 16:04:02.943526946 +0200
*************** same_succ_flush_bbs (bitmap bbs)
*** 812,848 ****
same_succ_flush_bb (BASIC_BLOCK (i));
}
- /* Release the last vdef in BB, either normal or phi result. */
-
- static void
- release_last_vdef (basic_block bb)
- {
- gimple_stmt_iterator i;
-
- for (i = gsi_last_bb (bb); !gsi_end_p (i); gsi_prev_nondebug (&i))
- {
- gimple stmt = gsi_stmt (i);
- if (gimple_vdef (stmt) == NULL_TREE)
- continue;
-
- mark_virtual_operand_for_renaming (gimple_vdef (stmt));
- return;
- }
-
- for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
- {
- gimple phi = gsi_stmt (i);
- tree res = gimple_phi_result (phi);
-
- if (is_gimple_reg (res))
- continue;
-
- mark_virtual_phi_result_for_renaming (phi);
- return;
- }
-
- }
-
/* For deleted_bb_preds, find bbs with same successors. */
static void
--- 812,817 ----
*************** replace_block_by (basic_block bb1, basic
*** 1477,1483 ****
bb1->frequency = 0;
/* Do updates that use bb1, before deleting bb1. */
- release_last_vdef (bb1);
same_succ_flush_bb (bb1);
delete_basic_block (bb1);
--- 1446,1451 ----
*************** tail_merge_optimize (unsigned int todo)
*** 1654,1660 ****
}
todo |= (TODO_verify_ssa | TODO_verify_stmts | TODO_verify_flow);
! mark_sym_for_renaming (gimple_vop (cfun));
}
delete_worklist ();
--- 1622,1628 ----
}
todo |= (TODO_verify_ssa | TODO_verify_stmts | TODO_verify_flow);
! mark_virtual_operands_for_renaming (cfun);
}
delete_worklist ();
Index: trunk/gcc/tree-tailcall.c
===================================================================
*** trunk.orig/gcc/tree-tailcall.c 2012-07-20 13:22:21.000000000 +0200
--- trunk/gcc/tree-tailcall.c 2012-07-31 15:59:39.921536050 +0200
*************** tree_optimize_tail_calls_1 (bool opt_tai
*** 1029,1035 ****
header of the loop created by tail recursion elimination. Do so
by triggering the SSA renamer. */
if (phis_constructed)
! mark_sym_for_renaming (gimple_vop (cfun));
if (changed)
return TODO_cleanup_cfg | TODO_update_ssa_only_virtuals;
--- 1029,1035 ----
header of the loop created by tail recursion elimination. Do so
by triggering the SSA renamer. */
if (phis_constructed)
! mark_virtual_operands_for_renaming (cfun);
if (changed)
return TODO_cleanup_cfg | TODO_update_ssa_only_virtuals;
Index: trunk/gcc/tree-vect-slp.c
===================================================================
*** trunk.orig/gcc/tree-vect-slp.c 2012-07-26 10:46:44.000000000 +0200
--- trunk/gcc/tree-vect-slp.c 2012-07-31 16:02:04.087531060 +0200
*************** vect_slp_transform_bb (basic_block bb)
*** 3149,3155 ****
}
}
! mark_sym_for_renaming (gimple_vop (cfun));
/* The memory tags and pointers in vectorized statements need to
have their SSA forms updated. FIXME, why can't this be delayed
until all the loops have been transformed? */
--- 3149,3155 ----
}
}
! mark_virtual_operands_for_renaming (cfun);
/* The memory tags and pointers in vectorized statements need to
have their SSA forms updated. FIXME, why can't this be delayed
until all the loops have been transformed? */
Index: trunk/gcc/tree-vectorizer.c
===================================================================
*** trunk.orig/gcc/tree-vectorizer.c 2012-07-31 16:00:41.000000000 +0200
--- trunk/gcc/tree-vectorizer.c 2012-07-31 16:00:58.140533343 +0200
*************** vectorize_loops (void)
*** 223,229 ****
/* ----------- Finalize. ----------- */
! mark_sym_for_renaming (gimple_vop (cfun));
for (i = 1; i < vect_loops_num; i++)
{
--- 223,229 ----
/* ----------- Finalize. ----------- */
! mark_virtual_operands_for_renaming (cfun);
for (i = 1; i < vect_loops_num; i++)
{
More information about the Gcc-patches
mailing list