Paolo Bonzini - [PATCH 1/5]: Use pointer_map in ivopts (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
- From: Paolo Bonzini
- To: GCC Patches
- Date: Tue, 06 Feb 2007 13:46:13 +0100
- Subject: [PATCH 1/5]: Use pointer_map in ivopts
The interesting thing here is that the value can be NULL; for this reason we cannot use *pointer_map_insert(map, key) being NULL as a test that KEY was not in MAP. So in the pointer_map case we must always check first for the presence of the value, and then insert it if it was absent.In addition to this, since there is no pointer_map_delete, a separate pointer_map is created for every loop.Bootstrapped C/C++/Ada/Java (Fortran is broken) on i686-pc-linux-gnu, ok for mainline?Paolo
2006-02-06 Paolo Bonzini bonzini@gnu.org
* Makefile.in (tree-ssa-loop-ivopts.o): Add pointer-set.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.
Index: Makefile.in
--- Makefile.in (revision 121601)
+++ Makefile.in (working copy)
@@ -2140,7 +2140,7 @@ tree-ssa-loop-ivopts.o : tree-ssa-loop-i
output.h (DIAGNOSTICH)(DIAGNOSTIC_H) (DIAGNOSTICH)(TIMEVAR_H) (TMH)coretypes.h(TM_H) coretypes.h (TMH)coretypes.h(TREE_DUMP_H)
tree-pass.h (GGCH)(GGC_H) (GGCH)(RECOG_H) insn-config.h (HASHTABH)(HASHTAB_H) (HASHTABH)(SCEV_H)
(CFGLOOPH)(CFGLOOP_H) (CFGLOOPH)(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)
(SYSTEMH)(SYSTEM_H) (SYSTEMH)(RTL_H) (TREEH)(TREE_H) (TREEH)(TM_P_H)
output.h (DIAGNOSTICH)(DIAGNOSTIC_H) (DIAGNOSTICH)(TM_H) coretypes.h $(TREE_DUMP_H)
Index: tree-ssa-loop-ivopts.c
--- tree-ssa-loop-ivopts.c (revision 121601) +++ tree-ssa-loop-ivopts.c (working copy) @@ -83,6 +83,7 @@ Software Foundation, 51 Franklin Street, #include "ggc.h" #include "insn-config.h" #include "recog.h" +#include "pointer-set.h" #include "hashtab.h" #include "tree-chrec.h" #include "tree-scalar-evolution.h" @@ -208,7 +209,7 @@ struct ivopts_data unsigned regs_used; /* 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. / unsigned version_info_size; @@ -673,58 +674,26 @@ contains_abnormal_ssa_name_p (tree expr) 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 EXIT of DATA->current_loop, or NULL if something goes wrong. */ static tree niter_for_exit (struct ivopts_data *data, edge exit) {
- struct nfe_cache_elt *nfe_desc; struct tree_niter_desc desc;
- PTR *slot;
- slot = htab_find_slot_with_hash (data->niters, exit,
htab_hash_pointer (exit),
INSERT);
- tree niter;
- void **slot;
- if (!*slot)
- if (!data->niters) {
nfe_desc = xmalloc (sizeof (struct nfe_cache_elt));
nfe_desc->exit = exit;
data->niters = pointer_map_create ();
slot = NULL;
}
else
slot = pointer_map_contains (data->niters, exit);
if (!slot)
{ /* Try to determine number of iterations. We must know it unconditionally (i.e., without possibility of # of iterations being zero). Also, we cannot safely work with ssa names that @@ -734,14 +703,16 @@ niter_for_exit (struct ivopts_data *data exit, &desc, true) && integer_zerop (desc.may_be_zero) && !contains_abnormal_ssa_name_p (desc.niter))
- nfe_desc->niter = desc.niter;
- niter = desc.niter; else
- nfe_desc->niter = NULL_TREE;
- niter = NULL_TREE;
} else*pointer_map_insert (data->niters, exit) = niter;
- nfe_desc = *slot;
- niter = *slot;
- return nfe_desc->niter;
- return niter; }
/* Returns tree describing number of iterations determined from @@ -770,7 +741,7 @@ tree_ssa_iv_optimize_init (struct ivopts data->relevant = BITMAP_ALLOC (NULL); data->important_candidates = BITMAP_ALLOC (NULL); 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_candidates = VEC_alloc (iv_cand_p, heap, 20); decl_rtl_to_reset = VEC_alloc (tree, heap, 20); @@ -5236,7 +5207,11 @@ free_loop_data (struct ivopts_data *data bitmap_iterator bi; 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) { @@ -5304,7 +5279,6 @@ tree_ssa_iv_optimize_finalize (struct iv free (data->version_info); BITMAP_FREE (data->relevant); BITMAP_FREE (data->important_candidates);
htab_delete (data->niters);
VEC_free (tree, heap, decl_rtl_to_reset); VEC_free (iv_use_p, heap, data->iv_uses);
@@ -5320,6 +5294,7 @@ tree_ssa_iv_optimize_loop (struct ivopts struct iv_ca *iv_ca; edge exit;
gcc_assert (!data->niters); data->current_loop = loop;
if (dump_file && (dump_flags & TDF_DETAILS))
- Follow-Ups:
- Re: [PATCH 1/5]: Use pointer_map in ivopts
* From: Diego Novillo
- Re: [PATCH 1/5]: Use pointer_map in ivopts
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |