Commit fdd43ac4 by Richard Biener Committed by Richard Biener

tree-scalar-evolution.c (scev_info_hasher): Remove.

2013-05-02  Richard Biener  <rguenther@suse.de>

	* tree-scalar-evolution.c (scev_info_hasher): Remove.
	(struct instantiate_cache_entry): New type.
	(struct instantiate_cache_entry_hasher): New hashtable descriptor.
	(struct instantiate_cache_type): New type.
	(set_instantiated_value, get_instantiated_value): Remove.
	(get_instantiated_value_entry): New function.
	(instantiate_scev_name): Use the new cache and adjust.
	(instantiate_scev_poly): Adjust.
	(instantiate_scev_binary): Likewise.
	(instantiate_array_ref): Likewise.
	(instantiate_scev_convert): Likewise.
	(instantiate_scev_not): Likewise.
	(instantiate_scev_3): Likewise.
	(instantiate_scev_2): Likewise.
	(instantiate_scev_r): Likewise.
	(instantiate_scev): Likewise.
	(resolve_mixers): Likewise.

From-SVN: r198523
parent b273e79b
2013-05-02 Richard Biener <rguenther@suse.de>
* tree-scalar-evolution.c (scev_info_hasher): Remove.
(struct instantiate_cache_entry): New type.
(struct instantiate_cache_entry_hasher): New hashtable descriptor.
(struct instantiate_cache_type): New type.
(set_instantiated_value, get_instantiated_value): Remove.
(get_instantiated_value_entry): New function.
(instantiate_scev_name): Use the new cache and adjust.
(instantiate_scev_poly): Adjust.
(instantiate_scev_binary): Likewise.
(instantiate_array_ref): Likewise.
(instantiate_scev_convert): Likewise.
(instantiate_scev_not): Likewise.
(instantiate_scev_3): Likewise.
(instantiate_scev_2): Likewise.
(instantiate_scev_r): Likewise.
(instantiate_scev): Likewise.
(resolve_mixers): Likewise.
2013-05-01 Vladimir Makarov <vmakarov@redhat.com> 2013-05-01 Vladimir Makarov <vmakarov@redhat.com>
PR target/57091 PR target/57091
......
...@@ -344,38 +344,6 @@ del_scev_info (void *e) ...@@ -344,38 +344,6 @@ del_scev_info (void *e)
ggc_free (e); ggc_free (e);
} }
/* Hashtable helpers. */
struct scev_info_hasher
{
typedef scev_info_str value_type;
typedef scev_info_str compare_type;
static inline hashval_t hash (const value_type *);
static inline bool equal (const value_type *, const compare_type *);
static inline void remove (value_type *);
};
inline hashval_t
scev_info_hasher::hash (const value_type *elt)
{
return hash_scev_info (elt);
}
inline bool
scev_info_hasher::equal (const value_type *elt1, const compare_type *elt2)
{
return eq_scev_info (elt1, elt2);
}
/* Deletes database element E. */
inline void
scev_info_hasher::remove (value_type *e)
{
del_scev_info (e);
}
typedef hash_table <scev_info_hasher> scev_info_hash_table_type;
/* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block. /* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block.
A first query on VAR returns chrec_not_analyzed_yet. */ A first query on VAR returns chrec_not_analyzed_yet. */
...@@ -2078,43 +2046,87 @@ analyze_scalar_evolution_in_loop (struct loop *wrto_loop, struct loop *use_loop, ...@@ -2078,43 +2046,87 @@ analyze_scalar_evolution_in_loop (struct loop *wrto_loop, struct loop *use_loop,
} }
} }
/* Returns from CACHE the value for VERSION instantiated below
INSTANTIATED_BELOW block. */
static tree /* Hashtable helpers for a temporary hash-table used when
get_instantiated_value (scev_info_hash_table_type cache, instantiating a CHREC or resolving mixers. For this use
basic_block instantiated_below, tree version) instantiated_below is always the same. */
struct instantiate_cache_entry
{ {
struct scev_info_str *info, pattern; tree name;
tree chrec;
};
pattern.var = version; struct instantiate_cache_entry_hasher : typed_noop_remove <uintptr_t>
pattern.instantiated_below = instantiated_below; {
info = cache.find (&pattern); typedef uintptr_t value_type;
typedef instantiate_cache_entry compare_type;
static inline hashval_t hash (const value_type *);
static inline bool equal (const value_type *, const compare_type *);
};
if (info) struct instantiate_cache_type
return info->chrec; {
else hash_table <instantiate_cache_entry_hasher> htab;
return NULL_TREE; vec<instantiate_cache_entry> entries;
~instantiate_cache_type ();
};
instantiate_cache_type::~instantiate_cache_type ()
{
if (htab.is_created ())
{
htab.dispose ();
entries.release ();
}
} }
/* Sets in CACHE the value of VERSION instantiated below basic block static instantiate_cache_type *ctbl;
INSTANTIATED_BELOW to VAL. */
static void inline hashval_t
set_instantiated_value (scev_info_hash_table_type cache, instantiate_cache_entry_hasher::hash (const value_type *idx)
basic_block instantiated_below, tree version, tree val)
{ {
struct scev_info_str *info, pattern; instantiate_cache_entry *elt
scev_info_str **slot; = &ctbl->entries[reinterpret_cast <uintptr_t> (idx) - 2];
return SSA_NAME_VERSION (elt->name);
}
inline bool
instantiate_cache_entry_hasher::equal (const value_type *idx1,
const compare_type *elt2)
{
compare_type *elt1 = &ctbl->entries[reinterpret_cast <uintptr_t> (idx1) - 2];
return elt1->name == elt2->name;
}
pattern.var = version; /* Returns from CACHE a pointer to the cached chrec for NAME. */
pattern.instantiated_below = instantiated_below;
slot = cache.find_slot (&pattern, INSERT);
static tree *
get_instantiated_value_entry (instantiate_cache_type &cache, tree name)
{
struct instantiate_cache_entry e;
uintptr_t **slot;
if (!cache.htab.is_created ())
{
cache.htab.create (10);
cache.entries.create (10);
}
ctbl = &cache;
e.name = name;
slot = cache.htab.find_slot_with_hash (&e, SSA_NAME_VERSION (name), INSERT);
if (!*slot) if (!*slot)
*slot = new_scev_info_str (instantiated_below, version); {
info = *slot; e.chrec = chrec_not_analyzed_yet;
info->chrec = val; cache.entries.safe_push (e);
*slot = reinterpret_cast <uintptr_t *>
((uintptr_t) cache.entries.length () + 1);
}
return &cache.entries[reinterpret_cast <uintptr_t> (*slot) - 2].chrec;
} }
/* Return the closed_loop_phi node for VAR. If there is none, return /* Return the closed_loop_phi node for VAR. If there is none, return
...@@ -2148,7 +2160,7 @@ loop_closed_phi_def (tree var) ...@@ -2148,7 +2160,7 @@ loop_closed_phi_def (tree var)
} }
static tree instantiate_scev_r (basic_block, struct loop *, struct loop *, static tree instantiate_scev_r (basic_block, struct loop *, struct loop *,
tree, bool, scev_info_hash_table_type, int); tree, bool, instantiate_cache_type &, int);
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
and EVOLUTION_LOOP, that were left under a symbolic form. and EVOLUTION_LOOP, that were left under a symbolic form.
...@@ -2168,7 +2180,7 @@ static tree ...@@ -2168,7 +2180,7 @@ static tree
instantiate_scev_name (basic_block instantiate_below, instantiate_scev_name (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree res; tree res;
...@@ -2191,12 +2203,13 @@ instantiate_scev_name (basic_block instantiate_below, ...@@ -2191,12 +2203,13 @@ instantiate_scev_name (basic_block instantiate_below,
| a_2 -> {0, +, 1, +, a_2}_1 */ | a_2 -> {0, +, 1, +, a_2}_1 */
res = get_instantiated_value (cache, instantiate_below, chrec); tree *si;
if (res) si = get_instantiated_value_entry (cache, chrec);
return res; if (*si != chrec_not_analyzed_yet)
return *si;
res = chrec_dont_know; /* On recursion return chrec_dont_know. */
set_instantiated_value (cache, instantiate_below, chrec, res); *si = chrec_dont_know;
def_loop = find_common_loop (evolution_loop, def_bb->loop_father); def_loop = find_common_loop (evolution_loop, def_bb->loop_father);
...@@ -2249,7 +2262,7 @@ instantiate_scev_name (basic_block instantiate_below, ...@@ -2249,7 +2262,7 @@ instantiate_scev_name (basic_block instantiate_below,
} }
/* Store the correct value to the cache. */ /* Store the correct value to the cache. */
set_instantiated_value (cache, instantiate_below, chrec, res); *si = res;
return res; return res;
} }
...@@ -2271,7 +2284,7 @@ static tree ...@@ -2271,7 +2284,7 @@ static tree
instantiate_scev_poly (basic_block instantiate_below, instantiate_scev_poly (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *, struct loop *evolution_loop, struct loop *,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree op1; tree op1;
...@@ -2318,7 +2331,8 @@ instantiate_scev_binary (basic_block instantiate_below, ...@@ -2318,7 +2331,8 @@ instantiate_scev_binary (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, enum tree_code code, tree chrec, enum tree_code code,
tree type, tree c0, tree c1, tree type, tree c0, tree c1,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions,
instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree op1; tree op1;
...@@ -2378,7 +2392,7 @@ static tree ...@@ -2378,7 +2392,7 @@ static tree
instantiate_array_ref (basic_block instantiate_below, instantiate_array_ref (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree res; tree res;
...@@ -2419,7 +2433,7 @@ instantiate_scev_convert (basic_block instantiate_below, ...@@ -2419,7 +2433,7 @@ instantiate_scev_convert (basic_block instantiate_below,
tree chrec, tree chrec,
tree type, tree op, tree type, tree op,
bool fold_conversions, bool fold_conversions,
scev_info_hash_table_type cache, int size_expr) instantiate_cache_type &cache, int size_expr)
{ {
tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
inner_loop, op, inner_loop, op,
...@@ -2468,7 +2482,7 @@ instantiate_scev_not (basic_block instantiate_below, ...@@ -2468,7 +2482,7 @@ instantiate_scev_not (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
enum tree_code code, tree type, tree op, enum tree_code code, tree type, tree op,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
...@@ -2518,7 +2532,7 @@ static tree ...@@ -2518,7 +2532,7 @@ static tree
instantiate_scev_3 (basic_block instantiate_below, instantiate_scev_3 (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree op1, op2; tree op1, op2;
...@@ -2567,7 +2581,7 @@ static tree ...@@ -2567,7 +2581,7 @@ static tree
instantiate_scev_2 (basic_block instantiate_below, instantiate_scev_2 (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree op1; tree op1;
...@@ -2608,7 +2622,7 @@ static tree ...@@ -2608,7 +2622,7 @@ static tree
instantiate_scev_1 (basic_block instantiate_below, instantiate_scev_1 (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
...@@ -2642,7 +2656,7 @@ static tree ...@@ -2642,7 +2656,7 @@ static tree
instantiate_scev_r (basic_block instantiate_below, instantiate_scev_r (basic_block instantiate_below,
struct loop *evolution_loop, struct loop *inner_loop, struct loop *evolution_loop, struct loop *inner_loop,
tree chrec, tree chrec,
bool fold_conversions, scev_info_hash_table_type cache, bool fold_conversions, instantiate_cache_type &cache,
int size_expr) int size_expr)
{ {
/* Give up if the expression is larger than the MAX that we allow. */ /* Give up if the expression is larger than the MAX that we allow. */
...@@ -2749,8 +2763,7 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop, ...@@ -2749,8 +2763,7 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop,
tree chrec) tree chrec)
{ {
tree res; tree res;
scev_info_hash_table_type cache; instantiate_cache_type cache;
cache.create (10);
if (dump_file && (dump_flags & TDF_SCEV)) if (dump_file && (dump_flags & TDF_SCEV))
{ {
...@@ -2772,8 +2785,6 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop, ...@@ -2772,8 +2785,6 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop,
fprintf (dump_file, "))\n"); fprintf (dump_file, "))\n");
} }
cache.dispose ();
return res; return res;
} }
...@@ -2785,11 +2796,9 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop, ...@@ -2785,11 +2796,9 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop,
tree tree
resolve_mixers (struct loop *loop, tree chrec) resolve_mixers (struct loop *loop, tree chrec)
{ {
scev_info_hash_table_type cache; instantiate_cache_type cache;
cache.create (10);
tree ret = instantiate_scev_r (block_before_loop (loop), loop, NULL, tree ret = instantiate_scev_r (block_before_loop (loop), loop, NULL,
chrec, true, cache, 0); chrec, true, cache, 0);
cache.dispose ();
return ret; return ret;
} }
......
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