diff options
author | Lawrence Crowl <crowl@google.com> | 2012-10-09 21:21:36 +0000 |
---|---|---|
committer | Lawrence Crowl <crowl@gcc.gnu.org> | 2012-10-09 21:21:36 +0000 |
commit | 703c8606fa58f4c827deda50f641da57294cc78e (patch) | |
tree | 6b83efb5a5d730e31c6760ce9e20be32071b13a4 /gcc/fold-const.c | |
parent | aa4723d7f56dd0c690c514b50c917c827a3d56dd (diff) | |
download | gcc-703c8606fa58f4c827deda50f641da57294cc78e.tar.gz |
Change more non-GTY hash tables to use the new type-safe template hash table.
Constify member function parameters that can be const.
Correct a couple of expressions in formerly uninstantiated templates.
The new code is 0.362% faster in bootstrap, with a 99.5% confidence of
being faster.
Tested on x86-64.
Index: gcc/java/ChangeLog
2012-10-01 Lawrence Crowl <crowl@google.com>
* Make-lang.in (JAVA_OBJS): Add dependence on hash-table.o.
(JCFDUMP_OBJS): Add dependence on hash-table.o.
(jcf-io.o): Add dependence on hash-table.h.
* jcf-io.c (memoized_class_lookups): Change to use type-safe hash table.
Index: gcc/c/ChangeLog
2012-10-09 Lawrence Crowl <crowl@google.com>
* Make-lang.in (c-decl.o): Add dependence on hash-table.h.
* c-decl.c (detect_field_duplicates_hash): Change to new type-safe
hash table.
Index: gcc/objc/ChangeLog
2012-10-01 Lawrence Crowl <crowl@google.com>
* Make-lang.in (OBJC_OBJS): Add dependence on hash-table.o.
(objc-act.o): Add dependence on hash-table.h.
* objc-act.c (objc_detect_field_duplicates): Change to new type-safe
hash table.
Index: gcc/ChangeLog
2012-10-09 Lawrence Crowl <crowl@google.com>
* Makefile.in (fold-const.o): Add depencence on hash-table.h.
(dse.o): Likewise.
(cfg.o): Likewise.
* fold-const.c (fold_checksum_tree): Change to new type-safe hash table.
* (print_fold_checksum): Likewise.
* cfg.c (var bb_original): Likewise.
* (var bb_copy): Likewise.
* (var loop_copy): Likewise.
* hash-table.h (template hash_table): Constify parameters for find...
and remove_elt... member functions.
(hash_table::empty) Correct size expression.
(hash_table::clear_slot) Correct deleted entry assignment.
* dse.c (var rtx_group_table): Change to new type-safe hash table.
Index: gcc/cp/ChangeLog
2012-10-09 Lawrence Crowl <crowl@google.com>
* Make-lang.in (class.o): Add dependence on hash-table.h.
(tree.o): Likewise.
(semantics.o): Likewise.
* class.c (fixed_type_or_null): Change to new type-safe hash table.
* tree.c (verify_stmt_tree): Likewise.
(verify_stmt_tree_r): Likewise.
* semantics.c (struct nrv_data): Likewise.
From-SVN: r192273
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9dabfabcec8..99655a1df9c 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -56,7 +56,7 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-core.h" #include "intl.h" #include "ggc.h" -#include "hashtab.h" +#include "hash-table.h" #include "langhooks.h" #include "md5.h" #include "gimple.h" @@ -14320,7 +14320,8 @@ fold (tree expr) #ifdef ENABLE_FOLD_CHECKING #undef fold -static void fold_checksum_tree (const_tree, struct md5_ctx *, htab_t); +static void fold_checksum_tree (const_tree, struct md5_ctx *, + hash_table <pointer_hash <tree_node> >); static void fold_check_failed (const_tree, const_tree); void print_fold_checksum (const_tree); @@ -14334,20 +14335,20 @@ fold (tree expr) tree ret; struct md5_ctx ctx; unsigned char checksum_before[16], checksum_after[16]; - htab_t ht; + hash_table <pointer_hash <tree_node> > ht; - ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (expr, &ctx, ht); md5_finish_ctx (&ctx, checksum_before); - htab_empty (ht); + ht.empty (); ret = fold_1 (expr); md5_init_ctx (&ctx); fold_checksum_tree (expr, &ctx, ht); md5_finish_ctx (&ctx, checksum_after); - htab_delete (ht); + ht.dispose (); if (memcmp (checksum_before, checksum_after, 16)) fold_check_failed (expr, ret); @@ -14360,13 +14361,13 @@ print_fold_checksum (const_tree expr) { struct md5_ctx ctx; unsigned char checksum[16], cnt; - htab_t ht; + hash_table <pointer_hash <tree_node> > ht; - ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (expr, &ctx, ht); md5_finish_ctx (&ctx, checksum); - htab_delete (ht); + ht.dispose (); for (cnt = 0; cnt < 16; ++cnt) fprintf (stderr, "%02x", checksum[cnt]); putc ('\n', stderr); @@ -14379,9 +14380,10 @@ fold_check_failed (const_tree expr ATTRIBUTE_UNUSED, const_tree ret ATTRIBUTE_UN } static void -fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, htab_t ht) +fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, + hash_table <pointer_hash <tree_node> > ht) { - void **slot; + tree_node **slot; enum tree_code code; union tree_node buf; int i, len; @@ -14389,7 +14391,7 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, htab_t ht) recursive_label: if (expr == NULL) return; - slot = (void **) htab_find_slot (ht, expr, INSERT); + slot = ht.find_slot (expr, INSERT); if (*slot != NULL) return; *slot = CONST_CAST_TREE (expr); @@ -14538,12 +14540,13 @@ debug_fold_checksum (const_tree t) int i; unsigned char checksum[16]; struct md5_ctx ctx; - htab_t ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + hash_table <pointer_hash <tree_node> > ht; + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (t, &ctx, ht); md5_finish_ctx (&ctx, checksum); - htab_empty (ht); + ht.empty (); for (i = 0; i < 16; i++) fprintf (stderr, "%d ", checksum[i]); @@ -14566,13 +14569,13 @@ fold_build1_stat_loc (location_t loc, #ifdef ENABLE_FOLD_CHECKING unsigned char checksum_before[16], checksum_after[16]; struct md5_ctx ctx; - htab_t ht; + hash_table <pointer_hash <tree_node> > ht; - ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (op0, &ctx, ht); md5_finish_ctx (&ctx, checksum_before); - htab_empty (ht); + ht.empty (); #endif tem = fold_unary_loc (loc, code, type, op0); @@ -14583,7 +14586,7 @@ fold_build1_stat_loc (location_t loc, md5_init_ctx (&ctx); fold_checksum_tree (op0, &ctx, ht); md5_finish_ctx (&ctx, checksum_after); - htab_delete (ht); + ht.dispose (); if (memcmp (checksum_before, checksum_after, 16)) fold_check_failed (op0, tem); @@ -14609,18 +14612,18 @@ fold_build2_stat_loc (location_t loc, checksum_after_op0[16], checksum_after_op1[16]; struct md5_ctx ctx; - htab_t ht; + hash_table <pointer_hash <tree_node> > ht; - ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (op0, &ctx, ht); md5_finish_ctx (&ctx, checksum_before_op0); - htab_empty (ht); + ht.empty (); md5_init_ctx (&ctx); fold_checksum_tree (op1, &ctx, ht); md5_finish_ctx (&ctx, checksum_before_op1); - htab_empty (ht); + ht.empty (); #endif tem = fold_binary_loc (loc, code, type, op0, op1); @@ -14631,7 +14634,7 @@ fold_build2_stat_loc (location_t loc, md5_init_ctx (&ctx); fold_checksum_tree (op0, &ctx, ht); md5_finish_ctx (&ctx, checksum_after_op0); - htab_empty (ht); + ht.empty (); if (memcmp (checksum_before_op0, checksum_after_op0, 16)) fold_check_failed (op0, tem); @@ -14639,7 +14642,7 @@ fold_build2_stat_loc (location_t loc, md5_init_ctx (&ctx); fold_checksum_tree (op1, &ctx, ht); md5_finish_ctx (&ctx, checksum_after_op1); - htab_delete (ht); + ht.dispose (); if (memcmp (checksum_before_op1, checksum_after_op1, 16)) fold_check_failed (op1, tem); @@ -14665,23 +14668,23 @@ fold_build3_stat_loc (location_t loc, enum tree_code code, tree type, checksum_after_op1[16], checksum_after_op2[16]; struct md5_ctx ctx; - htab_t ht; + hash_table <pointer_hash <tree_node> > ht; - ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (op0, &ctx, ht); md5_finish_ctx (&ctx, checksum_before_op0); - htab_empty (ht); + ht.empty (); md5_init_ctx (&ctx); fold_checksum_tree (op1, &ctx, ht); md5_finish_ctx (&ctx, checksum_before_op1); - htab_empty (ht); + ht.empty (); md5_init_ctx (&ctx); fold_checksum_tree (op2, &ctx, ht); md5_finish_ctx (&ctx, checksum_before_op2); - htab_empty (ht); + ht.empty (); #endif gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp); @@ -14693,7 +14696,7 @@ fold_build3_stat_loc (location_t loc, enum tree_code code, tree type, md5_init_ctx (&ctx); fold_checksum_tree (op0, &ctx, ht); md5_finish_ctx (&ctx, checksum_after_op0); - htab_empty (ht); + ht.empty (); if (memcmp (checksum_before_op0, checksum_after_op0, 16)) fold_check_failed (op0, tem); @@ -14701,7 +14704,7 @@ fold_build3_stat_loc (location_t loc, enum tree_code code, tree type, md5_init_ctx (&ctx); fold_checksum_tree (op1, &ctx, ht); md5_finish_ctx (&ctx, checksum_after_op1); - htab_empty (ht); + ht.empty (); if (memcmp (checksum_before_op1, checksum_after_op1, 16)) fold_check_failed (op1, tem); @@ -14709,7 +14712,7 @@ fold_build3_stat_loc (location_t loc, enum tree_code code, tree type, md5_init_ctx (&ctx); fold_checksum_tree (op2, &ctx, ht); md5_finish_ctx (&ctx, checksum_after_op2); - htab_delete (ht); + ht.dispose (); if (memcmp (checksum_before_op2, checksum_after_op2, 16)) fold_check_failed (op2, tem); @@ -14733,20 +14736,20 @@ fold_build_call_array_loc (location_t loc, tree type, tree fn, checksum_after_fn[16], checksum_after_arglist[16]; struct md5_ctx ctx; - htab_t ht; + hash_table <pointer_hash <tree_node> > ht; int i; - ht = htab_create (32, htab_hash_pointer, htab_eq_pointer, NULL); + ht.create (32); md5_init_ctx (&ctx); fold_checksum_tree (fn, &ctx, ht); md5_finish_ctx (&ctx, checksum_before_fn); - htab_empty (ht); + ht.empty (); md5_init_ctx (&ctx); for (i = 0; i < nargs; i++) fold_checksum_tree (argarray[i], &ctx, ht); md5_finish_ctx (&ctx, checksum_before_arglist); - htab_empty (ht); + ht.empty (); #endif tem = fold_builtin_call_array (loc, type, fn, nargs, argarray); @@ -14755,7 +14758,7 @@ fold_build_call_array_loc (location_t loc, tree type, tree fn, md5_init_ctx (&ctx); fold_checksum_tree (fn, &ctx, ht); md5_finish_ctx (&ctx, checksum_after_fn); - htab_empty (ht); + ht.empty (); if (memcmp (checksum_before_fn, checksum_after_fn, 16)) fold_check_failed (fn, tem); @@ -14764,7 +14767,7 @@ fold_build_call_array_loc (location_t loc, tree type, tree fn, for (i = 0; i < nargs; i++) fold_checksum_tree (argarray[i], &ctx, ht); md5_finish_ctx (&ctx, checksum_after_arglist); - htab_delete (ht); + ht.dispose (); if (memcmp (checksum_before_arglist, checksum_after_arglist, 16)) fold_check_failed (NULL_TREE, tem); |