diff options
author | Richard Biener <rguenther@suse.de> | 2020-11-06 15:13:56 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-11-06 15:41:04 +0100 |
commit | d398949230786a4d678677fab0070ad779cc1c84 (patch) | |
tree | 4f9140fee42f85962b5b44af1c26357e2472706b /gcc/tree-ssa-sccvn.c | |
parent | 22175d0dc6a89ddd630f19d0f32a2d1ddb046807 (diff) | |
download | gcc-d398949230786a4d678677fab0070ad779cc1c84.zip gcc-d398949230786a4d678677fab0070ad779cc1c84.tar.gz gcc-d398949230786a4d678677fab0070ad779cc1c84.tar.bz2 |
make PRE constant value IDs negative
This separates constant and non-constant value-ids to allow for
a more efficient constant_value_id_p and for more efficient bit-packing
inside the bitmap sets which never contain any constant values.
There's further optimization opportunities but at this stage
I'll do small refactorings.
2020-11-06 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.h (get_max_constant_value_id): Declare.
(get_next_constant_value_id): Likewise.
(value_id_constant_p): Inline and simplify.
* tree-ssa-sccvn.c (constant_value_ids): Remove.
(next_constant_value_id): Add.
(get_or_alloc_constant_value_id): Adjust.
(value_id_constant_p): Remove definition.
(get_max_constant_value_id): Define.
(get_next_value_id): Add assert for overflow.
(get_next_constant_value_id): Define.
(run_rpo_vn): Adjust.
(free_rpo_vn): Likewise.
(do_rpo_vn): Initialize next_constant_value_id.
* tree-ssa-pre.c (constant_value_expressions): New.
(add_to_value): Split into constant/non-constant value
handling. Avoid exact re-allocation.
(vn_valnum_from_value_id): Adjust.
(phi_translate_1): Remove spurious exact re-allocation.
(bitmap_find_leader): Adjust. Make sure we return
a CONSTANT value for a constant value id.
(do_pre_regular_insertion): Use 2 auto-elements for avail.
(do_pre_partial_partial_insertion): Likewise.
(init_pre): Allocate constant_value_expressions.
(fini_pre): Release constant_value_expressions.
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index c139adb..8c9880e 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -288,7 +288,6 @@ vn_constant_hasher::equal (const vn_constant_s *vc1, const vn_constant_s *vc2) } static hash_table<vn_constant_hasher> *constant_to_value_id; -static bitmap constant_value_ids; /* Obstack we allocate the vn-tables elements from. */ @@ -322,6 +321,7 @@ tree VN_TOP; /* Unique counter for our value ids. */ static unsigned int next_value_id; +static int next_constant_value_id; /* Table of vn_ssa_aux_t's, one per ssa_name. The vn_ssa_aux_t objects @@ -611,20 +611,11 @@ get_or_alloc_constant_value_id (tree constant) vcp = XNEW (struct vn_constant_s); vcp->hashcode = vc.hashcode; vcp->constant = constant; - vcp->value_id = get_next_value_id (); + vcp->value_id = get_next_constant_value_id (); *slot = 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. */ - -bool -value_id_constant_p (unsigned int v) -{ - return bitmap_bit_p (constant_value_ids, v); -} - /* Compute the hash for a reference operand VRO1. */ static void @@ -5578,14 +5569,32 @@ get_max_value_id (void) return next_value_id; } +/* Return the maximum constant value id we have ever seen. */ + +unsigned int +get_max_constant_value_id (void) +{ + return -next_constant_value_id; +} + /* Return the next unique value id. */ unsigned int get_next_value_id (void) { + gcc_checking_assert ((int)next_value_id > 0); return next_value_id++; } +/* Return the next unique value id for constants. */ + +unsigned int +get_next_constant_value_id (void) +{ + gcc_checking_assert (next_constant_value_id < 0); + return next_constant_value_id--; +} + /* Compare two expressions E1 and E2 and return true if they are equal. */ @@ -6654,7 +6663,6 @@ run_rpo_vn (vn_lookup_kind kind) /* ??? Prune requirement of these. */ constant_to_value_id = new hash_table<vn_constant_hasher> (23); - constant_value_ids = BITMAP_ALLOC (NULL); /* Initialize the value ids and prune out remaining VN_TOPs from dead code. */ @@ -6721,7 +6729,6 @@ free_rpo_vn (void) delete constant_to_value_id; constant_to_value_id = NULL; - BITMAP_FREE (constant_value_ids); } /* Hook for maybe_push_res_to_seq, lookup the expression in the VN tables. */ @@ -7446,6 +7453,7 @@ do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, / (n_basic_blocks_for_fn (fn) - NUM_FIXED_BLOCKS)); VN_TOP = create_tmp_var_raw (void_type_node, "vn_top"); next_value_id = 1; + next_constant_value_id = -1; vn_ssa_aux_hash = new hash_table <vn_ssa_aux_hasher> (region_size * 2); gcc_obstack_init (&vn_ssa_aux_obstack); |