diff options
author | Richard Guenther <rguenther@suse.de> | 2010-01-04 21:02:42 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-01-04 21:02:42 +0000 |
commit | a7d04a5357719127b0ac3b8f139ccabf188f30b4 (patch) | |
tree | 0d4b71e06f20c74e023eb6aacd7690d252cf6d24 /gcc/tree-ssa-sccvn.c | |
parent | d6de356aa3f8fa23a08ca801aa63c5e9cce58a20 (diff) | |
download | gcc-a7d04a5357719127b0ac3b8f139ccabf188f30b4.zip gcc-a7d04a5357719127b0ac3b8f139ccabf188f30b4.tar.gz gcc-a7d04a5357719127b0ac3b8f139ccabf188f30b4.tar.bz2 |
tree-ssa-sccvn.c (get_or_alloc_constant_value_id): Allocate a new entry only if needed.
2010-01-04 Richard Guenther <rguenther@suse.de>
* 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
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 2994bff..79ce3c2 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -357,21 +357,23 @@ unsigned int get_or_alloc_constant_value_id (tree constant) { void **slot; - vn_constant_t vc = XNEW (struct vn_constant_s); + struct vn_constant_s vc; + vn_constant_t vcp; - vc->hashcode = vn_hash_constant_with_type (constant); - vc->constant = constant; - slot = htab_find_slot_with_hash (constant_to_value_id, vc, - vc->hashcode, INSERT); + vc.hashcode = vn_hash_constant_with_type (constant); + vc.constant = constant; + slot = htab_find_slot_with_hash (constant_to_value_id, &vc, + vc.hashcode, INSERT); if (*slot) - { - free (vc); - return ((vn_constant_t)*slot)->value_id; - } - vc->value_id = get_next_value_id (); - *slot = vc; - bitmap_set_bit (constant_value_ids, vc->value_id); - return vc->value_id; + return ((vn_constant_t)*slot)->value_id; + + vcp = XNEW (struct vn_constant_s); + vcp->hashcode = vc.hashcode; + vcp->constant = constant; + vcp->value_id = get_next_value_id (); + *slot = (void *) vcp; + bitmap_set_bit (constant_value_ids, vcp->value_id); + return vcp->value_id; } /* Return true if V is a value id for a constant. */ |