diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-06 14:34:51 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-06 14:34:51 +0000 |
commit | b30a87157955484be66baebfecc08c680d721d93 (patch) | |
tree | 9ee2a06ba9a73c0dbf9a0d7de12bd0049f095cce /gcc/tree-ssa-reassoc.c | |
parent | bfd211a3616f0c871ceecc126156dea9654c96e9 (diff) | |
download | gcc-b30a87157955484be66baebfecc08c680d721d93.tar.gz |
2006-02-06 Paolo Bonzini <bonzini@gnu.org>
* Makefile.in (tree-ssa-loop-ivopts.o): Add pointer-set.h dependency.
(tree-ssa-reassoc.o): Add pointer-set.h dependency.
(tree-cfg.o): Remove hashtab.h dependency.
* tree-ssa-loop-ivopts.c: Include pointer-set.h.
(struct ivopts_data): Change niters to pointer_map_t.
(struct nfe_cache_elt, nfe_hash, nfe_eq): Delete.
(niter_for_exit): Create pointer_map on demand. Change for
pointer_map API.
(tree_ssa_iv_optimize_init): Initialize data->niters to NULL.
(free_loop_data): Destroy data->niters if created and reset field.
(tree_ssa_iv_optimize_finalize): Don't delete data->niters here.
(tree_ssa_iv_optimize_loop): Check for presence of stale data.
* tree-ssa-reassoc.c: Include pointer-set.h.
(bb_rank): Change to long *.
(operand_rank): Change to pointer_map_t.
(find_operand_rank): Return long, -1 if not found. Declare as inline.
(insert_operand_rank): Accept long.
(operand_entry_hash, operand_entry_eq): Remove.
(get_rank): Return long. Adjust for changes above.
(init_reassoc): Change rank type to long. Adjust creation of bb_rank
and operand_rank.
(fini_reassoc): Delete operand_rank with pointer_map_destroy.
* tree-ssa-structalias.c (vi_for_tree): Change to pointer_map.
(struct tree_vi, tree_vi_t, tree_vi_hash, tree_vi_eq): Delete.
(insert_vi_for_tree): Rewrite for pointer_map API. Assert argument
is not NULL.
(lookup_vi_for_tree): Rewrite for pointer_map API. Return varinfo_t
directly since it cannot be NULL.
(get_vi_for_tree): Rewrite for pointer_map API.
(find_what_p_points_to): Adjust for change to lookup_vi_for_tree.
(init_alias_vars): Create vi_for_tree as pointer_map.
(delete_points_to_sets): Delete vi_for_tree using pointer_map_destroy.
* tree-cfg.c: Don't include hashtab.h.
(edge_to_cases): Declare as pointer_map.
(struct edge_to_cases_elt, edge_to_cases_hash, edge_to_cases_eq):
Delete.
(edge_to_cases_cleanup): Rewrite as pointer_map_traverse callback.
(start_recording_case_labels): Create edge_to_cases as pointer_map.
(end_recoding_case_labels): Cleanup edge_to_cases manually before
destroying it.
(record_switch_edge): Delete.
(get_cases_for_edge): Adjust for pointer_map API, inline
record_switch_edge (rewritten for new API), remove goto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121648 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 5e782615072..e216f996637 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -38,6 +38,7 @@ Boston, MA 02110-1301, USA. */ #include "alloc-pool.h" #include "vec.h" #include "langhooks.h" +#include "pointer-set.h" /* This is a simple global reassociation pass. It is, in part, based on the LLVM pass of the same name (They do some things more/less @@ -179,68 +180,38 @@ static alloc_pool operand_entry_pool; /* Starting rank number for a given basic block, so that we can rank operations using unmovable instructions in that BB based on the bb depth. */ -static unsigned int *bb_rank; +static long *bb_rank; /* Operand->rank hashtable. */ -static htab_t operand_rank; +static struct pointer_map_t *operand_rank; /* Look up the operand rank structure for expression E. */ -static operand_entry_t +static inline long find_operand_rank (tree e) { - void **slot; - struct operand_entry vrd; - - vrd.op = e; - slot = htab_find_slot (operand_rank, &vrd, NO_INSERT); - if (!slot) - return NULL; - return ((operand_entry_t) *slot); + void **slot = pointer_map_contains (operand_rank, e); + return slot ? (long) *slot : -1; } /* Insert {E,RANK} into the operand rank hashtable. */ -static void -insert_operand_rank (tree e, unsigned int rank) +static inline void +insert_operand_rank (tree e, long rank) { void **slot; - operand_entry_t new_pair = pool_alloc (operand_entry_pool); - - new_pair->op = e; - new_pair->rank = rank; - slot = htab_find_slot (operand_rank, new_pair, INSERT); - gcc_assert (*slot == NULL); - *slot = new_pair; -} - -/* Return the hash value for a operand rank structure */ - -static hashval_t -operand_entry_hash (const void *p) -{ - const operand_entry_t vr = (operand_entry_t) p; - return iterative_hash_expr (vr->op, 0); -} - -/* Return true if two operand rank structures are equal. */ - -static int -operand_entry_eq (const void *p1, const void *p2) -{ - const operand_entry_t vr1 = (operand_entry_t) p1; - const operand_entry_t vr2 = (operand_entry_t) p2; - return vr1->op == vr2->op; + gcc_assert (rank > 0); + slot = pointer_map_insert (operand_rank, e); + gcc_assert (!*slot); + *slot = (void *) rank; } /* Given an expression E, return the rank of the expression. */ -static unsigned int +static long get_rank (tree e) { - operand_entry_t vr; - /* Constants have rank 0. */ if (is_gimple_min_invariant (e)) return 0; @@ -260,12 +231,12 @@ get_rank (tree e) { tree stmt; tree rhs; - unsigned int rank, maxrank; + long rank, maxrank; int i; if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL && SSA_NAME_IS_DEFAULT_DEF (e)) - return find_operand_rank (e)->rank; + return find_operand_rank (e); stmt = SSA_NAME_DEF_STMT (e); if (bb_for_stmt (stmt) == NULL) @@ -276,9 +247,9 @@ get_rank (tree e) return bb_rank[bb_for_stmt (stmt)->index]; /* If we already have a rank for this expression, use that. */ - vr = find_operand_rank (e); - if (vr) - return vr->rank; + rank = find_operand_rank (e); + if (rank != -1) + return rank; /* Otherwise, find the maximum rank for the operands, or the bb rank, whichever is less. */ @@ -301,7 +272,7 @@ get_rank (tree e) { fprintf (dump_file, "Rank for "); print_generic_expr (dump_file, e, 0); - fprintf (dump_file, " is %d\n", (rank + 1)); + fprintf (dump_file, " is %ld\n", (rank + 1)); } /* Note the rank in the hashtable so we don't recompute it. */ @@ -1417,7 +1388,7 @@ static void init_reassoc (void) { int i; - unsigned int rank = 2; + long rank = 2; tree param; int *bbs = XNEWVEC (int, last_basic_block + 1); @@ -1429,10 +1400,8 @@ init_reassoc (void) /* Reverse RPO (Reverse Post Order) will give us something where deeper loops come later. */ pre_and_rev_post_order_compute (NULL, bbs, false); - bb_rank = XCNEWVEC (unsigned int, last_basic_block + 1); - - operand_rank = htab_create (511, operand_entry_hash, - operand_entry_eq, 0); + bb_rank = XCNEWVEC (long, last_basic_block + 1); + operand_rank = pointer_map_create (); /* Give each argument a distinct rank. */ for (param = DECL_ARGUMENTS (current_function_decl); @@ -1483,8 +1452,8 @@ fini_reassoc (void) fprintf (dump_file, "Statements rewritten: %d\n", reassociate_stats.rewritten); } - htab_delete (operand_rank); + pointer_map_destroy (operand_rank); free_alloc_pool (operand_entry_pool); free (bb_rank); VEC_free (tree, heap, broken_up_subtracts); |