Commit 1af4bba8 by Jan Hubicka Committed by Jan Hubicka

tree-ssa-alias.c (eq_ptr_info, [...]): New function.

	* tree-ssa-alias.c (eq_ptr_info, ptr_info_hash): New function.
	(create_name_tags): Instead of quadratic checking use hashtable.
	* bitmap.h: Include hashtab.h.
	(bitmap_hash): Declare.
	* bitmap.c (bitmap_hash): New function.

From-SVN: r116285
parent 70d539ce
2006-08-20 Jan Hubicka <jh@suse.cz> 2006-08-20 Jan Hubicka <jh@suse.cz>
* tree-ssa-alias.c (eq_ptr_info, ptr_info_hash): New function.
(create_name_tags): Instead of quadratic checking use hashtable.
* bitmap.h: Include hashtab.h.
(bitmap_hash): Declare.
* bitmap.c (bitmap_hash): New function.
2006-08-20 Jan Hubicka <jh@suse.cz>
PR rtl-optimization/28071 PR rtl-optimization/28071
* tree-optimize.c (tree_rest_of_compilation): Do not remove edges * tree-optimize.c (tree_rest_of_compilation): Do not remove edges
twice. twice.
......
...@@ -1520,4 +1520,21 @@ bitmap_print (FILE *file, bitmap head, const char *prefix, const char *suffix) ...@@ -1520,4 +1520,21 @@ bitmap_print (FILE *file, bitmap head, const char *prefix, const char *suffix)
fputs (suffix, file); fputs (suffix, file);
} }
/* Compute hash of bitmap (for purposes of hashing). */
hashval_t
bitmap_hash (bitmap head)
{
bitmap_element *ptr;
BITMAP_WORD hash = 0;
int ix;
for (ptr = head->first; ptr; ptr = ptr->next)
{
hash ^= ptr->indx;
for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
hash ^= ptr->bits[ix];
}
return (hashval_t)hash;
}
#include "gt-bitmap.h" #include "gt-bitmap.h"
...@@ -21,6 +21,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -21,6 +21,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#ifndef GCC_BITMAP_H #ifndef GCC_BITMAP_H
#define GCC_BITMAP_H #define GCC_BITMAP_H
#include "hashtab.h"
/* Fundamental storage type for bitmap. */ /* Fundamental storage type for bitmap. */
...@@ -164,6 +165,9 @@ extern void bitmap_obstack_free (bitmap); ...@@ -164,6 +165,9 @@ extern void bitmap_obstack_free (bitmap);
#define bitmap_zero(a) bitmap_clear (a) #define bitmap_zero(a) bitmap_clear (a)
extern unsigned bitmap_first_set_bit (bitmap); extern unsigned bitmap_first_set_bit (bitmap);
/* Compute bitmap hash (for purposes of hashing etc.) */
extern hashval_t bitmap_hash(bitmap);
/* Allocate a bitmap from a bit obstack. */ /* Allocate a bitmap from a bit obstack. */
#define BITMAP_ALLOC(OBSTACK) bitmap_obstack_alloc (OBSTACK) #define BITMAP_ALLOC(OBSTACK) bitmap_obstack_alloc (OBSTACK)
......
...@@ -987,6 +987,23 @@ delete_alias_info (struct alias_info *ai) ...@@ -987,6 +987,23 @@ delete_alias_info (struct alias_info *ai)
delete_points_to_sets (); delete_points_to_sets ();
} }
/* Used for hashing to identify pointer infos with identical
pt_vars bitmaps. */
static int
eq_ptr_info (const void *p1, const void *p2)
{
const struct ptr_info_def *n1 = (const struct ptr_info_def *) p1;
const struct ptr_info_def *n2 = (const struct ptr_info_def *) p2;
return bitmap_equal_p (n1->pt_vars, n2->pt_vars);
}
static hashval_t
ptr_info_hash (const void *p)
{
const struct ptr_info_def *n = (const struct ptr_info_def *) p;
return bitmap_hash (n->pt_vars);
}
/* Create name tags for all the pointers that have been dereferenced. /* Create name tags for all the pointers that have been dereferenced.
We only create a name tag for a pointer P if P is found to point to We only create a name tag for a pointer P if P is found to point to
a set of variables (so that we can alias them to *P) or if it is a set of variables (so that we can alias them to *P) or if it is
...@@ -1002,6 +1019,7 @@ create_name_tags (void) ...@@ -1002,6 +1019,7 @@ create_name_tags (void)
size_t i; size_t i;
VEC (tree, heap) *with_ptvars = NULL; VEC (tree, heap) *with_ptvars = NULL;
tree ptr; tree ptr;
htab_t ptr_hash;
/* Collect the list of pointers with a non-empty points to set. */ /* Collect the list of pointers with a non-empty points to set. */
for (i = 1; i < num_ssa_names; i++) for (i = 1; i < num_ssa_names; i++)
...@@ -1036,15 +1054,15 @@ create_name_tags (void) ...@@ -1036,15 +1054,15 @@ create_name_tags (void)
if (!with_ptvars) if (!with_ptvars)
return; return;
ptr_hash = htab_create (10, ptr_info_hash, eq_ptr_info, NULL);
/* Now go through the pointers with pt_vars, and find a name tag /* Now go through the pointers with pt_vars, and find a name tag
with the same pt_vars as this pointer, or create one if one with the same pt_vars as this pointer, or create one if one
doesn't exist. */ doesn't exist. */
for (i = 0; VEC_iterate (tree, with_ptvars, i, ptr); i++) for (i = 0; VEC_iterate (tree, with_ptvars, i, ptr); i++)
{ {
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr); struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
size_t j;
tree ptr2;
tree old_name_tag = pi->name_mem_tag; tree old_name_tag = pi->name_mem_tag;
struct ptr_info_def **slot;
/* If PTR points to a set of variables, check if we don't /* If PTR points to a set of variables, check if we don't
have another pointer Q with the same points-to set before have another pointer Q with the same points-to set before
...@@ -1057,21 +1075,18 @@ create_name_tags (void) ...@@ -1057,21 +1075,18 @@ create_name_tags (void)
problems if they both had different name tags because problems if they both had different name tags because
they would have different SSA version numbers (which they would have different SSA version numbers (which
would force us to take the name tags in and out of SSA). */ would force us to take the name tags in and out of SSA). */
for (j = 0; j < i && VEC_iterate (tree, with_ptvars, j, ptr2); j++)
{
struct ptr_info_def *qi = SSA_NAME_PTR_INFO (ptr2);
if (bitmap_equal_p (pi->pt_vars, qi->pt_vars)) slot = (struct ptr_info_def **) htab_find_slot (ptr_hash, pi, INSERT);
if (*slot)
pi->name_mem_tag = (*slot)->name_mem_tag;
else
{ {
pi->name_mem_tag = qi->name_mem_tag; *slot = pi;
break;
}
}
/* If we didn't find a pointer with the same points-to set /* If we didn't find a pointer with the same points-to set
as PTR, create a new name tag if needed. */ as PTR, create a new name tag if needed. */
if (pi->name_mem_tag == NULL_TREE) if (pi->name_mem_tag == NULL_TREE)
pi->name_mem_tag = get_nmt_for (ptr); pi->name_mem_tag = get_nmt_for (ptr);
}
/* If the new name tag computed for PTR is different than /* If the new name tag computed for PTR is different than
the old name tag that it used to have, then the old tag the old name tag that it used to have, then the old tag
...@@ -1086,6 +1101,7 @@ create_name_tags (void) ...@@ -1086,6 +1101,7 @@ create_name_tags (void)
/* Mark the new name tag for renaming. */ /* Mark the new name tag for renaming. */
mark_sym_for_renaming (pi->name_mem_tag); mark_sym_for_renaming (pi->name_mem_tag);
} }
htab_delete (ptr_hash);
VEC_free (tree, heap, with_ptvars); VEC_free (tree, heap, with_ptvars);
} }
......
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