Commit 15814ba0 by Paolo Bonzini Committed by Paolo Bonzini

Makefile.in (tree-ssa-loop-ivopts.o): Add pointer-set.h dependency.

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.

From-SVN: r121648
parent 0802f6a2
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.
2006-02-06 Paolo Bonzini <bonzini@gnu.org>
* Makefile.in (tree-nested.o): Add pointer-set.h dependency.
* tree-nested.c: Include pointer-set.h.
(var_map_elt, var_map_eq, var_map_hash): Delete.
(struct nesting_info): Remove GTY marker. Change the two htab_t's
to pointer_map_t's.
(nesting_info_bitmap_obstack): New.
(lookup_field_for_decl): Adjust for pointer_map API.
(lookup_tramp_for_decl): Adjust for pointer_map API.
(get_nonlocal_debug_decl): Adjust for pointer_map API.
(get_local_debug_decl): Adjust for pointer_map API.
(convert_nl_goto_reference): Adjust for pointer_map API.
(convert_nl_goto_receiver): Adjust for pointer_map API.
(create_nesting_tree): Create outside GGC space. Create bitmap on
the new obstack. Create field_map and var_map as pointer_maps.
(free_nesting_tree): Adjust for changes to create_nesting_tree.
(root): Delete.
(lower_nested_functions): Move root here, no need to NULL it.
Initialize and release the obstack.
2007-02-06 Paolo Bonzini <bonzini@gnu.org> 2007-02-06 Paolo Bonzini <bonzini@gnu.org>
* tree.c (tree_int_map_hash, tree_int_map_eq, tree_int_map_marked_p): * tree.c (tree_int_map_hash, tree_int_map_eq, tree_int_map_marked_p):
......
...@@ -2055,7 +2055,7 @@ tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ ...@@ -2055,7 +2055,7 @@ tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \
$(DIAGNOSTIC_H) $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \ $(DIAGNOSTIC_H) $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \
$(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \ $(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \
$(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h $(HASHTAB_H) toplev.h \ $(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h toplev.h \
tree-ssa-propagate.h tree-ssa-propagate.h
tree-cfgcleanup.o : tree-cfgcleanup.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ tree-cfgcleanup.o : tree-cfgcleanup.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(FLAGS_H) output.h \
...@@ -2078,7 +2078,7 @@ tree-ssa-sink.o : tree-ssa-sink.c $(TREE_FLOW_H) $(CONFIG_H) \ ...@@ -2078,7 +2078,7 @@ tree-ssa-sink.o : tree-ssa-sink.c $(TREE_FLOW_H) $(CONFIG_H) \
tree-nested.o: tree-nested.c $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TREE_H) \ tree-nested.o: tree-nested.c $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TREE_H) \
$(RTL_H) $(TM_P_H) $(FUNCTION_H) $(TREE_DUMP_H) $(TREE_INLINE_H) \ $(RTL_H) $(TM_P_H) $(FUNCTION_H) $(TREE_DUMP_H) $(TREE_INLINE_H) \
tree-iterator.h $(TREE_GIMPLE_H) $(CGRAPH_H) $(EXPR_H) langhooks.h \ tree-iterator.h $(TREE_GIMPLE_H) $(CGRAPH_H) $(EXPR_H) langhooks.h \
$(GGC_H) gt-tree-nested.h coretypes.h $(TREE_FLOW_H) $(GGC_H) gt-tree-nested.h coretypes.h $(TREE_FLOW_H) pointer-set.h
tree-if-conv.o: tree-if-conv.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ tree-if-conv.o: tree-if-conv.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(FLAGS_H) $(TIMEVAR_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \ $(TREE_H) $(FLAGS_H) $(TIMEVAR_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
$(CFGLOOP_H) $(RTL_H) $(C_COMMON_H) tree-chrec.h $(TREE_DATA_REF_H) \ $(CFGLOOP_H) $(RTL_H) $(C_COMMON_H) tree-chrec.h $(TREE_DATA_REF_H) \
...@@ -2140,7 +2140,7 @@ tree-ssa-loop-ivopts.o : tree-ssa-loop-ivopts.c $(TREE_FLOW_H) $(CONFIG_H) \ ...@@ -2140,7 +2140,7 @@ tree-ssa-loop-ivopts.o : tree-ssa-loop-ivopts.c $(TREE_FLOW_H) $(CONFIG_H) \
output.h $(DIAGNOSTIC_H) $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \ output.h $(DIAGNOSTIC_H) $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
tree-pass.h $(GGC_H) $(RECOG_H) insn-config.h $(HASHTAB_H) $(SCEV_H) \ tree-pass.h $(GGC_H) $(RECOG_H) insn-config.h $(HASHTAB_H) $(SCEV_H) \
$(CFGLOOP_H) $(PARAMS_H) langhooks.h $(BASIC_BLOCK_H) hard-reg-set.h \ $(CFGLOOP_H) $(PARAMS_H) langhooks.h $(BASIC_BLOCK_H) hard-reg-set.h \
tree-chrec.h $(VARRAY_H) tree-affine.h tree-chrec.h $(VARRAY_H) tree-affine.h pointer-set.h
tree-affine.o : tree-affine.c tree-affine.h $(CONFIG_H) \ tree-affine.o : tree-affine.c tree-affine.h $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) \ $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) \
output.h $(DIAGNOSTIC_H) $(TM_H) coretypes.h $(TREE_DUMP_H) output.h $(DIAGNOSTIC_H) $(TM_H) coretypes.h $(TREE_DUMP_H)
...@@ -2167,7 +2167,7 @@ tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \ ...@@ -2167,7 +2167,7 @@ tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) errors.h $(TIMEVAR_H) \ $(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) errors.h $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) tree-iterator.h\ $(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) tree-iterator.h\
$(BASIC_BLOCK_H) $(TREE_GIMPLE_H) $(TREE_INLINE_H) vec.h \ $(BASIC_BLOCK_H) $(TREE_GIMPLE_H) $(TREE_INLINE_H) vec.h \
alloc-pool.h alloc-pool.h pointer-set.h
tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h $(DIAGNOSTIC_H) \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h $(DIAGNOSTIC_H) \
$(FLAGS_H) $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) toplev.h \ $(FLAGS_H) $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) toplev.h \
......
...@@ -44,7 +44,6 @@ Boston, MA 02110-1301, USA. */ ...@@ -44,7 +44,6 @@ Boston, MA 02110-1301, USA. */
#include "except.h" #include "except.h"
#include "cfgloop.h" #include "cfgloop.h"
#include "cfglayout.h" #include "cfglayout.h"
#include "hashtab.h"
#include "tree-ssa-propagate.h" #include "tree-ssa-propagate.h"
#include "value-prof.h" #include "value-prof.h"
#include "pointer-set.h" #include "pointer-set.h"
...@@ -70,19 +69,7 @@ static const int initial_cfg_capacity = 20; ...@@ -70,19 +69,7 @@ static const int initial_cfg_capacity = 20;
more persistent. The key is getting notification of changes to more persistent. The key is getting notification of changes to
the CFG (particularly edge removal, creation and redirection). */ the CFG (particularly edge removal, creation and redirection). */
struct edge_to_cases_elt static struct pointer_map_t *edge_to_cases;
{
/* The edge itself. Necessary for hashing and equality tests. */
edge e;
/* The case labels associated with this edge. We link these up via
their TREE_CHAIN field, then we wipe out the TREE_CHAIN fields
when we destroy the hash table. This prevents problems when copying
SWITCH_EXPRs. */
tree case_labels;
};
static htab_t edge_to_cases;
/* CFG statistics. */ /* CFG statistics. */
struct cfg_stats_d struct cfg_stats_d
...@@ -619,28 +606,6 @@ make_cond_expr_edges (basic_block bb) ...@@ -619,28 +606,6 @@ make_cond_expr_edges (basic_block bb)
} }
} }
/* Hashing routine for EDGE_TO_CASES. */
static hashval_t
edge_to_cases_hash (const void *p)
{
edge e = ((struct edge_to_cases_elt *)p)->e;
/* Hash on the edge itself (which is a pointer). */
return htab_hash_pointer (e);
}
/* Equality routine for EDGE_TO_CASES, edges are unique, so testing
for equality is just a pointer comparison. */
static int
edge_to_cases_eq (const void *p1, const void *p2)
{
edge e1 = ((struct edge_to_cases_elt *)p1)->e;
edge e2 = ((struct edge_to_cases_elt *)p2)->e;
return e1 == e2;
}
/* Called for each element in the hash table (P) as we delete the /* Called for each element in the hash table (P) as we delete the
edge to cases hash table. edge to cases hash table.
...@@ -649,18 +614,20 @@ edge_to_cases_eq (const void *p1, const void *p2) ...@@ -649,18 +614,20 @@ edge_to_cases_eq (const void *p1, const void *p2)
SWITCH_EXPRs and structure sharing rules, then free the hash table SWITCH_EXPRs and structure sharing rules, then free the hash table
element. */ element. */
static void static bool
edge_to_cases_cleanup (void *p) edge_to_cases_cleanup (void *key ATTRIBUTE_UNUSED, void **value,
void *data ATTRIBUTE_UNUSED)
{ {
struct edge_to_cases_elt *elt = (struct edge_to_cases_elt *) p;
tree t, next; tree t, next;
for (t = elt->case_labels; t; t = next) for (t = (tree) *value; t; t = next)
{ {
next = TREE_CHAIN (t); next = TREE_CHAIN (t);
TREE_CHAIN (t) = NULL; TREE_CHAIN (t) = NULL;
} }
free (p);
*value = NULL;
return false;
} }
/* Start recording information mapping edges to case labels. */ /* Start recording information mapping edges to case labels. */
...@@ -669,11 +636,7 @@ void ...@@ -669,11 +636,7 @@ void
start_recording_case_labels (void) start_recording_case_labels (void)
{ {
gcc_assert (edge_to_cases == NULL); gcc_assert (edge_to_cases == NULL);
edge_to_cases = pointer_map_create ();
edge_to_cases = htab_create (37,
edge_to_cases_hash,
edge_to_cases_eq,
edge_to_cases_cleanup);
} }
/* Return nonzero if we are recording information for case labels. */ /* Return nonzero if we are recording information for case labels. */
...@@ -689,46 +652,11 @@ recording_case_labels_p (void) ...@@ -689,46 +652,11 @@ recording_case_labels_p (void)
void void
end_recording_case_labels (void) end_recording_case_labels (void)
{ {
htab_delete (edge_to_cases); pointer_map_traverse (edge_to_cases, edge_to_cases_cleanup, NULL);
pointer_map_destroy (edge_to_cases);
edge_to_cases = NULL; edge_to_cases = NULL;
} }
/* Record that CASE_LABEL (a CASE_LABEL_EXPR) references edge E. */
static void
record_switch_edge (edge e, tree case_label)
{
struct edge_to_cases_elt *elt;
void **slot;
/* Build a hash table element so we can see if E is already
in the table. */
elt = XNEW (struct edge_to_cases_elt);
elt->e = e;
elt->case_labels = case_label;
slot = htab_find_slot (edge_to_cases, elt, INSERT);
if (*slot == NULL)
{
/* E was not in the hash table. Install E into the hash table. */
*slot = (void *)elt;
}
else
{
/* E was already in the hash table. Free ELT as we do not need it
anymore. */
free (elt);
/* Get the entry stored in the hash table. */
elt = (struct edge_to_cases_elt *) *slot;
/* Add it to the chain of CASE_LABEL_EXPRs referencing E. */
TREE_CHAIN (case_label) = elt->case_labels;
elt->case_labels = case_label;
}
}
/* If we are inside a {start,end}_recording_cases block, then return /* If we are inside a {start,end}_recording_cases block, then return
a chain of CASE_LABEL_EXPRs from T which reference E. a chain of CASE_LABEL_EXPRs from T which reference E.
...@@ -737,7 +665,6 @@ record_switch_edge (edge e, tree case_label) ...@@ -737,7 +665,6 @@ record_switch_edge (edge e, tree case_label)
static tree static tree
get_cases_for_edge (edge e, tree t) get_cases_for_edge (edge e, tree t)
{ {
struct edge_to_cases_elt elt, *elt_p;
void **slot; void **slot;
size_t i, n; size_t i, n;
tree vec; tree vec;
...@@ -747,16 +674,9 @@ get_cases_for_edge (edge e, tree t) ...@@ -747,16 +674,9 @@ get_cases_for_edge (edge e, tree t)
if (!recording_case_labels_p ()) if (!recording_case_labels_p ())
return NULL; return NULL;
restart: slot = pointer_map_contains (edge_to_cases, e);
elt.e = e;
elt.case_labels = NULL;
slot = htab_find_slot (edge_to_cases, &elt, NO_INSERT);
if (slot) if (slot)
{ return (tree) *slot;
elt_p = (struct edge_to_cases_elt *)*slot;
return elt_p->case_labels;
}
/* If we did not find E in the hash table, then this must be the first /* If we did not find E in the hash table, then this must be the first
time we have been queried for information about E & T. Add all the time we have been queried for information about E & T. Add all the
...@@ -766,11 +686,19 @@ restart: ...@@ -766,11 +686,19 @@ restart:
n = TREE_VEC_LENGTH (vec); n = TREE_VEC_LENGTH (vec);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
tree lab = CASE_LABEL (TREE_VEC_ELT (vec, i)); tree elt = TREE_VEC_ELT (vec, i);
tree lab = CASE_LABEL (elt);
basic_block label_bb = label_to_block (lab); basic_block label_bb = label_to_block (lab);
record_switch_edge (find_edge (e->src, label_bb), TREE_VEC_ELT (vec, i)); edge this_edge = find_edge (e->src, label_bb);
/* Add it to the chain of CASE_LABEL_EXPRs referencing E, or create
a new chain. */
slot = pointer_map_insert (edge_to_cases, this_edge);
TREE_CHAIN (elt) = (tree) *slot;
*slot = elt;
} }
goto restart;
return (tree) *pointer_map_contains (edge_to_cases, e);
} }
/* Create the edges for a SWITCH_EXPR starting at block BB. /* Create the edges for a SWITCH_EXPR starting at block BB.
......
...@@ -83,6 +83,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -83,6 +83,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "ggc.h" #include "ggc.h"
#include "insn-config.h" #include "insn-config.h"
#include "recog.h" #include "recog.h"
#include "pointer-set.h"
#include "hashtab.h" #include "hashtab.h"
#include "tree-chrec.h" #include "tree-chrec.h"
#include "tree-scalar-evolution.h" #include "tree-scalar-evolution.h"
...@@ -208,7 +209,7 @@ struct ivopts_data ...@@ -208,7 +209,7 @@ struct ivopts_data
unsigned regs_used; unsigned regs_used;
/* Numbers of iterations for all exits of the current loop. */ /* Numbers of iterations for all exits of the current loop. */
htab_t niters; struct pointer_map_t *niters;
/* The size of version_info array allocated. */ /* The size of version_info array allocated. */
unsigned version_info_size; unsigned version_info_size;
...@@ -673,58 +674,26 @@ contains_abnormal_ssa_name_p (tree expr) ...@@ -673,58 +674,26 @@ contains_abnormal_ssa_name_p (tree expr)
return false; return false;
} }
/* Element of the table in that we cache the numbers of iterations obtained
from exits of the loop. */
struct nfe_cache_elt
{
/* The edge for that the number of iterations is cached. */
edge exit;
/* Number of iterations corresponding to this exit, or NULL if it cannot be
determined. */
tree niter;
};
/* Hash function for nfe_cache_elt E. */
static hashval_t
nfe_hash (const void *e)
{
const struct nfe_cache_elt *elt = e;
return htab_hash_pointer (elt->exit);
}
/* Equality function for nfe_cache_elt E1 and edge E2. */
static int
nfe_eq (const void *e1, const void *e2)
{
const struct nfe_cache_elt *elt1 = e1;
return elt1->exit == e2;
}
/* Returns tree describing number of iterations determined from /* Returns tree describing number of iterations determined from
EXIT of DATA->current_loop, or NULL if something goes wrong. */ EXIT of DATA->current_loop, or NULL if something goes wrong. */
static tree static tree
niter_for_exit (struct ivopts_data *data, edge exit) niter_for_exit (struct ivopts_data *data, edge exit)
{ {
struct nfe_cache_elt *nfe_desc;
struct tree_niter_desc desc; struct tree_niter_desc desc;
PTR *slot; tree niter;
void **slot;
slot = htab_find_slot_with_hash (data->niters, exit,
htab_hash_pointer (exit),
INSERT);
if (!*slot) if (!data->niters)
{ {
nfe_desc = xmalloc (sizeof (struct nfe_cache_elt)); data->niters = pointer_map_create ();
nfe_desc->exit = exit; slot = NULL;
}
else
slot = pointer_map_contains (data->niters, exit);
if (!slot)
{
/* Try to determine number of iterations. We must know it /* Try to determine number of iterations. We must know it
unconditionally (i.e., without possibility of # of iterations unconditionally (i.e., without possibility of # of iterations
being zero). Also, we cannot safely work with ssa names that being zero). Also, we cannot safely work with ssa names that
...@@ -734,14 +703,16 @@ niter_for_exit (struct ivopts_data *data, edge exit) ...@@ -734,14 +703,16 @@ niter_for_exit (struct ivopts_data *data, edge exit)
exit, &desc, true) exit, &desc, true)
&& integer_zerop (desc.may_be_zero) && integer_zerop (desc.may_be_zero)
&& !contains_abnormal_ssa_name_p (desc.niter)) && !contains_abnormal_ssa_name_p (desc.niter))
nfe_desc->niter = desc.niter; niter = desc.niter;
else else
nfe_desc->niter = NULL_TREE; niter = NULL_TREE;
*pointer_map_insert (data->niters, exit) = niter;
} }
else else
nfe_desc = *slot; niter = *slot;
return nfe_desc->niter; return niter;
} }
/* Returns tree describing number of iterations determined from /* Returns tree describing number of iterations determined from
...@@ -770,7 +741,7 @@ tree_ssa_iv_optimize_init (struct ivopts_data *data) ...@@ -770,7 +741,7 @@ tree_ssa_iv_optimize_init (struct ivopts_data *data)
data->relevant = BITMAP_ALLOC (NULL); data->relevant = BITMAP_ALLOC (NULL);
data->important_candidates = BITMAP_ALLOC (NULL); data->important_candidates = BITMAP_ALLOC (NULL);
data->max_inv_id = 0; data->max_inv_id = 0;
data->niters = htab_create (10, nfe_hash, nfe_eq, free); data->niters = NULL;
data->iv_uses = VEC_alloc (iv_use_p, heap, 20); data->iv_uses = VEC_alloc (iv_use_p, heap, 20);
data->iv_candidates = VEC_alloc (iv_cand_p, heap, 20); data->iv_candidates = VEC_alloc (iv_cand_p, heap, 20);
decl_rtl_to_reset = VEC_alloc (tree, heap, 20); decl_rtl_to_reset = VEC_alloc (tree, heap, 20);
...@@ -5236,7 +5207,11 @@ free_loop_data (struct ivopts_data *data) ...@@ -5236,7 +5207,11 @@ free_loop_data (struct ivopts_data *data)
bitmap_iterator bi; bitmap_iterator bi;
tree obj; tree obj;
htab_empty (data->niters); if (data->niters)
{
pointer_map_destroy (data->niters);
data->niters = NULL;
}
EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi) EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
{ {
...@@ -5304,7 +5279,6 @@ tree_ssa_iv_optimize_finalize (struct ivopts_data *data) ...@@ -5304,7 +5279,6 @@ tree_ssa_iv_optimize_finalize (struct ivopts_data *data)
free (data->version_info); free (data->version_info);
BITMAP_FREE (data->relevant); BITMAP_FREE (data->relevant);
BITMAP_FREE (data->important_candidates); BITMAP_FREE (data->important_candidates);
htab_delete (data->niters);
VEC_free (tree, heap, decl_rtl_to_reset); VEC_free (tree, heap, decl_rtl_to_reset);
VEC_free (iv_use_p, heap, data->iv_uses); VEC_free (iv_use_p, heap, data->iv_uses);
...@@ -5320,6 +5294,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) ...@@ -5320,6 +5294,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop)
struct iv_ca *iv_ca; struct iv_ca *iv_ca;
edge exit; edge exit;
gcc_assert (!data->niters);
data->current_loop = loop; data->current_loop = loop;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
......
...@@ -38,6 +38,7 @@ Boston, MA 02110-1301, USA. */ ...@@ -38,6 +38,7 @@ Boston, MA 02110-1301, USA. */
#include "alloc-pool.h" #include "alloc-pool.h"
#include "vec.h" #include "vec.h"
#include "langhooks.h" #include "langhooks.h"
#include "pointer-set.h"
/* This is a simple global reassociation pass. It is, in part, based /* 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 on the LLVM pass of the same name (They do some things more/less
...@@ -179,68 +180,38 @@ static alloc_pool operand_entry_pool; ...@@ -179,68 +180,38 @@ static alloc_pool operand_entry_pool;
/* Starting rank number for a given basic block, so that we can rank /* Starting rank number for a given basic block, so that we can rank
operations using unmovable instructions in that BB based on the bb operations using unmovable instructions in that BB based on the bb
depth. */ depth. */
static unsigned int *bb_rank; static long *bb_rank;
/* Operand->rank hashtable. */ /* Operand->rank hashtable. */
static htab_t operand_rank; static struct pointer_map_t *operand_rank;
/* Look up the operand rank structure for expression E. */ /* Look up the operand rank structure for expression E. */
static operand_entry_t static inline long
find_operand_rank (tree e) find_operand_rank (tree e)
{ {
void **slot; void **slot = pointer_map_contains (operand_rank, e);
struct operand_entry vrd; return slot ? (long) *slot : -1;
vrd.op = e;
slot = htab_find_slot (operand_rank, &vrd, NO_INSERT);
if (!slot)
return NULL;
return ((operand_entry_t) *slot);
} }
/* Insert {E,RANK} into the operand rank hashtable. */ /* Insert {E,RANK} into the operand rank hashtable. */
static void static inline void
insert_operand_rank (tree e, unsigned int rank) insert_operand_rank (tree e, long rank)
{ {
void **slot; void **slot;
operand_entry_t new_pair = pool_alloc (operand_entry_pool); gcc_assert (rank > 0);
slot = pointer_map_insert (operand_rank, e);
new_pair->op = e; gcc_assert (!*slot);
new_pair->rank = rank; *slot = (void *) 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;
} }
/* Given an expression E, return the rank of the expression. */ /* Given an expression E, return the rank of the expression. */
static unsigned int static long
get_rank (tree e) get_rank (tree e)
{ {
operand_entry_t vr;
/* Constants have rank 0. */ /* Constants have rank 0. */
if (is_gimple_min_invariant (e)) if (is_gimple_min_invariant (e))
return 0; return 0;
...@@ -260,12 +231,12 @@ get_rank (tree e) ...@@ -260,12 +231,12 @@ get_rank (tree e)
{ {
tree stmt; tree stmt;
tree rhs; tree rhs;
unsigned int rank, maxrank; long rank, maxrank;
int i; int i;
if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL
&& SSA_NAME_IS_DEFAULT_DEF (e)) && SSA_NAME_IS_DEFAULT_DEF (e))
return find_operand_rank (e)->rank; return find_operand_rank (e);
stmt = SSA_NAME_DEF_STMT (e); stmt = SSA_NAME_DEF_STMT (e);
if (bb_for_stmt (stmt) == NULL) if (bb_for_stmt (stmt) == NULL)
...@@ -276,9 +247,9 @@ get_rank (tree e) ...@@ -276,9 +247,9 @@ get_rank (tree e)
return bb_rank[bb_for_stmt (stmt)->index]; return bb_rank[bb_for_stmt (stmt)->index];
/* If we already have a rank for this expression, use that. */ /* If we already have a rank for this expression, use that. */
vr = find_operand_rank (e); rank = find_operand_rank (e);
if (vr) if (rank != -1)
return vr->rank; return rank;
/* Otherwise, find the maximum rank for the operands, or the bb /* Otherwise, find the maximum rank for the operands, or the bb
rank, whichever is less. */ rank, whichever is less. */
...@@ -301,7 +272,7 @@ get_rank (tree e) ...@@ -301,7 +272,7 @@ get_rank (tree e)
{ {
fprintf (dump_file, "Rank for "); fprintf (dump_file, "Rank for ");
print_generic_expr (dump_file, e, 0); 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. */ /* Note the rank in the hashtable so we don't recompute it. */
...@@ -1417,7 +1388,7 @@ static void ...@@ -1417,7 +1388,7 @@ static void
init_reassoc (void) init_reassoc (void)
{ {
int i; int i;
unsigned int rank = 2; long rank = 2;
tree param; tree param;
int *bbs = XNEWVEC (int, last_basic_block + 1); int *bbs = XNEWVEC (int, last_basic_block + 1);
...@@ -1429,10 +1400,8 @@ init_reassoc (void) ...@@ -1429,10 +1400,8 @@ init_reassoc (void)
/* Reverse RPO (Reverse Post Order) will give us something where /* Reverse RPO (Reverse Post Order) will give us something where
deeper loops come later. */ deeper loops come later. */
pre_and_rev_post_order_compute (NULL, bbs, false); pre_and_rev_post_order_compute (NULL, bbs, false);
bb_rank = XCNEWVEC (unsigned int, last_basic_block + 1); bb_rank = XCNEWVEC (long, last_basic_block + 1);
operand_rank = pointer_map_create ();
operand_rank = htab_create (511, operand_entry_hash,
operand_entry_eq, 0);
/* Give each argument a distinct rank. */ /* Give each argument a distinct rank. */
for (param = DECL_ARGUMENTS (current_function_decl); for (param = DECL_ARGUMENTS (current_function_decl);
...@@ -1483,8 +1452,8 @@ fini_reassoc (void) ...@@ -1483,8 +1452,8 @@ fini_reassoc (void)
fprintf (dump_file, "Statements rewritten: %d\n", fprintf (dump_file, "Statements rewritten: %d\n",
reassociate_stats.rewritten); reassociate_stats.rewritten);
} }
htab_delete (operand_rank);
pointer_map_destroy (operand_rank);
free_alloc_pool (operand_entry_pool); free_alloc_pool (operand_entry_pool);
free (bb_rank); free (bb_rank);
VEC_free (tree, heap, broken_up_subtracts); VEC_free (tree, heap, broken_up_subtracts);
......
...@@ -2138,67 +2138,31 @@ solve_graph (constraint_graph_t graph) ...@@ -2138,67 +2138,31 @@ solve_graph (constraint_graph_t graph)
} }
/* Map from trees to variable infos. */ /* Map from trees to variable infos. */
static htab_t vi_for_tree; static struct pointer_map_t *vi_for_tree;
typedef struct tree_vi
{
tree t;
varinfo_t vi;
} *tree_vi_t;
/* Hash a tree id structure. */
static hashval_t
tree_vi_hash (const void *p)
{
const tree_vi_t ta = (tree_vi_t) p;
return htab_hash_pointer (ta->t);
}
/* Return true if the tree in P1 and the tree in P2 are the same. */
static int
tree_vi_eq (const void *p1, const void *p2)
{
const tree_vi_t ta1 = (tree_vi_t) p1;
const tree_vi_t ta2 = (tree_vi_t) p2;
return ta1->t == ta2->t;
}
/* Insert ID as the variable id for tree T in the hashtable. */ /* Insert ID as the variable id for tree T in the vi_for_tree map. */
static void static void
insert_vi_for_tree (tree t, varinfo_t vi) insert_vi_for_tree (tree t, varinfo_t vi)
{ {
void **slot; void **slot = pointer_map_insert (vi_for_tree, t);
struct tree_vi finder; gcc_assert (vi);
tree_vi_t new_pair;
finder.t = t;
slot = htab_find_slot (vi_for_tree, &finder, INSERT);
gcc_assert (*slot == NULL); gcc_assert (*slot == NULL);
new_pair = XNEW (struct tree_vi); *slot = vi;
new_pair->t = t;
new_pair->vi = vi;
*slot = (void *)new_pair;
} }
/* Find the variable info for tree T in VI_FOR_TREE. If T does not /* Find the variable info for tree T in VI_FOR_TREE. If T does not
exist in the hash table, return false, otherwise, return true and exist in the map, return NULL, otherwise, return the varinfo we found. */
set *VI to the varinfo we found. */
static bool static varinfo_t
lookup_vi_for_tree (tree t, varinfo_t *vi) lookup_vi_for_tree (tree t)
{ {
tree_vi_t pair; void **slot = pointer_map_contains (vi_for_tree, t);
struct tree_vi finder; if (slot == NULL)
return NULL;
finder.t = t; return (varinfo_t) *slot;
pair = htab_find (vi_for_tree, &finder);
if (pair == NULL)
return false;
*vi = pair->vi;
return true;
} }
/* Return a printable name for DECL */ /* Return a printable name for DECL */
...@@ -2235,21 +2199,17 @@ alias_get_name (tree decl) ...@@ -2235,21 +2199,17 @@ alias_get_name (tree decl)
return res; return res;
} }
/* Find the variable id for tree T in the hashtable. /* Find the variable id for tree T in the map.
If T doesn't exist in the hash table, create an entry for it. */ If T doesn't exist in the map, create an entry for it and return it. */
static varinfo_t static varinfo_t
get_vi_for_tree (tree t) get_vi_for_tree (tree t)
{ {
tree_vi_t pair; void **slot = pointer_map_contains (vi_for_tree, t);
struct tree_vi finder; if (slot == NULL)
finder.t = t;
pair = htab_find (vi_for_tree, &finder);
if (pair == NULL)
return get_varinfo (create_variable_info_for (t, alias_get_name (t))); return get_varinfo (create_variable_info_for (t, alias_get_name (t)));
return pair->vi; return (varinfo_t) *slot;
} }
/* Get a constraint expression from an SSA_VAR_P node. */ /* Get a constraint expression from an SSA_VAR_P node. */
...@@ -4383,9 +4343,9 @@ find_what_p_points_to (tree p) ...@@ -4383,9 +4343,9 @@ find_what_p_points_to (tree p)
&& SSA_NAME_IS_DEFAULT_DEF (p)) && SSA_NAME_IS_DEFAULT_DEF (p))
lookup_p = SSA_NAME_VAR (p); lookup_p = SSA_NAME_VAR (p);
if (lookup_vi_for_tree (lookup_p, &vi)) vi = lookup_vi_for_tree (lookup_p);
if (vi)
{ {
if (vi->is_artificial_var) if (vi->is_artificial_var)
return false; return false;
...@@ -4633,7 +4593,7 @@ init_alias_vars (void) ...@@ -4633,7 +4593,7 @@ init_alias_vars (void)
sizeof (struct variable_info), 30); sizeof (struct variable_info), 30);
constraints = VEC_alloc (constraint_t, heap, 8); constraints = VEC_alloc (constraint_t, heap, 8);
varmap = VEC_alloc (varinfo_t, heap, 8); varmap = VEC_alloc (varinfo_t, heap, 8);
vi_for_tree = htab_create (10, tree_vi_hash, tree_vi_eq, free); vi_for_tree = pointer_map_create ();
memset (&stats, 0, sizeof (stats)); memset (&stats, 0, sizeof (stats));
...@@ -4774,7 +4734,7 @@ delete_points_to_sets (void) ...@@ -4774,7 +4734,7 @@ delete_points_to_sets (void)
fprintf (dump_file, "Points to sets created:%d\n", fprintf (dump_file, "Points to sets created:%d\n",
stats.points_to_sets_created); stats.points_to_sets_created);
htab_delete (vi_for_tree); pointer_map_destroy (vi_for_tree);
bitmap_obstack_release (&pta_obstack); bitmap_obstack_release (&pta_obstack);
VEC_free (constraint_t, heap, constraints); VEC_free (constraint_t, heap, constraints);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment