summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-coalesce.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-10 08:29:29 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-08-10 08:29:29 +0000
commitec11736b57986660deef21d6375d2f23edf290d2 (patch)
tree997e1b096111bead6b6ecba118fde1adf2e1a6ff /gcc/tree-ssa-coalesce.c
parent6331b6fa2c9eca625aabcecf3a691577b3cca229 (diff)
downloadgcc-ec11736b57986660deef21d6375d2f23edf290d2.tar.gz
2012-08-10 Richard Guenther <rguenther@suse.de>
* tree.h (SSA_NAME_VAR): Return NULL_TREE if an IDENTIFIER_NODE is recorded as var. (SSA_NAME_IDENTIFIER): Return the IDENTIFIER_NODE of the SSA_NAME or its SSA_NAME_VAR. (SET_SSA_NAME_VAR_OR_IDENTIFIER): New setter. * tree-ssanames.c (make_ssa_name_fn): Handle creating anonymous SSA names by passing a type instead of a variable decl. (release_ssa_name): Use SET_SSA_NAME_VAR_OR_IDENTIFIER. (copy_ssa_name_fn): Handle anonymous SSA names. (replace_ssa_name_symbol): Use SET_SSA_NAME_VAR_OR_IDENTIFIER. * tree-flow-inline.h (make_temp_ssa_name): New inline function. * tree-pretty-print.c (dump_generic_node): Use SSA_NAME_IDENTIFIER, dump SSA names without a name as <anon>. * cfgexpand.c (expand_used_vars): Assing anonymous SSA names we are going to expand a decl. (gimple_expand_cfg): Assign all SSA names of a partition the decl we created for its leader. * tree-ssa.c (target_for_debug_bind): Handle SSA_NAMEs. (verify_ssa_name): Handle anonymous SSA names. (verify_def): Likewise. * tree-predcom.c (eliminate_temp_copies): Likewise. * tree-ssa-copyrename.c (copy_rename_partition_coalesce): Likewise. * tree-ssa-live.c (var_map_base_init): Compute conflicts for anonymous SSA names with the same type. (mark_all_vars_used_1): Handle anonymous SSA names. (verify_live_on_entry): Likewise. * tree-ssa-coalesce.c (abnormal_corrupt): Remove. (create_outofssa_var_map): Adjust with respect to conflicts we compute for anonymous SSA names. Do not restrict abnormal coalescing. (coalesce_partitions): Do not restrict abnormal coalescing. Assert we only ever coalesce variables we computed conflicts for. * tree-ssa-ter.c (process_replaceable): Do not restrict TER of anonymous names. * expr.c (expand_expr_real_1): Handle anonymous SSA names expanded from IVOPTs by creating a raw REG here. * tree-cfg.c (replace_ssa_name): Handle anonymous SSA names. (dump_function_to_file): Dump anonymous SSA names alongside with their types in the variable list. (verify_gimple_return): Guard use of SSA_NAME_VAR. * tree-into-ssa.c (mark_for_renaming): Handle a NULL symbol. (rewrite_into_ssa): Make SSA names anonymous. * tree-ssa-structalias.c (alias_get_name): Rewrite. * tree-ssa-uninit.c (ssa_undefined_value_p): Handle anonymous SSA names. (warn_uninitialized_phi): Likewise. * tree-ssa-loop-ivopts.c (prepare_decl_rtl): Defer expanding anonymous SSA names to the expander. (determine_iv_cost): Anonymous SSA names are artificial. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Handle anonymous SSA names. * lto-streamer-out.c (output_ssa_names): Stream SSA_NAME_VAR or if NULL, the type of the SSA name. * tree-inline.c (remap_ssa_name): Handle anonymous SSA names, remap names as anonymous where appropriate. (insert_init_stmt): Pass SSA names down to insert_init_debug_bind. * tree-ssa-uncprop.c (uncprop_into_successor_phis): Adjust according to what we create conflicts for in out-of-SSA coalescing. * tree-parloops.c (separate_decls_in_region_name): Handle anonymous SSA names. (add_field_for_name): Likewise. * tree.c (get_name): Handle SSA names. * tree-ssa-loop-im.c (gen_lsm_tmp_name): Defer to get_name for SSA_NAMEs. * tree-vect-loop-manip.c (adjust_debug_stmts): Use virtual_operand_p. * tree-sra.c (create_access_replacement): Give up generating a DECL_DEBUG_EXPR for SSA names in the memory reference. (replace_removed_params_ssa_names): Guard use of SSA_NAME_VAR. * tree-complex.c (get_component_ssa_name): Handle anonymous SSA names. (set_component_ssa_name): Likewise. * tree-ssa-sccvn.c (visit_reference_op_load): Likewise. * tree-object-size.c (collect_object_sizes_for): Handle uninitialized SSA names properly. * ipa-inline-analysis.c (eliminated_by_inlining_prob): Guard use of SSA_NAME_VAR. * ipa-split.c (test_nonssa_use): Likewise. (consider_split): Likewise. (mark_nonssa_use): Likewise. c-family/ * c-pretty-print.c (pp_c_expression): Handle anonymous SSA names. cp/ * error.c (dump_expr): Likewise. * g++.dg/plugin/selfassign.c: Adjust. * gcc.dg/plugin/selfassign.c: Likewise. * gcc.dg/strlenopt-11.c: Likewise. * gcc.dg/strlenopt-13.c: Likewise. * gcc.dg/no-strict-overflow-4.c: Likewise. * gcc.dg/strict-overflow-4.c: Likewise. * gcc.dg/tree-ssa/alias-11.c: Likewise. * gcc.dg/tree-ssa/alias-6.c: Likewise. * gcc.dg/tree-ssa/asm-3.c: Likewise. * gcc.dg/tree-ssa/pr18908.c: Likewise. * gcc.dg/tree-ssa/pr19431.c: Likewise. * gcc.dg/tree-ssa/ssa-pre-21.c: Likewise. * gcc.dg/tree-ssa/phi-opt-10.c: Likewise. * gcc.dg/tree-ssa/phi-opt-7.c: Likewise. * gcc.dg/tree-ssa/slsr-27.c: Likewise. * gcc.dg/tree-ssa/slsr-28.c: Likewise. * gcc.dg/tree-ssa/slsr-29.c: Likewise. * gcc.dg/pr46309.c: Likewise. * gcc.dg/tree-ssa/loop-5.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190284 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-coalesce.c')
-rw-r--r--gcc/tree-ssa-coalesce.c64
1 files changed, 19 insertions, 45 deletions
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index 5001ced3abb..b8b1a51dd72 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -924,34 +924,6 @@ print_exprs (FILE *f, const char *str1, tree expr1, const char *str2,
}
-/* Called if a coalesce across and abnormal edge cannot be performed. PHI is
- the phi node at fault, I is the argument index at fault. A message is
- printed and compilation is then terminated. */
-
-static inline void
-abnormal_corrupt (gimple phi, int i)
-{
- edge e = gimple_phi_arg_edge (phi, i);
- tree res = gimple_phi_result (phi);
- tree arg = gimple_phi_arg_def (phi, i);
-
- fprintf (stderr, " Corrupt SSA across abnormal edge BB%d->BB%d\n",
- e->src->index, e->dest->index);
- fprintf (stderr, "Argument %d (", i);
- print_generic_expr (stderr, arg, TDF_SLIM);
- if (TREE_CODE (arg) != SSA_NAME)
- fprintf (stderr, ") is not an SSA_NAME.\n");
- else
- {
- gcc_assert (SSA_NAME_VAR (res) != SSA_NAME_VAR (arg));
- fprintf (stderr, ") does not have the same base variable as the result ");
- print_generic_stmt (stderr, res, TDF_SLIM);
- }
-
- internal_error ("SSA corruption");
-}
-
-
/* Print a failure to coalesce a MUST_COALESCE pair X and Y. */
static inline void
@@ -1007,25 +979,25 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
{
edge e = gimple_phi_arg_edge (phi, i);
arg = PHI_ARG_DEF (phi, i);
- if (TREE_CODE (arg) == SSA_NAME)
- register_ssa_partition (map, arg);
- if (TREE_CODE (arg) == SSA_NAME
- && SSA_NAME_VAR (arg) == SSA_NAME_VAR (res))
- {
+ if (TREE_CODE (arg) != SSA_NAME)
+ continue;
+
+ register_ssa_partition (map, arg);
+ if ((SSA_NAME_VAR (arg) == SSA_NAME_VAR (res)
+ && TREE_TYPE (arg) == TREE_TYPE (res))
+ || (e->flags & EDGE_ABNORMAL))
+ {
saw_copy = true;
bitmap_set_bit (used_in_copy, SSA_NAME_VERSION (arg));
if ((e->flags & EDGE_ABNORMAL) == 0)
{
int cost = coalesce_cost_edge (e);
if (cost == 1 && has_single_use (arg))
- add_cost_one_coalesce (cl, ver, SSA_NAME_VERSION (arg));
+ add_cost_one_coalesce (cl, ver, SSA_NAME_VERSION (arg));
else
add_coalesce (cl, ver, SSA_NAME_VERSION (arg), cost);
}
}
- else
- if (e->flags & EDGE_ABNORMAL)
- abnormal_corrupt (phi, i);
}
if (saw_copy)
bitmap_set_bit (used_in_copy, ver);
@@ -1053,7 +1025,8 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
if (gimple_assign_copy_p (stmt)
&& TREE_CODE (lhs) == SSA_NAME
&& TREE_CODE (rhs1) == SSA_NAME
- && SSA_NAME_VAR (lhs) == SSA_NAME_VAR (rhs1))
+ && SSA_NAME_VAR (lhs) == SSA_NAME_VAR (rhs1)
+ && TREE_TYPE (lhs) == TREE_TYPE (rhs1))
{
v1 = SSA_NAME_VERSION (lhs);
v2 = SSA_NAME_VERSION (rhs1);
@@ -1103,7 +1076,8 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
v1 = SSA_NAME_VERSION (outputs[match]);
v2 = SSA_NAME_VERSION (input);
- if (SSA_NAME_VAR (outputs[match]) == SSA_NAME_VAR (input))
+ if (SSA_NAME_VAR (outputs[match]) == SSA_NAME_VAR (input)
+ && TREE_TYPE (outputs[match]) == TREE_TYPE (input))
{
cost = coalesce_cost (REG_BR_PROB_BASE,
optimize_bb_for_size_p (bb));
@@ -1130,13 +1104,15 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
if (var != NULL_TREE && is_gimple_reg (var))
{
/* Add coalesces between all the result decls. */
- if (TREE_CODE (SSA_NAME_VAR (var)) == RESULT_DECL)
+ if (SSA_NAME_VAR (var)
+ && TREE_CODE (SSA_NAME_VAR (var)) == RESULT_DECL)
{
if (first == NULL_TREE)
first = var;
else
{
- gcc_assert (SSA_NAME_VAR (var) == SSA_NAME_VAR (first));
+ gcc_assert (SSA_NAME_VAR (var) == SSA_NAME_VAR (first)
+ && TREE_TYPE (var) == TREE_TYPE (first));
v1 = SSA_NAME_VERSION (first);
v2 = SSA_NAME_VERSION (var);
bitmap_set_bit (used_in_copy, v1);
@@ -1256,9 +1232,6 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
int v1 = SSA_NAME_VERSION (res);
int v2 = SSA_NAME_VERSION (arg);
- if (SSA_NAME_VAR (arg) != SSA_NAME_VAR (res))
- abnormal_corrupt (phi, e->dest_idx);
-
if (debug)
fprintf (debug, "Abnormal coalesce: ");
@@ -1276,7 +1249,8 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
var2 = ssa_name (y);
/* Assert the coalesces have the same base variable. */
- gcc_assert (SSA_NAME_VAR (var1) == SSA_NAME_VAR (var2));
+ gcc_assert (SSA_NAME_VAR (var1) == SSA_NAME_VAR (var2)
+ && TREE_TYPE (var1) == TREE_TYPE (var2));
if (debug)
fprintf (debug, "Coalesce list: ");