summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-01 11:48:04 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-01 11:48:04 +0000
commite70e8b13a21cfe8866fc9c3357c6f42962246aaa (patch)
tree103b768984c681c0e66bf0bd7b06f89dbdc9cce1
parenta575acb283ccbe98f47a7f5b58b15bdcb6df313f (diff)
downloadgcc-e70e8b13a21cfe8866fc9c3357c6f42962246aaa.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190033 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog59
-rw-r--r--gcc/cgraphunit.c4
-rw-r--r--gcc/gimplify.c32
-rw-r--r--gcc/ipa-prop.c1
-rw-r--r--gcc/matrix-reorg.c4
-rw-r--r--gcc/tree-dfa.c2
-rw-r--r--gcc/tree-flow.h11
-rw-r--r--gcc/tree-inline.c5
-rw-r--r--gcc/tree-into-ssa.c159
-rw-r--r--gcc/tree-parloops.c4
-rw-r--r--gcc/tree-predcom.c34
-rw-r--r--gcc/tree-sra.c24
-rw-r--r--gcc/tree-ssa-loop-im.c24
-rw-r--r--gcc/tree-ssa-loop-prefetch.c1
-rw-r--r--gcc/tree-ssa-operands.c24
-rw-r--r--gcc/tree-ssa.c58
-rw-r--r--gcc/tree-ssanames.c3
17 files changed, 243 insertions, 206 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 322ab5b3c81..1d7faf0a0b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,62 @@
+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>
* config/s390/s390.c (s390_option_override): Disable DWARF 3/4
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a5588bb2775..1e17fdfff62 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1455,13 +1455,9 @@ assemble_thunk (struct cgraph_node *node)
else
VEC_quick_push (tree, vargs, 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))
{
add_referenced_var (arg);
- if (is_gimple_reg (arg))
- mark_sym_for_renaming (arg);
VEC_quick_push (tree, vargs, arg);
}
call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f48b81f4b53..0c6ea1ce2be 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8527,22 +8527,7 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
add_referenced_var (t);
if (!gimple_seq_empty_p (pre))
- {
- 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);
- }
+ gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
if (post_stmt)
gsi_insert_after (gsi_p, post_stmt, GSI_NEW_STMT);
@@ -8593,21 +8578,6 @@ force_gimple_operand_1 (tree expr, gimple_seq *stmts,
for (t = gimplify_ctxp->temps; t ; t = DECL_CHAIN (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);
return expr;
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 4181c63695a..214b2de3521 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -2356,7 +2356,6 @@ ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments,
layout_decl (new_parm, 0);
add_referenced_var (new_parm);
- mark_sym_for_renaming (new_parm);
adj->base = parm;
adj->reduction = new_parm;
diff --git a/gcc/matrix-reorg.c b/gcc/matrix-reorg.c
index 048cc7fdd5f..966ab0c254d 100644
--- a/gcc/matrix-reorg.c
+++ b/gcc/matrix-reorg.c
@@ -1810,13 +1810,9 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED)
{
if (acc_info->level >= 0 && gimple_bb (acc_info->stmt))
{
- ssa_op_iter iter;
- tree def;
gimple stmt = acc_info->stmt;
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);
gcc_assert (is_gimple_assign (acc_info->stmt));
lhs = gimple_assign_lhs (acc_info->stmt);
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index f8ebfd26972..8989a5b869e 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -174,8 +174,6 @@ make_rename_temp (tree type, const char *prefix)
if (gimple_referenced_vars (cfun))
add_referenced_var (t);
- if (gimple_in_ssa_p (cfun))
- mark_sym_for_renaming (t);
return t;
}
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 301bd7e9c83..553f22e321e 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -77,9 +77,11 @@ struct GTY(()) gimple_df {
for this variable with an empty defining statement. */
htab_t GTY((param_is (union tree_node))) default_defs;
- /* Symbols whose SSA form needs to be updated or created for the first
- time. */
- bitmap syms_to_rename;
+ /* True if there are any symbols that need to be renamed. */
+ unsigned int ssa_renaming_needed : 1;
+
+ /* True if all virtual operands need to be renamed. */
+ unsigned int rename_vops : 1;
/* True if the code is in ssa form. */
unsigned int in_ssa_p : 1;
@@ -100,7 +102,6 @@ struct GTY(()) gimple_df {
#define SSANAMES(fun) (fun)->gimple_df->ssa_names
#define MODIFIED_NORETURN_CALLS(fun) (fun)->gimple_df->modified_noreturn_calls
#define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
-#define SYMS_TO_RENAME(fun) (fun)->gimple_df->syms_to_rename
typedef struct
{
@@ -565,7 +566,6 @@ 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);
-bool symbol_marked_for_renaming (tree);
tree get_current_def (tree);
void set_current_def (tree, tree);
@@ -715,7 +715,6 @@ void tree_transform_and_unroll_loop (struct loop *, unsigned,
transform_callback, void *);
bool contains_abnormal_ssa_name_p (tree);
bool stmt_dominates_stmt_p (gimple, gimple);
-void mark_virtual_ops_for_renaming (gimple);
/* In tree-ssa-dce.c */
void mark_virtual_operand_for_renaming (tree);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 78b4d94573d..4088e755a8a 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2969,11 +2969,6 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest,
TREE_ADDRESSABLE (var) = 1;
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:
/* Register the VAR_DECL as the equivalent for the RESULT_DECL; that
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index da747bfc442..0971d01f295 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -227,6 +227,33 @@ extern void debug_defs_stack (int);
extern void dump_currdefs (FILE *);
extern void debug_currdefs (void);
+
+/* The set of symbols we ought to re-write into SSA form in update_ssa. */
+static bitmap symbols_to_rename_set;
+static VEC(tree,heap) *symbols_to_rename;
+
+/* Mark SYM for renaming. */
+
+static void
+mark_for_renaming (tree sym)
+{
+ if (!symbols_to_rename_set)
+ symbols_to_rename_set = BITMAP_ALLOC (NULL);
+ if (bitmap_set_bit (symbols_to_rename_set, DECL_UID (sym)))
+ VEC_safe_push (tree, heap, symbols_to_rename, sym);
+}
+
+/* Return true if SYM is marked for renaming. */
+
+static bool
+marked_for_renaming (tree sym)
+{
+ if (!symbols_to_rename_set)
+ return false;
+ return bitmap_bit_p (symbols_to_rename_set, DECL_UID (sym));
+}
+
+
/* Return true if STMT needs to be rewritten. When renaming a subset
of the variables, not all statements will be processed. This is
decided in mark_def_sites. */
@@ -574,15 +601,6 @@ set_livein_block (tree var, basic_block bb)
}
-/* Return true if symbol SYM is marked for renaming. */
-
-bool
-symbol_marked_for_renaming (tree sym)
-{
- return bitmap_bit_p (SYMS_TO_RENAME (cfun), DECL_UID (sym));
-}
-
-
/* Return true if NAME is in OLD_SSA_NAMES. */
static inline bool
@@ -1636,23 +1654,24 @@ debug_defs_stack (int n)
void
dump_currdefs (FILE *file)
{
- referenced_var_iterator i;
+ unsigned i;
tree var;
+ if (VEC_empty (tree, symbols_to_rename))
+ return;
+
fprintf (file, "\n\nCurrent reaching definitions\n\n");
- FOR_EACH_REFERENCED_VAR (cfun, var, i)
- if (SYMS_TO_RENAME (cfun) == NULL
- || bitmap_bit_p (SYMS_TO_RENAME (cfun), DECL_UID (var)))
- {
- fprintf (file, "CURRDEF (");
- print_generic_expr (file, var, 0);
- fprintf (file, ") = ");
- if (get_current_def (var))
- print_generic_expr (file, get_current_def (var), 0);
- else
- fprintf (file, "<NIL>");
- fprintf (file, "\n");
- }
+ FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, var)
+ {
+ fprintf (file, "CURRDEF (");
+ print_generic_expr (file, var, 0);
+ fprintf (file, ") = ");
+ if (get_current_def (var))
+ print_generic_expr (file, get_current_def (var), 0);
+ else
+ fprintf (file, "<NIL>");
+ fprintf (file, "\n");
+ }
}
@@ -1830,7 +1849,7 @@ maybe_replace_use (use_operand_p use_p)
tree use = USE_FROM_PTR (use_p);
tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
- if (symbol_marked_for_renaming (sym))
+ if (marked_for_renaming (sym))
rdef = get_reaching_def (sym);
else if (is_old_name (use))
rdef = get_reaching_def (use);
@@ -1850,7 +1869,7 @@ maybe_replace_use_in_debug_stmt (use_operand_p use_p)
tree use = USE_FROM_PTR (use_p);
tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
- if (symbol_marked_for_renaming (sym))
+ if (marked_for_renaming (sym))
rdef = get_current_def (sym);
else if (is_old_name (use))
{
@@ -1886,7 +1905,7 @@ maybe_register_def (def_operand_p def_p, gimple stmt,
/* If DEF is a naked symbol that needs renaming, create a new
name for it. */
- if (symbol_marked_for_renaming (sym))
+ if (marked_for_renaming (sym))
{
if (DECL_P (def))
{
@@ -2077,7 +2096,7 @@ rewrite_update_phi_arguments (basic_block bb)
{
tree sym = DECL_P (arg) ? arg : SSA_NAME_VAR (arg);
- if (symbol_marked_for_renaming (sym))
+ if (marked_for_renaming (sym))
reaching_def = get_reaching_def (sym);
else if (is_old_name (arg))
reaching_def = get_reaching_def (arg);
@@ -2154,7 +2173,7 @@ rewrite_update_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
lhs = gimple_phi_result (phi);
lhs_sym = SSA_NAME_VAR (lhs);
- if (symbol_marked_for_renaming (lhs_sym))
+ if (marked_for_renaming (lhs_sym))
register_new_update_single (lhs, lhs_sym);
else
{
@@ -2369,6 +2388,8 @@ fini_ssa_renamer (void)
bitmap_obstack_release (&update_ssa_obstack);
+ cfun->gimple_df->ssa_renaming_needed = 0;
+ cfun->gimple_df->rename_vops = 0;
cfun->gimple_df->in_ssa_p = true;
}
@@ -2526,7 +2547,7 @@ mark_use_interesting (tree var, gimple stmt, basic_block bb, bool insert_phi_p)
/* Do a dominator walk starting at BB processing statements that
- reference symbols in SYMS_TO_RENAME. This is very similar to
+ reference symbols in SSA operands. This is very similar to
mark_def_sites, but the scan handles statements whose operands may
already be SSA names.
@@ -2559,9 +2580,13 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p)
lhs_sym = DECL_P (lhs) ? lhs : SSA_NAME_VAR (lhs);
- if (!symbol_marked_for_renaming (lhs_sym))
+ if (TREE_CODE (lhs) == SSA_NAME
+ && (TREE_CODE (lhs_sym) != VAR_DECL
+ || !VAR_DECL_IS_VIRTUAL_OPERAND (lhs_sym)
+ || !cfun->gimple_df->rename_vops))
continue;
+ mark_for_renaming (lhs_sym);
mark_def_interesting (lhs_sym, phi, bb, insert_phi_p);
/* Mark the uses in phi nodes as interesting. It would be more correct
@@ -2585,20 +2610,40 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p)
stmt = gsi_stmt (si);
- FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_ALL_USES)
+ if (cfun->gimple_df->rename_vops
+ && gimple_vuse (stmt))
{
- tree use = USE_FROM_PTR (use_p);
+ tree use = gimple_vuse (stmt);
tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);
- if (symbol_marked_for_renaming (sym))
- mark_use_interesting (sym, stmt, bb, insert_phi_p);
+ mark_for_renaming (sym);
+ mark_use_interesting (sym, stmt, bb, insert_phi_p);
}
- FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, i, SSA_OP_ALL_DEFS)
+ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, i, SSA_OP_USE)
{
- tree def = DEF_FROM_PTR (def_p);
+ tree use = USE_FROM_PTR (use_p);
+ if (!DECL_P (use))
+ continue;
+ mark_for_renaming (use);
+ mark_use_interesting (use, stmt, bb, insert_phi_p);
+ }
+
+ if (cfun->gimple_df->rename_vops
+ && gimple_vdef (stmt))
+ {
+ tree def = gimple_vdef (stmt);
tree sym = DECL_P (def) ? def : SSA_NAME_VAR (def);
- if (symbol_marked_for_renaming (sym))
- mark_def_interesting (sym, stmt, bb, insert_phi_p);
+ mark_for_renaming (sym);
+ mark_def_interesting (sym, stmt, bb, insert_phi_p);
+ }
+
+ FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, i, SSA_OP_DEF)
+ {
+ tree def = DEF_FROM_PTR (def_p);
+ if (!DECL_P (def))
+ continue;
+ mark_for_renaming (def);
+ mark_def_interesting (def, stmt, bb, insert_phi_p);
}
}
@@ -2757,10 +2802,10 @@ dump_update_ssa (FILE *file)
dump_names_replaced_by (file, ssa_name (i));
}
- if (!bitmap_empty_p (SYMS_TO_RENAME (cfun)))
+ if (symbols_to_rename_set && !bitmap_empty_p (symbols_to_rename_set))
{
fprintf (file, "\nSymbols to be put in SSA form\n");
- dump_decl_set (file, SYMS_TO_RENAME (cfun));
+ dump_decl_set (file, symbols_to_rename_set);
fprintf (file, "\n");
}
@@ -2821,7 +2866,9 @@ delete_update_ssa (void)
sbitmap_free (new_ssa_names);
new_ssa_names = NULL;
- bitmap_clear (SYMS_TO_RENAME (update_ssa_initialized_fn));
+ BITMAP_FREE (symbols_to_rename_set);
+ symbols_to_rename_set = NULL;
+ VEC_free (tree, heap, symbols_to_rename);
if (names_to_release)
{
@@ -2902,8 +2949,12 @@ register_new_name_mapping (tree new_tree, tree old)
void
mark_sym_for_renaming (tree sym)
{
- if (cfun->gimple_df->in_ssa_p)
- bitmap_set_bit (SYMS_TO_RENAME (cfun), DECL_UID (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;
+ }
}
@@ -2915,8 +2966,7 @@ need_ssa_update_p (struct function *fn)
{
gcc_assert (fn != NULL);
return (update_ssa_initialized_fn == fn
- || (fn->gimple_df
- && !bitmap_empty_p (SYMS_TO_RENAME (fn))));
+ || (fn->gimple_df && fn->gimple_df->ssa_renaming_needed));
}
/* Return true if name N has been registered in the replacement table. */
@@ -2983,7 +3033,7 @@ insert_updated_phi_nodes_for (tree var, bitmap_head *dfs, bitmap blocks,
if (TREE_CODE (var) == SSA_NAME)
gcc_checking_assert (is_old_name (var));
else
- gcc_checking_assert (symbol_marked_for_renaming (var));
+ gcc_checking_assert (marked_for_renaming (var));
/* Get all the definition sites for VAR. */
db = find_def_blocks_for (var);
@@ -3127,6 +3177,7 @@ update_ssa (unsigned update_flags)
unsigned i = 0;
bool insert_phi_p;
sbitmap_iterator sbi;
+ tree sym;
if (!need_ssa_update_p (cfun))
return;
@@ -3176,12 +3227,12 @@ update_ssa (unsigned update_flags)
removal, and there are no symbols to rename, then there's
nothing else to do. */
if (sbitmap_first_set_bit (new_ssa_names) < 0
- && bitmap_empty_p (SYMS_TO_RENAME (cfun)))
+ && !cfun->gimple_df->ssa_renaming_needed)
goto done;
}
/* Next, determine the block at which to start the renaming process. */
- if (!bitmap_empty_p (SYMS_TO_RENAME (cfun)))
+ if (cfun->gimple_df->ssa_renaming_needed)
{
/* If we rename bare symbols initialize the mapping to
auxiliar info we need to keep track of. */
@@ -3195,7 +3246,7 @@ update_ssa (unsigned update_flags)
start_bb = ENTRY_BLOCK_PTR;
/* Traverse the CFG looking for existing definitions and uses of
- symbols in SYMS_TO_RENAME. Mark interesting blocks and
+ symbols in SSA operands. Mark interesting blocks and
statements and set local live-in information for the PHI
placement heuristics. */
prepare_block_for_update (start_bb, insert_phi_p);
@@ -3210,7 +3261,7 @@ update_ssa (unsigned update_flags)
/* If requested, insert PHI nodes at the iterated dominance frontier
of every block, creating new definitions for names in OLD_SSA_NAMES
- and for symbols in SYMS_TO_RENAME. */
+ and for symbols found. */
if (insert_phi_p)
{
bitmap_head *dfs;
@@ -3239,8 +3290,8 @@ update_ssa (unsigned update_flags)
sbitmap_free (tmp);
}
- EXECUTE_IF_SET_IN_BITMAP (SYMS_TO_RENAME (cfun), 0, i, bi)
- insert_updated_phi_nodes_for (referenced_var (i), dfs, blocks_to_update,
+ FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, sym)
+ insert_updated_phi_nodes_for (sym, dfs, blocks_to_update,
update_flags);
FOR_EACH_BB (bb)
@@ -3260,8 +3311,8 @@ update_ssa (unsigned update_flags)
EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
set_current_def (ssa_name (i), NULL_TREE);
- EXECUTE_IF_SET_IN_BITMAP (SYMS_TO_RENAME (cfun), 0, i, bi)
- set_current_def (referenced_var (i), NULL_TREE);
+ FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, sym)
+ set_current_def (sym, NULL_TREE);
/* Now start the renaming process at START_BB. */
interesting_blocks = sbitmap_alloc (last_basic_block);
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 86036b42639..92faa996a8c 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -861,8 +861,6 @@ separate_decls_in_region_stmt (edge entry, edge exit, gimple stmt,
tree name, copy;
bool copy_name_p;
- mark_virtual_ops_for_renaming (stmt);
-
FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF)
{
name = DEF_FROM_PTR (def);
@@ -1182,7 +1180,6 @@ create_stores_for_reduction (void **slot, void *data)
gsi = gsi_last_bb (clsn_data->store_bb);
t = build3 (COMPONENT_REF, type, clsn_data->store, red->field, NULL_TREE);
stmt = gimple_build_assign (t, red->initial_value);
- mark_virtual_ops_for_renaming (stmt);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
return 1;
@@ -1206,7 +1203,6 @@ create_loads_and_stores_for_name (void **slot, void *data)
gsi = gsi_last_bb (clsn_data->store_bb);
t = build3 (COMPONENT_REF, type, clsn_data->store, elt->field, NULL_TREE);
stmt = gimple_build_assign (t, ssa_name (elt->version));
- mark_virtual_ops_for_renaming (stmt);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
gsi = gsi_last_bb (clsn_data->load_bb);
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 29080b7e06f..cb7d0883222 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1440,30 +1440,6 @@ get_init_expr (chain_p chain, unsigned 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
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,
else
{
gimple init_stmt = gimple_build_assign (var, init);
- mark_virtual_ops_for_renaming (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)
FOR_EACH_VEC_ELT (dref, chain->refs, i, a)
{
bool is_read = DR_IS_READ (a->ref);
- mark_virtual_ops_for_renaming (a->stmt);
if (DR_IS_WRITE (a->ref))
{
@@ -1730,7 +1704,7 @@ remove_stmt (gimple stmt)
next = single_nonlooparound_use (name);
reset_debug_uses (stmt);
- mark_virtual_ops_for_renaming (stmt);
+ unlink_stmt_vdef (stmt);
gsi_remove (&bsi, true);
release_defs (stmt);
@@ -1751,7 +1725,7 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain,
bitmap tmp_vars)
{
unsigned i;
- dref a, root;
+ dref a;
tree var;
if (chain->combined)
@@ -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,
and replace the uses of the original references by these
variables. */
- root = get_chain_root (chain);
- mark_virtual_ops_for_renaming (root->stmt);
-
initialize_root (loop, chain, tmp_vars);
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);
replace_ref_with (a->stmt, var, false, false);
}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index e7ac92628e9..45d9f023502 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1828,15 +1828,12 @@ sort_and_splice_var_accesses (tree var)
ACCESS->replacement. */
static tree
-create_access_replacement (struct access *access, bool rename)
+create_access_replacement (struct access *access)
{
tree repl;
repl = create_tmp_var (access->type, "SR");
add_referenced_var (repl);
- if (!access->grp_partial_lhs
- && rename)
- mark_sym_for_renaming (repl);
if (TREE_CODE (access->type) == COMPLEX_TYPE
|| TREE_CODE (access->type) == VECTOR_TYPE)
@@ -1917,23 +1914,8 @@ create_access_replacement (struct access *access, bool rename)
static inline tree
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)
- access->replacement_decl = create_access_replacement (access, false);
+ access->replacement_decl = create_access_replacement (access);
return access->replacement_decl;
}
@@ -2832,7 +2814,7 @@ get_repl_default_def_ssa_name (struct access *racc)
{
tree repl, decl;
- decl = get_unrenamed_access_replacement (racc);
+ decl = get_access_replacement (racc);
repl = gimple_default_def (cfun, decl);
if (!repl)
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 541b8c25252..558df409cd3 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1291,6 +1291,8 @@ move_computations_stmt (struct dom_walk_data *dw_data,
for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
{
+ edge e;
+
stmt = gsi_stmt (bsi);
lim_data = get_lim_data (stmt);
@@ -1323,9 +1325,26 @@ move_computations_stmt (struct dom_walk_data *dw_data,
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_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)
static void
rewrite_mem_ref_loc (mem_ref_loc_p loc, tree tmp_var)
{
- mark_virtual_ops_for_renaming (loc->stmt);
*loc->ref = tmp_var;
update_stmt (loc->stmt);
}
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 144050db36b..fe4df9a06f7 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -1204,7 +1204,6 @@ emit_mfence_after_loop (struct loop *loop)
bsi = gsi_after_labels (exit->dest);
gsi_insert_before (&bsi, call, GSI_NEW_STMT);
- mark_virtual_ops_for_renaming (call);
}
VEC_free (edge, heap, exits);
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 50731adc1c4..7eea53717ab 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -416,7 +416,10 @@ finalize_ssa_defs (gimple stmt)
/* If we have a non-SSA_NAME VDEF, mark it for renaming. */
if (gimple_vdef (stmt)
&& 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. */
if (old_ops && old_ops->next == NULL && num == 1
@@ -432,7 +435,12 @@ finalize_ssa_defs (gimple stmt)
/* If there is anything remaining in the build_defs list, simply emit it. */
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. */
gimple_set_def_ops (stmt, new_list.next);
@@ -487,14 +495,18 @@ finalize_ssa_uses (gimple stmt)
&& gimple_vuse (stmt) == NULL_TREE)
{
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. */
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),
- last);
+ {
+ tree *op = (tree *) VEC_index (tree, build_uses, new_i);
+ if (DECL_P (*op))
+ cfun->gimple_df->ssa_renaming_needed = 1;
+ last = add_use_op (stmt, op, last);
+ }
/* Now set the stmt's operands. */
gimple_set_use_ops (stmt, new_list.next);
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 9acb0354941..b8712eb094c 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1771,7 +1771,7 @@ struct gimple_opt_pass pass_early_warn_uninitialized =
a MEM_REF to a plain or converted symbol. */
static void
-maybe_rewrite_mem_ref_base (tree *tp)
+maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming)
{
tree sym;
@@ -1782,7 +1782,7 @@ maybe_rewrite_mem_ref_base (tree *tp)
&& (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0))
&& DECL_P (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
&& useless_type_conversion_p (TREE_TYPE (*tp),
@@ -1891,21 +1891,15 @@ non_rewritable_lvalue_p (tree lhs)
mark the variable VAR for conversion into SSA. Return true when updating
stmts is required. */
-static bool
-maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
+static void
+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. */
if (is_global_var (var)
|| TREE_CODE (var) == RESULT_DECL
|| bitmap_bit_p (addresses_taken, DECL_UID (var)))
- return false;
-
- /* 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;
+ return;
if (TREE_ADDRESSABLE (var)
/* 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)
{
TREE_ADDRESSABLE (var) = 0;
if (is_gimple_reg (var))
- mark_sym_for_renaming (var);
- update_vops = true;
+ bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
if (dump_file)
{
fprintf (dump_file, "No longer having address taken: ");
@@ -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)))
{
DECL_GIMPLE_REG_P (var) = 1;
- mark_sym_for_renaming (var);
- update_vops = true;
+ bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
if (dump_file)
{
fprintf (dump_file, "Now a gimple register: ");
@@ -1945,8 +1937,6 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
fprintf (dump_file, "\n");
}
}
-
- return update_vops;
}
/* Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables. */
@@ -1958,7 +1948,7 @@ execute_update_addresses_taken (void)
basic_block bb;
bitmap addresses_taken = BITMAP_ALLOC (NULL);
bitmap not_reg_needs = BITMAP_ALLOC (NULL);
- bool update_vops = false;
+ bitmap suitable_for_renaming = BITMAP_ALLOC (NULL);
tree var;
unsigned i;
@@ -2057,14 +2047,16 @@ execute_update_addresses_taken (void)
unused vars from BLOCK trees, which causes code generation differences
for -g vs. -g0. */
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)
- 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
- variables. */
- if (update_vops)
+ variables and operands need to be rewritten to expose bare symbols. */
+ if (!bitmap_empty_p (suitable_for_renaming))
{
FOR_EACH_BB (bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
@@ -2090,14 +2082,14 @@ execute_update_addresses_taken (void)
&& (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0))
&& DECL_P (sym)
&& !TREE_ADDRESSABLE (sym)
- && symbol_marked_for_renaming (sym))
+ && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)))
lhs = sym;
else
lhs = gimple_assign_lhs (stmt);
/* Rewrite the RHS and make sure the resulting assignment
is validly typed. */
- maybe_rewrite_mem_ref_base (rhsp);
+ maybe_rewrite_mem_ref_base (rhsp, suitable_for_renaming);
rhs = gimple_assign_rhs1 (stmt);
if (gimple_assign_lhs (stmt) != lhs
&& !useless_type_conversion_p (TREE_TYPE (lhs),
@@ -2112,7 +2104,7 @@ execute_update_addresses_taken (void)
TREE_ADDRESSABLE just remove the stmt. */
if (DECL_P (lhs)
&& TREE_CLOBBER_P (rhs)
- && symbol_marked_for_renaming (lhs))
+ && bitmap_bit_p (suitable_for_renaming, DECL_UID (lhs)))
{
unlink_stmt_vdef (stmt);
gsi_remove (&gsi, true);
@@ -2133,7 +2125,7 @@ execute_update_addresses_taken (void)
for (i = 0; i < gimple_call_num_args (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)
for (i = 0; i < gimple_asm_noutputs (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)
{
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)
{
tree *valuep = gimple_debug_bind_get_value_ptr (stmt);
tree decl;
- maybe_rewrite_mem_ref_base (valuep);
+ maybe_rewrite_mem_ref_base (valuep, suitable_for_renaming);
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);
}
@@ -2179,6 +2174,7 @@ execute_update_addresses_taken (void)
BITMAP_FREE (not_reg_needs);
BITMAP_FREE (addresses_taken);
+ BITMAP_FREE (suitable_for_renaming);
timevar_pop (TV_ADDRESS_TAKEN);
}
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 67c406f4ba1..f2b434a4d65 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -85,7 +85,8 @@ init_ssanames (struct function *fn, int size)
VEC_quick_push (tree, SSANAMES (fn), NULL_TREE);
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. */