Commit 13714310 by Richard Guenther Committed by Richard Biener

tree-flow.h (struct gimple_df): Remove syms_to_rename member, add…

tree-flow.h (struct gimple_df): Remove syms_to_rename member, add ssa_renaming_needed and rename_vops flags.

2012-08-01  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (struct gimple_df): Remove syms_to_rename member,
	add ssa_renaming_needed and rename_vops flags.
	(SYMS_TO_RENAME): Remove.
	(symbol_marked_for_renaming): Likewise.
	(mark_virtual_ops_for_renaming): Likewise.
	* tree-into-ssa.c (symbols_to_rename_set, symbols_to_rename):
	New globals.
	(mark_for_renaming, marked_for_renaming): New functions.
	(symbol_marked_for_renaming): Remove.
	(dump_currdefs): Adjust.
	(maybe_replace_use): Likewise.
	(maybe_replace_use_in_debug_stmt): Likewise.
	(maybe_register_def): Likewise.
	(rewrite_update_phi_arguments): Likewise.
	(rewrite_update_enter_block): Likewise.
	(fini_ssa_renamer): Clear update SSA status here ...
	(delete_update_ssa): ... not here.  Free rename set.
	(prepare_block_for_update): Compute which decls need renaming.
	(dump_update_ssa): Adjust.
	(mark_sym_for_renaming): Adjust update SSA status for virtuals.
	(need_ssa_update_p): Adjust.
	(insert_updated_phi_nodes_for): Likewise.
	(update_ssa): Likewise.
	* tree-ssa-operands.c (finalize_ssa_defs): Adjust update SSA status
	for virtual and real operands.
	(finalize_ssa_uses): Likewise.
	* tree-ssanames.c (init_ssanames): Adjust.
	* tree-ssa.c (maybe_rewrite_mem_ref_base, maybe_optimize_var,
	execute_update_addresses_taken): Add bitmap to keep track of which
	candidates are suitable for rewriting and later renaming by SSA
	update.
	* matrix-reorg.c (transform_access_sites): Do not rename all defs.
	* tree-dfa.c (make_rename_temp): Do not mark real operands for renaming.
	* cgraphunit.c (assemble_thunk): Likewise.
	* gimplify.c (gimple_regimplify_operands): Likewise.
	(force_gimple_operand_1): Likewise.
	* ipa-prop.c (ipa_modify_formal_parameters): Likewise.
	* tree-inline.c (declare_return_variable): Likewise.
	* tree-parloops.c (separate_decls_in_region_stmt): Do not call
	mark_virtual_ops_for_renaming.
	(create_stores_for_reduction): Likewise.
	(create_loads_and_stores_for_name): Likewise.
	* tree-predcom.c (mark_virtual_ops_for_renaming): Remove.
	(initialize_root_vars_lm): Do not call mark_virtual_ops_for_renaming.
	(execute_load_motion): Likewise.
	(remove_stmt): Likewise.
	(execute_pred_commoning_chain): Likewise.
	* tree-sra.c (create_access_replacement): Do not rename real
	operands.
	(get_unrenamed_access_replacement): Unify with ...
	(get_access_replacement): ... this.
	(get_repl_default_def_ssa_name): Adjust.
	* tree-ssa-loop-im.c (move_computations_stmt): Manually update
	virtual SSA form.
	(rewrite_mem_ref_loc): Do not call mark_virtual_ops_for_renaming.
	* tree-ssa-loop-prefetch.c (emit_mfence_after_loop): Likewise.

From-SVN: r190033
parent d04aacfc
2012-08-01 Richard Guenther <rguenther@suse.de>
* tree-flow.h (struct gimple_df): Remove syms_to_rename member,
add ssa_renaming_needed and rename_vops flags.
(SYMS_TO_RENAME): Remove.
(symbol_marked_for_renaming): Likewise.
(mark_virtual_ops_for_renaming): Likewise.
* tree-into-ssa.c (symbols_to_rename_set, symbols_to_rename):
New globals.
(mark_for_renaming, marked_for_renaming): New functions.
(symbol_marked_for_renaming): Remove.
(dump_currdefs): Adjust.
(maybe_replace_use): Likewise.
(maybe_replace_use_in_debug_stmt): Likewise.
(maybe_register_def): Likewise.
(rewrite_update_phi_arguments): Likewise.
(rewrite_update_enter_block): Likewise.
(fini_ssa_renamer): Clear update SSA status here ...
(delete_update_ssa): ... not here. Free rename set.
(prepare_block_for_update): Compute which decls need renaming.
(dump_update_ssa): Adjust.
(mark_sym_for_renaming): Adjust update SSA status for virtuals.
(need_ssa_update_p): Adjust.
(insert_updated_phi_nodes_for): Likewise.
(update_ssa): Likewise.
* tree-ssa-operands.c (finalize_ssa_defs): Adjust update SSA status
for virtual and real operands.
(finalize_ssa_uses): Likewise.
* tree-ssanames.c (init_ssanames): Adjust.
* tree-ssa.c (maybe_rewrite_mem_ref_base, maybe_optimize_var,
execute_update_addresses_taken): Add bitmap to keep track of which
candidates are suitable for rewriting and later renaming by SSA
update.
* matrix-reorg.c (transform_access_sites): Do not rename all defs.
* tree-dfa.c (make_rename_temp): Do not mark real operands for renaming.
* cgraphunit.c (assemble_thunk): Likewise.
* gimplify.c (gimple_regimplify_operands): Likewise.
(force_gimple_operand_1): Likewise.
* ipa-prop.c (ipa_modify_formal_parameters): Likewise.
* tree-inline.c (declare_return_variable): Likewise.
* tree-parloops.c (separate_decls_in_region_stmt): Do not call
mark_virtual_ops_for_renaming.
(create_stores_for_reduction): Likewise.
(create_loads_and_stores_for_name): Likewise.
* tree-predcom.c (mark_virtual_ops_for_renaming): Remove.
(initialize_root_vars_lm): Do not call mark_virtual_ops_for_renaming.
(execute_load_motion): Likewise.
(remove_stmt): Likewise.
(execute_pred_commoning_chain): Likewise.
* tree-sra.c (create_access_replacement): Do not rename real
operands.
(get_unrenamed_access_replacement): Unify with ...
(get_access_replacement): ... this.
(get_repl_default_def_ssa_name): Adjust.
* tree-ssa-loop-im.c (move_computations_stmt): Manually update
virtual SSA form.
(rewrite_mem_ref_loc): Do not call mark_virtual_ops_for_renaming.
* tree-ssa-loop-prefetch.c (emit_mfence_after_loop): Likewise.
2012-07-31 DJ Delorie <dj@redhat.com> 2012-07-31 DJ Delorie <dj@redhat.com>
* config/s390/s390.c (s390_option_override): Disable DWARF 3/4 * config/s390/s390.c (s390_option_override): Disable DWARF 3/4
......
...@@ -1455,13 +1455,9 @@ assemble_thunk (struct cgraph_node *node) ...@@ -1455,13 +1455,9 @@ assemble_thunk (struct cgraph_node *node)
else else
VEC_quick_push (tree, vargs, a); VEC_quick_push (tree, vargs, a);
add_referenced_var (a); add_referenced_var (a);
if (is_gimple_reg (a))
mark_sym_for_renaming (a);
for (i = 1, arg = DECL_CHAIN (a); i < nargs; i++, arg = DECL_CHAIN (arg)) for (i = 1, arg = DECL_CHAIN (a); i < nargs; i++, arg = DECL_CHAIN (arg))
{ {
add_referenced_var (arg); add_referenced_var (arg);
if (is_gimple_reg (arg))
mark_sym_for_renaming (arg);
VEC_quick_push (tree, vargs, arg); VEC_quick_push (tree, vargs, arg);
} }
call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs); call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs);
......
...@@ -8527,22 +8527,7 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p) ...@@ -8527,22 +8527,7 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
add_referenced_var (t); add_referenced_var (t);
if (!gimple_seq_empty_p (pre)) if (!gimple_seq_empty_p (pre))
{ gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
if (gimple_in_ssa_p (cfun))
{
gimple_stmt_iterator i;
for (i = gsi_start (pre); !gsi_end_p (i); gsi_next (&i))
{
tree lhs = gimple_get_lhs (gsi_stmt (i));
if (lhs
&& TREE_CODE (lhs) != SSA_NAME
&& is_gimple_reg (lhs))
mark_sym_for_renaming (lhs);
}
}
gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
}
if (post_stmt) if (post_stmt)
gsi_insert_after (gsi_p, post_stmt, GSI_NEW_STMT); gsi_insert_after (gsi_p, post_stmt, GSI_NEW_STMT);
...@@ -8593,21 +8578,6 @@ force_gimple_operand_1 (tree expr, gimple_seq *stmts, ...@@ -8593,21 +8578,6 @@ force_gimple_operand_1 (tree expr, gimple_seq *stmts,
for (t = gimplify_ctxp->temps; t ; t = DECL_CHAIN (t)) for (t = gimplify_ctxp->temps; t ; t = DECL_CHAIN (t))
add_referenced_var (t); add_referenced_var (t);
if (!gimple_seq_empty_p (*stmts)
&& gimplify_ctxp->into_ssa)
{
gimple_stmt_iterator i;
for (i = gsi_start (*stmts); !gsi_end_p (i); gsi_next (&i))
{
tree lhs = gimple_get_lhs (gsi_stmt (i));
if (lhs
&& TREE_CODE (lhs) != SSA_NAME
&& is_gimple_reg (lhs))
mark_sym_for_renaming (lhs);
}
}
pop_gimplify_context (NULL); pop_gimplify_context (NULL);
return expr; return expr;
......
...@@ -2356,7 +2356,6 @@ ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments, ...@@ -2356,7 +2356,6 @@ ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments,
layout_decl (new_parm, 0); layout_decl (new_parm, 0);
add_referenced_var (new_parm); add_referenced_var (new_parm);
mark_sym_for_renaming (new_parm);
adj->base = parm; adj->base = parm;
adj->reduction = new_parm; adj->reduction = new_parm;
......
...@@ -1810,13 +1810,9 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED) ...@@ -1810,13 +1810,9 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED)
{ {
if (acc_info->level >= 0 && gimple_bb (acc_info->stmt)) if (acc_info->level >= 0 && gimple_bb (acc_info->stmt))
{ {
ssa_op_iter iter;
tree def;
gimple stmt = acc_info->stmt; gimple stmt = acc_info->stmt;
tree lhs; tree lhs;
FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
mark_sym_for_renaming (SSA_NAME_VAR (def));
gsi = gsi_for_stmt (stmt); gsi = gsi_for_stmt (stmt);
gcc_assert (is_gimple_assign (acc_info->stmt)); gcc_assert (is_gimple_assign (acc_info->stmt));
lhs = gimple_assign_lhs (acc_info->stmt); lhs = gimple_assign_lhs (acc_info->stmt);
......
...@@ -174,8 +174,6 @@ make_rename_temp (tree type, const char *prefix) ...@@ -174,8 +174,6 @@ make_rename_temp (tree type, const char *prefix)
if (gimple_referenced_vars (cfun)) if (gimple_referenced_vars (cfun))
add_referenced_var (t); add_referenced_var (t);
if (gimple_in_ssa_p (cfun))
mark_sym_for_renaming (t);
return t; return t;
} }
......
...@@ -77,9 +77,11 @@ struct GTY(()) gimple_df { ...@@ -77,9 +77,11 @@ struct GTY(()) gimple_df {
for this variable with an empty defining statement. */ for this variable with an empty defining statement. */
htab_t GTY((param_is (union tree_node))) default_defs; htab_t GTY((param_is (union tree_node))) default_defs;
/* Symbols whose SSA form needs to be updated or created for the first /* True if there are any symbols that need to be renamed. */
time. */ unsigned int ssa_renaming_needed : 1;
bitmap syms_to_rename;
/* True if all virtual operands need to be renamed. */
unsigned int rename_vops : 1;
/* True if the code is in ssa form. */ /* True if the code is in ssa form. */
unsigned int in_ssa_p : 1; unsigned int in_ssa_p : 1;
...@@ -100,7 +102,6 @@ struct GTY(()) gimple_df { ...@@ -100,7 +102,6 @@ struct GTY(()) gimple_df {
#define SSANAMES(fun) (fun)->gimple_df->ssa_names #define SSANAMES(fun) (fun)->gimple_df->ssa_names
#define MODIFIED_NORETURN_CALLS(fun) (fun)->gimple_df->modified_noreturn_calls #define MODIFIED_NORETURN_CALLS(fun) (fun)->gimple_df->modified_noreturn_calls
#define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs #define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
#define SYMS_TO_RENAME(fun) (fun)->gimple_df->syms_to_rename
typedef struct typedef struct
{ {
...@@ -565,7 +566,6 @@ bool name_registered_for_update_p (tree); ...@@ -565,7 +566,6 @@ bool name_registered_for_update_p (tree);
void release_ssa_name_after_update_ssa (tree); void release_ssa_name_after_update_ssa (tree);
void compute_global_livein (bitmap, bitmap); void compute_global_livein (bitmap, bitmap);
void mark_sym_for_renaming (tree); void mark_sym_for_renaming (tree);
bool symbol_marked_for_renaming (tree);
tree get_current_def (tree); tree get_current_def (tree);
void set_current_def (tree, tree); void set_current_def (tree, tree);
...@@ -715,7 +715,6 @@ void tree_transform_and_unroll_loop (struct loop *, unsigned, ...@@ -715,7 +715,6 @@ void tree_transform_and_unroll_loop (struct loop *, unsigned,
transform_callback, void *); transform_callback, void *);
bool contains_abnormal_ssa_name_p (tree); bool contains_abnormal_ssa_name_p (tree);
bool stmt_dominates_stmt_p (gimple, gimple); bool stmt_dominates_stmt_p (gimple, gimple);
void mark_virtual_ops_for_renaming (gimple);
/* In tree-ssa-dce.c */ /* In tree-ssa-dce.c */
void mark_virtual_operand_for_renaming (tree); void mark_virtual_operand_for_renaming (tree);
......
...@@ -2969,11 +2969,6 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, ...@@ -2969,11 +2969,6 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest,
TREE_ADDRESSABLE (var) = 1; TREE_ADDRESSABLE (var) = 1;
var = build_fold_addr_expr (var); var = build_fold_addr_expr (var);
} }
else if (gimple_in_ssa_p (cfun)
&& is_gimple_reg (var))
/* ??? Re-org id->retval and its special handling so that we can
record an SSA name directly and not need to invoke the SSA renamer. */
mark_sym_for_renaming (var);
done: done:
/* Register the VAR_DECL as the equivalent for the RESULT_DECL; that /* Register the VAR_DECL as the equivalent for the RESULT_DECL; that
......
...@@ -861,8 +861,6 @@ separate_decls_in_region_stmt (edge entry, edge exit, gimple stmt, ...@@ -861,8 +861,6 @@ separate_decls_in_region_stmt (edge entry, edge exit, gimple stmt,
tree name, copy; tree name, copy;
bool copy_name_p; bool copy_name_p;
mark_virtual_ops_for_renaming (stmt);
FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF) FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF)
{ {
name = DEF_FROM_PTR (def); name = DEF_FROM_PTR (def);
...@@ -1182,7 +1180,6 @@ create_stores_for_reduction (void **slot, void *data) ...@@ -1182,7 +1180,6 @@ create_stores_for_reduction (void **slot, void *data)
gsi = gsi_last_bb (clsn_data->store_bb); gsi = gsi_last_bb (clsn_data->store_bb);
t = build3 (COMPONENT_REF, type, clsn_data->store, red->field, NULL_TREE); t = build3 (COMPONENT_REF, type, clsn_data->store, red->field, NULL_TREE);
stmt = gimple_build_assign (t, red->initial_value); stmt = gimple_build_assign (t, red->initial_value);
mark_virtual_ops_for_renaming (stmt);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
return 1; return 1;
...@@ -1206,7 +1203,6 @@ create_loads_and_stores_for_name (void **slot, void *data) ...@@ -1206,7 +1203,6 @@ create_loads_and_stores_for_name (void **slot, void *data)
gsi = gsi_last_bb (clsn_data->store_bb); gsi = gsi_last_bb (clsn_data->store_bb);
t = build3 (COMPONENT_REF, type, clsn_data->store, elt->field, NULL_TREE); t = build3 (COMPONENT_REF, type, clsn_data->store, elt->field, NULL_TREE);
stmt = gimple_build_assign (t, ssa_name (elt->version)); stmt = gimple_build_assign (t, ssa_name (elt->version));
mark_virtual_ops_for_renaming (stmt);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
gsi = gsi_last_bb (clsn_data->load_bb); gsi = gsi_last_bb (clsn_data->load_bb);
......
...@@ -1440,30 +1440,6 @@ get_init_expr (chain_p chain, unsigned index) ...@@ -1440,30 +1440,6 @@ get_init_expr (chain_p chain, unsigned index)
return VEC_index (tree, chain->inits, index); return VEC_index (tree, chain->inits, index);
} }
/* Marks all virtual operands of statement STMT for renaming. */
void
mark_virtual_ops_for_renaming (gimple stmt)
{
tree var;
if (gimple_code (stmt) == GIMPLE_PHI)
{
var = PHI_RESULT (stmt);
if (is_gimple_reg (var))
return;
if (TREE_CODE (var) == SSA_NAME)
var = SSA_NAME_VAR (var);
mark_sym_for_renaming (var);
return;
}
update_stmt (stmt);
if (gimple_vuse (stmt))
mark_sym_for_renaming (gimple_vop (cfun));
}
/* Returns a new temporary variable used for the I-th variable carrying /* Returns a new temporary variable used for the I-th variable carrying
value of REF. The variable's uid is marked in TMP_VARS. */ value of REF. The variable's uid is marked in TMP_VARS. */
...@@ -1600,7 +1576,6 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written, ...@@ -1600,7 +1576,6 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written,
else else
{ {
gimple init_stmt = gimple_build_assign (var, init); gimple init_stmt = gimple_build_assign (var, init);
mark_virtual_ops_for_renaming (init_stmt);
gsi_insert_on_edge_immediate (entry, init_stmt); gsi_insert_on_edge_immediate (entry, init_stmt);
} }
} }
...@@ -1634,7 +1609,6 @@ execute_load_motion (struct loop *loop, chain_p chain, bitmap tmp_vars) ...@@ -1634,7 +1609,6 @@ execute_load_motion (struct loop *loop, chain_p chain, bitmap tmp_vars)
FOR_EACH_VEC_ELT (dref, chain->refs, i, a) FOR_EACH_VEC_ELT (dref, chain->refs, i, a)
{ {
bool is_read = DR_IS_READ (a->ref); bool is_read = DR_IS_READ (a->ref);
mark_virtual_ops_for_renaming (a->stmt);
if (DR_IS_WRITE (a->ref)) if (DR_IS_WRITE (a->ref))
{ {
...@@ -1730,7 +1704,7 @@ remove_stmt (gimple stmt) ...@@ -1730,7 +1704,7 @@ remove_stmt (gimple stmt)
next = single_nonlooparound_use (name); next = single_nonlooparound_use (name);
reset_debug_uses (stmt); reset_debug_uses (stmt);
mark_virtual_ops_for_renaming (stmt); unlink_stmt_vdef (stmt);
gsi_remove (&bsi, true); gsi_remove (&bsi, true);
release_defs (stmt); release_defs (stmt);
...@@ -1751,7 +1725,7 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain, ...@@ -1751,7 +1725,7 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain,
bitmap tmp_vars) bitmap tmp_vars)
{ {
unsigned i; unsigned i;
dref a, root; dref a;
tree var; tree var;
if (chain->combined) if (chain->combined)
...@@ -1766,13 +1740,9 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain, ...@@ -1766,13 +1740,9 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain,
/* For non-combined chains, set up the variables that hold its value, /* For non-combined chains, set up the variables that hold its value,
and replace the uses of the original references by these and replace the uses of the original references by these
variables. */ variables. */
root = get_chain_root (chain);
mark_virtual_ops_for_renaming (root->stmt);
initialize_root (loop, chain, tmp_vars); initialize_root (loop, chain, tmp_vars);
for (i = 1; VEC_iterate (dref, chain->refs, i, a); i++) for (i = 1; VEC_iterate (dref, chain->refs, i, a); i++)
{ {
mark_virtual_ops_for_renaming (a->stmt);
var = VEC_index (tree, chain->vars, chain->length - a->distance); var = VEC_index (tree, chain->vars, chain->length - a->distance);
replace_ref_with (a->stmt, var, false, false); replace_ref_with (a->stmt, var, false, false);
} }
......
...@@ -1828,15 +1828,12 @@ sort_and_splice_var_accesses (tree var) ...@@ -1828,15 +1828,12 @@ sort_and_splice_var_accesses (tree var)
ACCESS->replacement. */ ACCESS->replacement. */
static tree static tree
create_access_replacement (struct access *access, bool rename) create_access_replacement (struct access *access)
{ {
tree repl; tree repl;
repl = create_tmp_var (access->type, "SR"); repl = create_tmp_var (access->type, "SR");
add_referenced_var (repl); add_referenced_var (repl);
if (!access->grp_partial_lhs
&& rename)
mark_sym_for_renaming (repl);
if (TREE_CODE (access->type) == COMPLEX_TYPE if (TREE_CODE (access->type) == COMPLEX_TYPE
|| TREE_CODE (access->type) == VECTOR_TYPE) || TREE_CODE (access->type) == VECTOR_TYPE)
...@@ -1917,23 +1914,8 @@ create_access_replacement (struct access *access, bool rename) ...@@ -1917,23 +1914,8 @@ create_access_replacement (struct access *access, bool rename)
static inline tree static inline tree
get_access_replacement (struct access *access) get_access_replacement (struct access *access)
{ {
gcc_assert (access->grp_to_be_replaced);
if (!access->replacement_decl)
access->replacement_decl = create_access_replacement (access, true);
return access->replacement_decl;
}
/* Return ACCESS scalar replacement, create it if it does not exist yet but do
not mark it for renaming. */
static inline tree
get_unrenamed_access_replacement (struct access *access)
{
gcc_assert (!access->grp_to_be_replaced);
if (!access->replacement_decl) if (!access->replacement_decl)
access->replacement_decl = create_access_replacement (access, false); access->replacement_decl = create_access_replacement (access);
return access->replacement_decl; return access->replacement_decl;
} }
...@@ -2832,7 +2814,7 @@ get_repl_default_def_ssa_name (struct access *racc) ...@@ -2832,7 +2814,7 @@ get_repl_default_def_ssa_name (struct access *racc)
{ {
tree repl, decl; tree repl, decl;
decl = get_unrenamed_access_replacement (racc); decl = get_access_replacement (racc);
repl = gimple_default_def (cfun, decl); repl = gimple_default_def (cfun, decl);
if (!repl) if (!repl)
......
...@@ -1291,6 +1291,8 @@ move_computations_stmt (struct dom_walk_data *dw_data, ...@@ -1291,6 +1291,8 @@ move_computations_stmt (struct dom_walk_data *dw_data,
for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); ) for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
{ {
edge e;
stmt = gsi_stmt (bsi); stmt = gsi_stmt (bsi);
lim_data = get_lim_data (stmt); lim_data = get_lim_data (stmt);
...@@ -1323,9 +1325,26 @@ move_computations_stmt (struct dom_walk_data *dw_data, ...@@ -1323,9 +1325,26 @@ move_computations_stmt (struct dom_walk_data *dw_data,
cost, level->num); cost, level->num);
} }
mark_virtual_ops_for_renaming (stmt); e = loop_preheader_edge (level);
gcc_assert (!gimple_vdef (stmt));
if (gimple_vuse (stmt))
{
/* The new VUSE is the one from the virtual PHI in the loop
header or the one already present. */
gimple_stmt_iterator gsi2;
for (gsi2 = gsi_start_phis (e->dest);
!gsi_end_p (gsi2); gsi_next (&gsi2))
{
gimple phi = gsi_stmt (gsi2);
if (!is_gimple_reg (gimple_phi_result (phi)))
{
gimple_set_vuse (stmt, PHI_ARG_DEF_FROM_EDGE (phi, e));
break;
}
}
}
gsi_remove (&bsi, false); gsi_remove (&bsi, false);
gsi_insert_on_edge (loop_preheader_edge (level), stmt); gsi_insert_on_edge (e, stmt);
} }
} }
...@@ -1783,7 +1802,6 @@ mem_refs_may_alias_p (tree mem1, tree mem2, struct pointer_map_t **ttae_cache) ...@@ -1783,7 +1802,6 @@ mem_refs_may_alias_p (tree mem1, tree mem2, struct pointer_map_t **ttae_cache)
static void static void
rewrite_mem_ref_loc (mem_ref_loc_p loc, tree tmp_var) rewrite_mem_ref_loc (mem_ref_loc_p loc, tree tmp_var)
{ {
mark_virtual_ops_for_renaming (loc->stmt);
*loc->ref = tmp_var; *loc->ref = tmp_var;
update_stmt (loc->stmt); update_stmt (loc->stmt);
} }
......
...@@ -1204,7 +1204,6 @@ emit_mfence_after_loop (struct loop *loop) ...@@ -1204,7 +1204,6 @@ emit_mfence_after_loop (struct loop *loop)
bsi = gsi_after_labels (exit->dest); bsi = gsi_after_labels (exit->dest);
gsi_insert_before (&bsi, call, GSI_NEW_STMT); gsi_insert_before (&bsi, call, GSI_NEW_STMT);
mark_virtual_ops_for_renaming (call);
} }
VEC_free (edge, heap, exits); VEC_free (edge, heap, exits);
......
...@@ -416,7 +416,10 @@ finalize_ssa_defs (gimple stmt) ...@@ -416,7 +416,10 @@ finalize_ssa_defs (gimple stmt)
/* If we have a non-SSA_NAME VDEF, mark it for renaming. */ /* If we have a non-SSA_NAME VDEF, mark it for renaming. */
if (gimple_vdef (stmt) if (gimple_vdef (stmt)
&& TREE_CODE (gimple_vdef (stmt)) != SSA_NAME) && TREE_CODE (gimple_vdef (stmt)) != SSA_NAME)
mark_sym_for_renaming (gimple_vdef (stmt)); {
cfun->gimple_df->rename_vops = 1;
cfun->gimple_df->ssa_renaming_needed = 1;
}
/* Check for the common case of 1 def that hasn't changed. */ /* Check for the common case of 1 def that hasn't changed. */
if (old_ops && old_ops->next == NULL && num == 1 if (old_ops && old_ops->next == NULL && num == 1
...@@ -432,7 +435,12 @@ finalize_ssa_defs (gimple stmt) ...@@ -432,7 +435,12 @@ finalize_ssa_defs (gimple stmt)
/* If there is anything remaining in the build_defs list, simply emit it. */ /* If there is anything remaining in the build_defs list, simply emit it. */
for ( ; new_i < num; new_i++) for ( ; new_i < num; new_i++)
last = add_def_op ((tree *) VEC_index (tree, build_defs, new_i), last); {
tree *op = (tree *) VEC_index (tree, build_defs, new_i);
if (DECL_P (*op))
cfun->gimple_df->ssa_renaming_needed = 1;
last = add_def_op (op, last);
}
/* Now set the stmt's operands. */ /* Now set the stmt's operands. */
gimple_set_def_ops (stmt, new_list.next); gimple_set_def_ops (stmt, new_list.next);
...@@ -487,14 +495,18 @@ finalize_ssa_uses (gimple stmt) ...@@ -487,14 +495,18 @@ finalize_ssa_uses (gimple stmt)
&& gimple_vuse (stmt) == NULL_TREE) && gimple_vuse (stmt) == NULL_TREE)
{ {
gimple_set_vuse (stmt, gimple_vop (cfun)); gimple_set_vuse (stmt, gimple_vop (cfun));
mark_sym_for_renaming (gimple_vop (cfun)); cfun->gimple_df->rename_vops = 1;
cfun->gimple_df->ssa_renaming_needed = 1;
} }
/* Now create nodes for all the new nodes. */ /* Now create nodes for all the new nodes. */
for (new_i = 0; new_i < VEC_length (tree, build_uses); new_i++) for (new_i = 0; new_i < VEC_length (tree, build_uses); new_i++)
last = add_use_op (stmt, {
(tree *) VEC_index (tree, build_uses, new_i), tree *op = (tree *) VEC_index (tree, build_uses, new_i);
last); if (DECL_P (*op))
cfun->gimple_df->ssa_renaming_needed = 1;
last = add_use_op (stmt, op, last);
}
/* Now set the stmt's operands. */ /* Now set the stmt's operands. */
gimple_set_use_ops (stmt, new_list.next); gimple_set_use_ops (stmt, new_list.next);
......
...@@ -1771,7 +1771,7 @@ struct gimple_opt_pass pass_early_warn_uninitialized = ...@@ -1771,7 +1771,7 @@ struct gimple_opt_pass pass_early_warn_uninitialized =
a MEM_REF to a plain or converted symbol. */ a MEM_REF to a plain or converted symbol. */
static void static void
maybe_rewrite_mem_ref_base (tree *tp) maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming)
{ {
tree sym; tree sym;
...@@ -1782,7 +1782,7 @@ maybe_rewrite_mem_ref_base (tree *tp) ...@@ -1782,7 +1782,7 @@ maybe_rewrite_mem_ref_base (tree *tp)
&& (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0)) && (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0))
&& DECL_P (sym) && DECL_P (sym)
&& !TREE_ADDRESSABLE (sym) && !TREE_ADDRESSABLE (sym)
&& symbol_marked_for_renaming (sym)) && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)))
{ {
if (TREE_CODE (TREE_TYPE (sym)) == VECTOR_TYPE if (TREE_CODE (TREE_TYPE (sym)) == VECTOR_TYPE
&& useless_type_conversion_p (TREE_TYPE (*tp), && useless_type_conversion_p (TREE_TYPE (*tp),
...@@ -1891,21 +1891,15 @@ non_rewritable_lvalue_p (tree lhs) ...@@ -1891,21 +1891,15 @@ non_rewritable_lvalue_p (tree lhs)
mark the variable VAR for conversion into SSA. Return true when updating mark the variable VAR for conversion into SSA. Return true when updating
stmts is required. */ stmts is required. */
static bool static void
maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs) maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs,
bitmap suitable_for_renaming)
{ {
bool update_vops = false;
/* Global Variables, result decls cannot be changed. */ /* Global Variables, result decls cannot be changed. */
if (is_global_var (var) if (is_global_var (var)
|| TREE_CODE (var) == RESULT_DECL || TREE_CODE (var) == RESULT_DECL
|| bitmap_bit_p (addresses_taken, DECL_UID (var))) || bitmap_bit_p (addresses_taken, DECL_UID (var)))
return false; return;
/* If the variable is not in the list of referenced vars then we
do not need to touch it nor can we rename it. */
if (!referenced_var_lookup (cfun, DECL_UID (var)))
return false;
if (TREE_ADDRESSABLE (var) if (TREE_ADDRESSABLE (var)
/* Do not change TREE_ADDRESSABLE if we need to preserve var as /* Do not change TREE_ADDRESSABLE if we need to preserve var as
...@@ -1918,8 +1912,7 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs) ...@@ -1918,8 +1912,7 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
{ {
TREE_ADDRESSABLE (var) = 0; TREE_ADDRESSABLE (var) = 0;
if (is_gimple_reg (var)) if (is_gimple_reg (var))
mark_sym_for_renaming (var); bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
update_vops = true;
if (dump_file) if (dump_file)
{ {
fprintf (dump_file, "No longer having address taken: "); fprintf (dump_file, "No longer having address taken: ");
...@@ -1936,8 +1929,7 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs) ...@@ -1936,8 +1929,7 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
&& (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var))) && (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var)))
{ {
DECL_GIMPLE_REG_P (var) = 1; DECL_GIMPLE_REG_P (var) = 1;
mark_sym_for_renaming (var); bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
update_vops = true;
if (dump_file) if (dump_file)
{ {
fprintf (dump_file, "Now a gimple register: "); fprintf (dump_file, "Now a gimple register: ");
...@@ -1945,8 +1937,6 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs) ...@@ -1945,8 +1937,6 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
fprintf (dump_file, "\n"); fprintf (dump_file, "\n");
} }
} }
return update_vops;
} }
/* Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables. */ /* Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables. */
...@@ -1958,7 +1948,7 @@ execute_update_addresses_taken (void) ...@@ -1958,7 +1948,7 @@ execute_update_addresses_taken (void)
basic_block bb; basic_block bb;
bitmap addresses_taken = BITMAP_ALLOC (NULL); bitmap addresses_taken = BITMAP_ALLOC (NULL);
bitmap not_reg_needs = BITMAP_ALLOC (NULL); bitmap not_reg_needs = BITMAP_ALLOC (NULL);
bool update_vops = false; bitmap suitable_for_renaming = BITMAP_ALLOC (NULL);
tree var; tree var;
unsigned i; unsigned i;
...@@ -2057,14 +2047,16 @@ execute_update_addresses_taken (void) ...@@ -2057,14 +2047,16 @@ execute_update_addresses_taken (void)
unused vars from BLOCK trees, which causes code generation differences unused vars from BLOCK trees, which causes code generation differences
for -g vs. -g0. */ for -g vs. -g0. */
for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var)) for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var))
update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs); maybe_optimize_var (var, addresses_taken, not_reg_needs,
suitable_for_renaming);
FOR_EACH_VEC_ELT (tree, cfun->local_decls, i, var) FOR_EACH_VEC_ELT (tree, cfun->local_decls, i, var)
update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs); maybe_optimize_var (var, addresses_taken, not_reg_needs,
suitable_for_renaming);
/* Operand caches need to be recomputed for operands referencing the updated /* Operand caches need to be recomputed for operands referencing the updated
variables. */ variables and operands need to be rewritten to expose bare symbols. */
if (update_vops) if (!bitmap_empty_p (suitable_for_renaming))
{ {
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
...@@ -2090,14 +2082,14 @@ execute_update_addresses_taken (void) ...@@ -2090,14 +2082,14 @@ execute_update_addresses_taken (void)
&& (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0)) && (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0))
&& DECL_P (sym) && DECL_P (sym)
&& !TREE_ADDRESSABLE (sym) && !TREE_ADDRESSABLE (sym)
&& symbol_marked_for_renaming (sym)) && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)))
lhs = sym; lhs = sym;
else else
lhs = gimple_assign_lhs (stmt); lhs = gimple_assign_lhs (stmt);
/* Rewrite the RHS and make sure the resulting assignment /* Rewrite the RHS and make sure the resulting assignment
is validly typed. */ is validly typed. */
maybe_rewrite_mem_ref_base (rhsp); maybe_rewrite_mem_ref_base (rhsp, suitable_for_renaming);
rhs = gimple_assign_rhs1 (stmt); rhs = gimple_assign_rhs1 (stmt);
if (gimple_assign_lhs (stmt) != lhs if (gimple_assign_lhs (stmt) != lhs
&& !useless_type_conversion_p (TREE_TYPE (lhs), && !useless_type_conversion_p (TREE_TYPE (lhs),
...@@ -2112,7 +2104,7 @@ execute_update_addresses_taken (void) ...@@ -2112,7 +2104,7 @@ execute_update_addresses_taken (void)
TREE_ADDRESSABLE just remove the stmt. */ TREE_ADDRESSABLE just remove the stmt. */
if (DECL_P (lhs) if (DECL_P (lhs)
&& TREE_CLOBBER_P (rhs) && TREE_CLOBBER_P (rhs)
&& symbol_marked_for_renaming (lhs)) && bitmap_bit_p (suitable_for_renaming, DECL_UID (lhs)))
{ {
unlink_stmt_vdef (stmt); unlink_stmt_vdef (stmt);
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
...@@ -2133,7 +2125,7 @@ execute_update_addresses_taken (void) ...@@ -2133,7 +2125,7 @@ execute_update_addresses_taken (void)
for (i = 0; i < gimple_call_num_args (stmt); ++i) for (i = 0; i < gimple_call_num_args (stmt); ++i)
{ {
tree *argp = gimple_call_arg_ptr (stmt, i); tree *argp = gimple_call_arg_ptr (stmt, i);
maybe_rewrite_mem_ref_base (argp); maybe_rewrite_mem_ref_base (argp, suitable_for_renaming);
} }
} }
...@@ -2143,12 +2135,14 @@ execute_update_addresses_taken (void) ...@@ -2143,12 +2135,14 @@ execute_update_addresses_taken (void)
for (i = 0; i < gimple_asm_noutputs (stmt); ++i) for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
{ {
tree link = gimple_asm_output_op (stmt, i); tree link = gimple_asm_output_op (stmt, i);
maybe_rewrite_mem_ref_base (&TREE_VALUE (link)); maybe_rewrite_mem_ref_base (&TREE_VALUE (link),
suitable_for_renaming);
} }
for (i = 0; i < gimple_asm_ninputs (stmt); ++i) for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
{ {
tree link = gimple_asm_input_op (stmt, i); tree link = gimple_asm_input_op (stmt, i);
maybe_rewrite_mem_ref_base (&TREE_VALUE (link)); maybe_rewrite_mem_ref_base (&TREE_VALUE (link),
suitable_for_renaming);
} }
} }
...@@ -2157,9 +2151,10 @@ execute_update_addresses_taken (void) ...@@ -2157,9 +2151,10 @@ execute_update_addresses_taken (void)
{ {
tree *valuep = gimple_debug_bind_get_value_ptr (stmt); tree *valuep = gimple_debug_bind_get_value_ptr (stmt);
tree decl; tree decl;
maybe_rewrite_mem_ref_base (valuep); maybe_rewrite_mem_ref_base (valuep, suitable_for_renaming);
decl = non_rewritable_mem_ref_base (*valuep); decl = non_rewritable_mem_ref_base (*valuep);
if (decl && symbol_marked_for_renaming (decl)) if (decl
&& bitmap_bit_p (suitable_for_renaming, DECL_UID (decl)))
gimple_debug_bind_reset_value (stmt); gimple_debug_bind_reset_value (stmt);
} }
...@@ -2179,6 +2174,7 @@ execute_update_addresses_taken (void) ...@@ -2179,6 +2174,7 @@ execute_update_addresses_taken (void)
BITMAP_FREE (not_reg_needs); BITMAP_FREE (not_reg_needs);
BITMAP_FREE (addresses_taken); BITMAP_FREE (addresses_taken);
BITMAP_FREE (suitable_for_renaming);
timevar_pop (TV_ADDRESS_TAKEN); timevar_pop (TV_ADDRESS_TAKEN);
} }
......
...@@ -85,7 +85,8 @@ init_ssanames (struct function *fn, int size) ...@@ -85,7 +85,8 @@ init_ssanames (struct function *fn, int size)
VEC_quick_push (tree, SSANAMES (fn), NULL_TREE); VEC_quick_push (tree, SSANAMES (fn), NULL_TREE);
FREE_SSANAMES (fn) = NULL; FREE_SSANAMES (fn) = NULL;
SYMS_TO_RENAME (fn) = BITMAP_GGC_ALLOC (); fn->gimple_df->ssa_renaming_needed = 0;
fn->gimple_df->rename_vops = 0;
} }
/* Finalize management of SSA_NAMEs. */ /* Finalize management of SSA_NAMEs. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment