From c72321c9a7c869ae5cb7f5bbec1ea4e8c8d3c50a Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sun, 20 Jul 2008 18:06:51 +0200 Subject: cgraph.c (cgraph_add_new_function): Do early local passes. * cgraph.c (cgraph_add_new_function): Do early local passes. * tree-nrv.c (gate_pass_return_slot): New gate. (pass_nrv): Add the gate. * tree-ssa-coalese.c (hash_ssa_name_by_var, eq_ssa_name_by_var): New functions. (coalesce_ssa_name): Coalesce SSA names. * tree-ssa-live.c (remove_unused_locals): Be more conservative when not optimizing so unused user vars remains visible. * common.opt (flag_tree_ter): Always enable by default. * tree-ssa-ter.c: Include flags.h (is_replaceable_p): Check that locations match; when aliasing is missing be conservative about loads. * tree-optimize.c (gate_init_datastructures): Remove. (pass_init_datastructures): New. * passes.c: Reorder passes so we always go into SSA. From-SVN: r138010 --- gcc/tree-ssa-coalesce.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'gcc/tree-ssa-coalesce.c') diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 388437d44bb..a96029aa7c5 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -1297,6 +1297,24 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl, } } +/* Returns a hash code for P. */ + +static hashval_t +hash_ssa_name_by_var (const void *p) +{ + const_tree n = (const_tree) p; + return (hashval_t) htab_hash_pointer (SSA_NAME_VAR (n)); +} + +/* Returns nonzero if P1 and P2 are equal. */ + +static int +eq_ssa_name_by_var (const void *p1, const void *p2) +{ + const_tree n1 = (const_tree) p1; + const_tree n2 = (const_tree) p2; + return SSA_NAME_VAR (n1) == SSA_NAME_VAR (n2); +} /* Reduce the number of copies by coalescing variables in the function. Return a partition map with the resulting coalesces. */ @@ -1310,10 +1328,42 @@ coalesce_ssa_name (void) coalesce_list_p cl; bitmap used_in_copies = BITMAP_ALLOC (NULL); var_map map; + unsigned int i; + static htab_t ssa_name_hash; cl = create_coalesce_list (); map = create_outofssa_var_map (cl, used_in_copies); + /* We need to coalesce all names originating same SSA_NAME_VAR + so debug info remains undisturbed. */ + if (!optimize) + { + ssa_name_hash = htab_create (10, hash_ssa_name_by_var, + eq_ssa_name_by_var, NULL); + for (i = 1; i < num_ssa_names; i++) + { + tree a = ssa_name (i); + + if (a && SSA_NAME_VAR (a) && !DECL_ARTIFICIAL (SSA_NAME_VAR (a))) + { + tree *slot = (tree *) htab_find_slot (ssa_name_hash, a, INSERT); + + if (!*slot) + *slot = a; + else + { + add_coalesce (cl, SSA_NAME_VERSION (a), SSA_NAME_VERSION (*slot), + MUST_COALESCE_COST - 1); + bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (a)); + bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (*slot)); + } + } + } + htab_delete (ssa_name_hash); + } + if (dump_file && (dump_flags & TDF_DETAILS)) + dump_var_map (dump_file, map); + /* Don't calculate live ranges for variables not in the coalesce list. */ partition_view_bitmap (map, used_in_copies, true); BITMAP_FREE (used_in_copies); -- cgit v1.2.1