diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-10 00:37:39 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-10 00:37:39 +0000 |
commit | 1382992bbdaff4b5e426d77b731b0961ba5f6777 (patch) | |
tree | 44bd2d64a442165a5d4162e8caf3157b8f5557a6 /gcc/tree-ssa-live.c | |
parent | d1ad4a2d62169f4b195a00efd68642a4a6d52d4a (diff) | |
download | gcc-1382992bbdaff4b5e426d77b731b0961ba5f6777.tar.gz |
Revert "[PR64164] Drop copyrename, use coalescible partition as base when optimizing."
This reverts commit c66acc7cedd89bfd22124caec44b8427c9082dac.
Conflicts:
gcc/ChangeLog
gcc/testsuite/ChangeLog
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224310 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-live.c')
-rw-r--r-- | gcc/tree-ssa-live.c | 101 |
1 files changed, 96 insertions, 5 deletions
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 0f32b14a863..204e70b6f44 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -89,6 +89,90 @@ static void verify_live_on_entry (tree_live_info_p); ssa_name or variable, and vice versa. */ +/* Hashtable helpers. */ + +struct tree_int_map_hasher : typed_noop_remove <tree_int_map> +{ + typedef tree_int_map *value_type; + typedef tree_int_map *compare_type; + static inline hashval_t hash (const tree_int_map *); + static inline bool equal (const tree_int_map *, const tree_int_map *); +}; + +inline hashval_t +tree_int_map_hasher::hash (const tree_int_map *v) +{ + return tree_map_base_hash (v); +} + +inline bool +tree_int_map_hasher::equal (const tree_int_map *v, const tree_int_map *c) +{ + return tree_int_map_eq (v, c); +} + + +/* This routine will initialize the basevar fields of MAP. */ + +static void +var_map_base_init (var_map map) +{ + int x, num_part; + tree var; + struct tree_int_map *m, *mapstorage; + + num_part = num_var_partitions (map); + hash_table<tree_int_map_hasher> tree_to_index (num_part); + /* We can have at most num_part entries in the hash tables, so it's + enough to allocate so many map elements once, saving some malloc + calls. */ + mapstorage = m = XNEWVEC (struct tree_int_map, num_part); + + /* If a base table already exists, clear it, otherwise create it. */ + free (map->partition_to_base_index); + map->partition_to_base_index = (int *) xmalloc (sizeof (int) * num_part); + + /* Build the base variable list, and point partitions at their bases. */ + for (x = 0; x < num_part; x++) + { + struct tree_int_map **slot; + unsigned baseindex; + var = partition_to_var (map, x); + if (SSA_NAME_VAR (var) + && (!VAR_P (SSA_NAME_VAR (var)) + || !DECL_IGNORED_P (SSA_NAME_VAR (var)))) + m->base.from = SSA_NAME_VAR (var); + else + /* This restricts what anonymous SSA names we can coalesce + as it restricts the sets we compute conflicts for. + Using TREE_TYPE to generate sets is the easies as + type equivalency also holds for SSA names with the same + underlying decl. + + Check gimple_can_coalesce_p when changing this code. */ + m->base.from = (TYPE_CANONICAL (TREE_TYPE (var)) + ? TYPE_CANONICAL (TREE_TYPE (var)) + : TREE_TYPE (var)); + /* If base variable hasn't been seen, set it up. */ + slot = tree_to_index.find_slot (m, INSERT); + if (!*slot) + { + baseindex = m - mapstorage; + m->to = baseindex; + *slot = m; + m++; + } + else + baseindex = (*slot)->to; + map->partition_to_base_index[x] = baseindex; + } + + map->num_basevars = m - mapstorage; + + free (mapstorage); +} + + /* Remove the base table in MAP. */ static void @@ -266,17 +350,21 @@ partition_view_fini (var_map map, bitmap selected) } -/* Create a partition view which includes all the used partitions in MAP. */ +/* Create a partition view which includes all the used partitions in MAP. If + WANT_BASES is true, create the base variable map as well. */ void -partition_view_normal (var_map map) +partition_view_normal (var_map map, bool want_bases) { bitmap used; used = partition_view_init (map); partition_view_fini (map, used); - var_map_base_fini (map); + if (want_bases) + var_map_base_init (map); + else + var_map_base_fini (map); } @@ -285,7 +373,7 @@ partition_view_normal (var_map map) as well. */ void -partition_view_bitmap (var_map map, bitmap only) +partition_view_bitmap (var_map map, bitmap only, bool want_bases) { bitmap used; bitmap new_partitions = BITMAP_ALLOC (NULL); @@ -301,7 +389,10 @@ partition_view_bitmap (var_map map, bitmap only) } partition_view_fini (map, new_partitions); - var_map_base_fini (map); + if (want_bases) + var_map_base_init (map); + else + var_map_base_fini (map); } |