aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-data-refs.c
diff options
context:
space:
mode:
authorLawrence Crowl <crowl@google.com>2013-04-23 22:00:12 +0000
committerLawrence Crowl <crowl@gcc.gnu.org>2013-04-23 22:00:12 +0000
commitbf190e8df270025e2d0729858c031eb4ef7d49d2 (patch)
treefd9e547e6ac26ffd9c7200538fb2582c9ab2c3dc /gcc/tree-vect-data-refs.c
parent4a8043c4e02c8c2517424722ba3055a159b93e87 (diff)
downloadgcc-bf190e8df270025e2d0729858c031eb4ef7d49d2.zip
gcc-bf190e8df270025e2d0729858c031eb4ef7d49d2.tar.gz
gcc-bf190e8df270025e2d0729858c031eb4ef7d49d2.tar.bz2
This patch extracts approved portions of the hash_table patches to the...
This patch extracts approved portions of the hash_table patches to the cxx-conversion branch for files not under gcc/config. Update various hash tables from htab_t to hash_table. Modify types and calls to match. * tree-ssa-coalesce.c'coalesce_list_d.list from htab_t to hash_table. Fold coalesce_pair_map_hash and coalesce_pair_map_eq into new struct coalesce_pair_hasher. Removed struct coalesce_pair_iterator, as did not meet the hash_table iterator interface and it provided no significant code reduction. This leads to a change in the implementation of FOR_EACH_PARTITION_PAIR. * statistics.c'statistics_hashes Fold hash_statistics_eq into new struct stats_counter_hasher. * hash-table.h'hash_table Add documentation. Add nested class iterator and methods to hash_table. Add FOR_EACH_HASH_TABLE_ELEMENT implemented with those iterators. Change uses of FOR_EACH_HTAB_ELEMENT to FOR_EACH_HASH_TABLE_ELEMENT. * tree-ssa-sccvn.c'vn_tables_s.nary Fold vn_nary_op_hash, vn_nary_op_eq into new struct vn_nary_op_hasher. Add typedef vn_nary_op_table_type. Add typedef vn_nary_op_iterator_type. * tree-ssa-sccvn.c'vn_tables_s.phis Fold vn_phi_hash, free_phi into new struct vn_phi_hasher. Add typedef vn_phi_table_type. Add typedef vn_phi_iterator_type. * tree-ssa-sccvn.c'vn_tables_s.references Fold vn_reference_hash, vn_reference_op_eq, free_reference into new struct vn_reference_hasher. Add typedef vn_reference_table_type. Add typedef vn_reference_iterator_type. * tree-ssa-sccvn.c'constant_value_ids Fold vn_constant_hash, vn_constant_eq into new struct vn_constant_hasher. * tree-into-ssa.c'var_infos Fold var_info_hash, var_info_eq into new struct var_info_hasher. * tree-vectorizer.h'_loop_vec_info::peeling_htab * tree-vectorizer.h New struct peel_info_hasher. * tree-vect-loop.c Update dependent calls and types to match. * tree-vect-data-refs.c Fold vect_peeling_hash and vect_peeling_hash_eq into struct peel_info_hasher. * tree-ssa-reassoc.c'undistribute_ops_list::ctable Fold oecount_hash and oecount_eq into new struct oecount_hasher. * tree-ssa-loop-im.c'memory_accesses.refs Fold memref_hash and memref_eq into new struct mem_ref_hasher. Tested on x86_64. Index: gcc/ChangeLog 2013-04-23 Lawrence Crowl <crowl@google.com> * Makefile.in: Update as needed below. * hash-table.h (class hash_table): Correct many methods with parameter types compare_type to the correct value_type. (Correct code was unlikely to notice the change.) (hash_table::elements_with_deleted) New. (class hashtable::iterator): New. (hashtable::begin()): New. (hashtable::end()): New. (FOR_EACH_HASH_TABLE_ELEMENT): New. * statistics.c (statistics_hashes): Change type to hash_table. Update dependent calls and types. * tree-into-ssa.c (var_infos): Change type to hash_table. Update dependent calls and types. * tree-ssa-coalesce.c (struct coalesce_list_d.list): Change type to hash_table. Update dependent calls and types. * tree-ssa-loop-im.c (struct mem_ref.refs): Change type to hash_table. Update dependent calls and types. * tree-ssa-reassoc.c (undistribute_ops_list::ctable): Change type to hash_table. Update dependent calls and types. * tree-ssa-sccvn.c (vn_tables_s::nary): Change type to hash_table. Update dependent calls and types. (vn_tables_s::phis): Likewise. (vn_tables_s::references): Likewise. * tree-ssa-sccvn.h (vn_nary_op_eq): Update parameter and return types. (vn_reference_eq): Update parameter and return types. * tree-ssa-structalias.c (pointer_equiv_class_table): Change type to hash_table. Update dependent calls and types. (location_equiv_class_table): Likewise. * tree-vect-data-refs.c: Consequential changes for making peeling a hash_table. * tree-vect-loop.c (new_loop_vec_info): Dependent hash_table update. (destroy_loop_vec_info): Dependent hash_table update. * tree-vectorizer.h (peeling_htab): Change type to hash_table. Update dependent calls and types. From-SVN: r198213
Diffstat (limited to 'gcc/tree-vect-data-refs.c')
-rw-r--r--gcc/tree-vect-data-refs.c61
1 files changed, 19 insertions, 42 deletions
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 9cbc5c7..c1b5826 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -1062,27 +1062,6 @@ vect_get_data_access_cost (struct data_reference *dr,
}
-static hashval_t
-vect_peeling_hash (const void *elem)
-{
- const struct _vect_peel_info *peel_info;
-
- peel_info = (const struct _vect_peel_info *) elem;
- return (hashval_t) peel_info->npeel;
-}
-
-
-static int
-vect_peeling_hash_eq (const void *elem1, const void *elem2)
-{
- const struct _vect_peel_info *a, *b;
-
- a = (const struct _vect_peel_info *) elem1;
- b = (const struct _vect_peel_info *) elem2;
- return (a->npeel == b->npeel);
-}
-
-
/* Insert DR into peeling hash table with NPEEL as key. */
static void
@@ -1090,12 +1069,11 @@ vect_peeling_hash_insert (loop_vec_info loop_vinfo, struct data_reference *dr,
int npeel)
{
struct _vect_peel_info elem, *slot;
- void **new_slot;
+ _vect_peel_info **new_slot;
bool supportable_dr_alignment = vect_supportable_dr_alignment (dr, true);
elem.npeel = npeel;
- slot = (vect_peel_info) htab_find (LOOP_VINFO_PEELING_HTAB (loop_vinfo),
- &elem);
+ slot = LOOP_VINFO_PEELING_HTAB (loop_vinfo).find (&elem);
if (slot)
slot->count++;
else
@@ -1104,8 +1082,7 @@ vect_peeling_hash_insert (loop_vec_info loop_vinfo, struct data_reference *dr,
slot->npeel = npeel;
slot->dr = dr;
slot->count = 1;
- new_slot = htab_find_slot (LOOP_VINFO_PEELING_HTAB (loop_vinfo), slot,
- INSERT);
+ new_slot = LOOP_VINFO_PEELING_HTAB (loop_vinfo).find_slot (slot, INSERT);
*new_slot = slot;
}
@@ -1117,11 +1094,11 @@ vect_peeling_hash_insert (loop_vec_info loop_vinfo, struct data_reference *dr,
/* Traverse peeling hash table to find peeling option that aligns maximum
number of data accesses. */
-static int
-vect_peeling_hash_get_most_frequent (void **slot, void *data)
+int
+vect_peeling_hash_get_most_frequent (_vect_peel_info **slot,
+ _vect_peel_extended_info *max)
{
- vect_peel_info elem = (vect_peel_info) *slot;
- vect_peel_extended_info max = (vect_peel_extended_info) data;
+ vect_peel_info elem = *slot;
if (elem->count > max->peel_info.count
|| (elem->count == max->peel_info.count
@@ -1139,11 +1116,11 @@ vect_peeling_hash_get_most_frequent (void **slot, void *data)
/* Traverse peeling hash table and calculate cost for each peeling option.
Find the one with the lowest cost. */
-static int
-vect_peeling_hash_get_lowest_cost (void **slot, void *data)
+int
+vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
+ _vect_peel_extended_info *min)
{
- vect_peel_info elem = (vect_peel_info) *slot;
- vect_peel_extended_info min = (vect_peel_extended_info) data;
+ vect_peel_info elem = *slot;
int save_misalignment, dummy;
unsigned int inside_cost = 0, outside_cost = 0, i;
gimple stmt = DR_STMT (elem->dr);
@@ -1223,14 +1200,16 @@ vect_peeling_hash_choose_best_peeling (loop_vec_info loop_vinfo,
{
res.inside_cost = INT_MAX;
res.outside_cost = INT_MAX;
- htab_traverse (LOOP_VINFO_PEELING_HTAB (loop_vinfo),
- vect_peeling_hash_get_lowest_cost, &res);
+ LOOP_VINFO_PEELING_HTAB (loop_vinfo)
+ .traverse <_vect_peel_extended_info *,
+ vect_peeling_hash_get_lowest_cost> (&res);
}
else
{
res.peel_info.count = 0;
- htab_traverse (LOOP_VINFO_PEELING_HTAB (loop_vinfo),
- vect_peeling_hash_get_most_frequent, &res);
+ LOOP_VINFO_PEELING_HTAB (loop_vinfo)
+ .traverse <_vect_peel_extended_info *,
+ vect_peeling_hash_get_most_frequent> (&res);
}
*npeel = res.peel_info.npeel;
@@ -1423,10 +1402,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
size_zero_node) < 0;
/* Save info about DR in the hash table. */
- if (!LOOP_VINFO_PEELING_HTAB (loop_vinfo))
- LOOP_VINFO_PEELING_HTAB (loop_vinfo) =
- htab_create (1, vect_peeling_hash,
- vect_peeling_hash_eq, free);
+ if (!LOOP_VINFO_PEELING_HTAB (loop_vinfo).is_created ())
+ LOOP_VINFO_PEELING_HTAB (loop_vinfo).create (1);
vectype = STMT_VINFO_VECTYPE (stmt_info);
nelements = TYPE_VECTOR_SUBPARTS (vectype);