From a7d04a5357719127b0ac3b8f139ccabf188f30b4 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 4 Jan 2010 21:02:42 +0000 Subject: tree-ssa-sccvn.c (get_or_alloc_constant_value_id): Allocate a new entry only if needed. 2010-01-04 Richard Guenther * tree-ssa-sccvn.c (get_or_alloc_constant_value_id): Allocate a new entry only if needed. * tree-ssa-dom.c (lookup_avail_expr): Likewise. * tree-ssa-coalesce.c (find_coalesce_pair): Avoid one hashtable lookup. * tree-ssa-pre.c (sorted_array_from_bitmap_set): Pre-allocate the result array. (phi_translate): Handle CONSTANTs early. From-SVN: r155633 --- gcc/tree-ssa-coalesce.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'gcc/tree-ssa-coalesce.c') diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 867e15c..b96d091 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -256,7 +256,7 @@ delete_coalesce_list (coalesce_list_p cl) static coalesce_pair_p find_coalesce_pair (coalesce_list_p cl, int p1, int p2, bool create) { - struct coalesce_pair p, *pair; + struct coalesce_pair p; void **slot; unsigned int hash; @@ -272,22 +272,23 @@ find_coalesce_pair (coalesce_list_p cl, int p1, int p2, bool create) p.second_element = p2; } - hash = coalesce_pair_map_hash (&p); - pair = (struct coalesce_pair *) htab_find_with_hash (cl->list, &p, hash); + slot = htab_find_slot_with_hash (cl->list, &p, hash, + create ? INSERT : NO_INSERT); + if (!slot) + return NULL; - if (create && !pair) + if (!*slot) { + struct coalesce_pair * pair = XNEW (struct coalesce_pair); gcc_assert (cl->sorted == NULL); - pair = XNEW (struct coalesce_pair); pair->first_element = p.first_element; pair->second_element = p.second_element; pair->cost = 0; - slot = htab_find_slot_with_hash (cl->list, pair, hash, INSERT); - *(struct coalesce_pair **)slot = pair; + *slot = (void *)pair; } - return pair; + return (struct coalesce_pair *) *slot; } static inline void -- cgit v1.1