Commit f3940b0e by Andrew MacLeod Committed by Andrew Macleod

re PR tree-optimization/18587 (build_v_may_defs and build_vuses can be improved when adding)



2005-10-05  Andrew MacLeod  <amacleod@redhat.com>

	PR tree-optimization/18587

	* tree-ssa-operands.c (struct opbuild_list_d, OPBUILD_LAST): Delete.
	(build_defs, build_uses, build_v_may_defs, build_v_must_defs,
	build_vuses): Change to VEC type.
	(opbuild_initialize_virtual, opbuild_initialize_real, opbuild_free,
	opbuild_num_elems, opbuild_append_real, opbuild_append_virtual,
	opbuild_first, opbuild_next, opbuild_elem_real, opbuild_elem_virtual,
	opbuild_elem_uid, opbuild_clear, opbuild_remove_elem): Delete.
	(get_name_decl): New.  Return DECL_UID of base variable.
	(operand_build_cmp): New.  qsort comparison routine.
	(operand_build_sort_virtual): New.  Sort virtual build vector.
	(init_ssa_operands, fini_ssa_operands): Use VEC routines.
	(FINALIZE_OPBUILD_BASE, FINALIZE_OPBUILD_ELEM): Use VEC_Index.
	(FINALIZE_BASE): Use get_name_decl.
	(finalize_ssa_defs, finalize_ssa_uses, cleanup_v_may_defs,
	finalize_ssa_v_may_defs, finalize_ssa_vuses, finalize_ssa_v_must_defs,
	(start_ssa_stmt_operands, append_def, append_use, append_vuse,
	append_v_may_def, append_v_must_def): Replace opbuild_* routines with
	direct VEC_* manipulations.
	(build_ssa_operands): Call operand_build_sort_virtual.
	(copy_virtual_operand, create_ssa_artficial_load_stmt,
	add_call_clobber_ops, add_call_read_ops): Replace opbuild_* routines
	with direct VEC_* manipulations.
	* tree-ssa-opfinalize.h (FINALIZE_FUNC): Replace opbuild_* routines
	with direct VEC manipulations.

From-SVN: r104996
parent 3015564c
2005-10-05 Andrew MacLeod <amacleod@redhat.com>
PR tree-optimization/18587
* tree-ssa-operands.c (struct opbuild_list_d, OPBUILD_LAST): Delete.
(build_defs, build_uses, build_v_may_defs, build_v_must_defs,
build_vuses): Change to VEC type.
(opbuild_initialize_virtual, opbuild_initialize_real, opbuild_free,
opbuild_num_elems, opbuild_append_real, opbuild_append_virtual,
opbuild_first, opbuild_next, opbuild_elem_real, opbuild_elem_virtual,
opbuild_elem_uid, opbuild_clear, opbuild_remove_elem): Delete.
(get_name_decl): New. Return DECL_UID of base variable.
(operand_build_cmp): New. qsort comparison routine.
(operand_build_sort_virtual): New. Sort virtual build vector.
(init_ssa_operands, fini_ssa_operands): Use VEC routines.
(FINALIZE_OPBUILD_BASE, FINALIZE_OPBUILD_ELEM): Use VEC_Index.
(FINALIZE_BASE): Use get_name_decl.
(finalize_ssa_defs, finalize_ssa_uses, cleanup_v_may_defs,
finalize_ssa_v_may_defs, finalize_ssa_vuses, finalize_ssa_v_must_defs,
(start_ssa_stmt_operands, append_def, append_use, append_vuse,
append_v_may_def, append_v_must_def): Replace opbuild_* routines with
direct VEC_* manipulations.
(build_ssa_operands): Call operand_build_sort_virtual.
(copy_virtual_operand, create_ssa_artficial_load_stmt,
add_call_clobber_ops, add_call_read_ops): Replace opbuild_* routines
with direct VEC_* manipulations.
* tree-ssa-opfinalize.h (FINALIZE_FUNC): Replace opbuild_* routines
with direct VEC manipulations.
2005-10-05 Paolo Bonzini <bonzini@gnu.org> 2005-10-05 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/21419 PR tree-optimization/21419
......
...@@ -103,34 +103,21 @@ Boston, MA 02110-1301, USA. */ ...@@ -103,34 +103,21 @@ Boston, MA 02110-1301, USA. */
to distinguish "reset the world" events from explicit MODIFY_EXPRs. */ to distinguish "reset the world" events from explicit MODIFY_EXPRs. */
#define opf_non_specific (1 << 3) #define opf_non_specific (1 << 3)
/* This structure maintain a sorted list of operands which is created by
parse_ssa_operand. */
struct opbuild_list_d GTY (())
{
varray_type vars; /* The VAR_DECLS tree. */
varray_type uid; /* The sort value for virtual symbols. */
varray_type next; /* The next index in the sorted list. */
int first; /* First element in list. */
unsigned num; /* Number of elements. */
};
#define OPBUILD_LAST -1
/* Array for building all the def operands. */ /* Array for building all the def operands. */
static GTY (()) struct opbuild_list_d build_defs; static VEC(tree,heap) *build_defs;
/* Array for building all the use operands. */ /* Array for building all the use operands. */
static GTY (()) struct opbuild_list_d build_uses; static VEC(tree,heap) *build_uses;
/* Array for building all the v_may_def operands. */ /* Array for building all the v_may_def operands. */
static GTY (()) struct opbuild_list_d build_v_may_defs; static VEC(tree,heap) *build_v_may_defs;
/* Array for building all the vuse operands. */ /* Array for building all the vuse operands. */
static GTY (()) struct opbuild_list_d build_vuses; static VEC(tree,heap) *build_vuses;
/* Array for building all the v_must_def operands. */ /* Array for building all the v_must_def operands. */
static GTY (()) struct opbuild_list_d build_v_must_defs; static VEC(tree,heap) *build_v_must_defs;
/* True if the operands for call clobbered vars are cached and valid. */ /* True if the operands for call clobbered vars are cached and valid. */
bool ssa_call_clobbered_cache_valid; bool ssa_call_clobbered_cache_valid;
...@@ -168,222 +155,65 @@ static vuse_optype_p free_vuses = NULL; ...@@ -168,222 +155,65 @@ static vuse_optype_p free_vuses = NULL;
static maydef_optype_p free_maydefs = NULL; static maydef_optype_p free_maydefs = NULL;
static mustdef_optype_p free_mustdefs = NULL; static mustdef_optype_p free_mustdefs = NULL;
/* Initialize a virtual operand build LIST called NAME with NUM elements. */
static inline void
opbuild_initialize_virtual (struct opbuild_list_d *list, int num,
const char *name)
{
list->first = OPBUILD_LAST;
list->num = 0;
VARRAY_TREE_INIT (list->vars, num, name);
VARRAY_UINT_INIT (list->uid, num, "List UID");
VARRAY_INT_INIT (list->next, num, "List NEXT");
}
/* Initialize a real operand build LIST called NAME with NUM elements. */
static inline void
opbuild_initialize_real (struct opbuild_list_d *list, int num, const char *name)
{
list->first = OPBUILD_LAST;
list->num = 0;
VARRAY_TREE_PTR_INIT (list->vars, num, name);
VARRAY_INT_INIT (list->next, num, "List NEXT");
/* The UID field is not needed since we sort based on the pointer value. */
list->uid = NULL;
}
/* Free memory used in virtual operand build object LIST. */ /* Return the DECL_UID of the base varaiable of T. */
static inline void
opbuild_free (struct opbuild_list_d *list)
{
list->vars = NULL;
list->uid = NULL;
list->next = NULL;
}
/* Number of elements in an opbuild list. */
static inline unsigned static inline unsigned
opbuild_num_elems (struct opbuild_list_d *list) get_name_decl (tree t)
{ {
return list->num; if (TREE_CODE (t) != SSA_NAME)
return DECL_UID (t);
else
return DECL_UID (SSA_NAME_VAR (t));
} }
/* Comparison function for qsort used in operand_build_sort_virtual. */
/* Add VAR to the real operand list LIST, keeping it sorted and avoiding static int
duplicates. The actual sort value is the tree pointer value. */ operand_build_cmp (const void *p, const void *q)
static inline void
opbuild_append_real (struct opbuild_list_d *list, tree *var)
{ {
int index; tree e1 = *((const tree *)p);
tree e2 = *((const tree *)q);
unsigned int u1,u2;
u1 = get_name_decl (e1);
u2 = get_name_decl (e2);
/* We want to sort in ascending order. They can never be equal. */
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
/* Ensure the real operand doesn't exist already. */ gcc_assert (u1 != u2);
for (index = list->first;
index != OPBUILD_LAST;
index = VARRAY_INT (list->next, index))
gcc_assert (VARRAY_TREE_PTR (list->vars, index) != var);
#endif #endif
return (u1 > u2 ? 1 : -1);
/* First item in the list. */
index = VARRAY_ACTIVE_SIZE (list->vars);
if (index == 0)
list->first = index;
else
VARRAY_INT (list->next, index - 1) = index;
VARRAY_PUSH_INT (list->next, OPBUILD_LAST);
VARRAY_PUSH_TREE_PTR (list->vars, var);
list->num++;
} }
/* Sort the virtual operands in LIST from lowest DECL_UID to highest. */
/* Add VAR to the virtual operand list LIST, keeping it sorted and avoiding
duplicates. The actual sort value is the DECL UID of the base variable. */
static inline void static inline void
opbuild_append_virtual (struct opbuild_list_d *list, tree var) operand_build_sort_virtual (VEC(tree,heap) *list)
{ {
int index, curr, last; int num = VEC_length (tree, list);
unsigned int var_uid; if (num < 2)
if (TREE_CODE (var) != SSA_NAME)
var_uid = DECL_UID (var);
else
var_uid = DECL_UID (SSA_NAME_VAR (var));
index = VARRAY_ACTIVE_SIZE (list->vars);
if (index == 0)
{
VARRAY_PUSH_TREE (list->vars, var);
VARRAY_PUSH_UINT (list->uid, var_uid);
VARRAY_PUSH_INT (list->next, OPBUILD_LAST);
list->first = 0;
list->num = 1;
return; return;
} if (num == 2)
last = OPBUILD_LAST;
/* Find the correct spot in the sorted list. */
for (curr = list->first;
curr != OPBUILD_LAST;
last = curr, curr = VARRAY_INT (list->next, curr))
{ {
if (VARRAY_UINT (list->uid, curr) > var_uid) if (get_name_decl (VEC_index (tree, list, 0))
break; > get_name_decl (VEC_index (tree, list, 1)))
}
if (last == OPBUILD_LAST)
{ {
/* First item in the list. */ /* Swap elements if in the wrong order. */
VARRAY_PUSH_INT (list->next, list->first); tree tmp = VEC_index (tree, list, 0);
list->first = index; VEC_replace (tree, list, 0, VEC_index (tree, list, 1));
VEC_replace (tree, list, 1, tmp);
} }
else
{
/* Don't enter duplicates at all. */
if (VARRAY_UINT (list->uid, last) == var_uid)
return; return;
VARRAY_PUSH_INT (list->next, VARRAY_INT (list->next, last));
VARRAY_INT (list->next, last) = index;
} }
VARRAY_PUSH_TREE (list->vars, var); /* There are 3 or more elements, call qsort. */
VARRAY_PUSH_UINT (list->uid, var_uid); qsort (VEC_address (tree, list),
list->num++; VEC_length (tree, list),
sizeof (tree),
operand_build_cmp);
} }
/* Return the first element index in LIST. OPBUILD_LAST means there are no
more elements. */
static inline int
opbuild_first (struct opbuild_list_d *list)
{
if (list->num > 0)
return list->first;
else
return OPBUILD_LAST;
}
/* Return the next element after PREV in LIST. */
static inline int
opbuild_next (struct opbuild_list_d *list, int prev)
{
return VARRAY_INT (list->next, prev);
}
/* Return the real element at index ELEM in LIST. */
static inline tree *
opbuild_elem_real (struct opbuild_list_d *list, int elem)
{
return VARRAY_TREE_PTR (list->vars, elem);
}
/* Return the virtual element at index ELEM in LIST. */
static inline tree
opbuild_elem_virtual (struct opbuild_list_d *list, int elem)
{
return VARRAY_TREE (list->vars, elem);
}
/* Return the virtual element uid at index ELEM in LIST. */
static inline unsigned int
opbuild_elem_uid (struct opbuild_list_d *list, int elem)
{
return VARRAY_UINT (list->uid, elem);
}
/* Reset an operand build list. */
static inline void
opbuild_clear (struct opbuild_list_d *list)
{
list->first = OPBUILD_LAST;
VARRAY_POP_ALL (list->vars);
VARRAY_POP_ALL (list->next);
if (list->uid)
VARRAY_POP_ALL (list->uid);
list->num = 0;
}
/* Remove ELEM from LIST where PREV is the previous element. Return the next
element. */
static inline int
opbuild_remove_elem (struct opbuild_list_d *list, int elem, int prev)
{
int ret;
if (prev != OPBUILD_LAST)
{
gcc_assert (VARRAY_INT (list->next, prev) == elem);
ret = VARRAY_INT (list->next, prev) = VARRAY_INT (list->next, elem);
}
else
{
gcc_assert (list->first == elem);
ret = list->first = VARRAY_INT (list->next, elem);
}
list->num--;
return ret;
}
/* Return true if the ssa operands cache is active. */ /* Return true if the ssa operands cache is active. */
...@@ -399,11 +229,12 @@ ssa_operands_active (void) ...@@ -399,11 +229,12 @@ ssa_operands_active (void)
void void
init_ssa_operands (void) init_ssa_operands (void)
{ {
opbuild_initialize_real (&build_defs, 5, "build defs"); build_defs = VEC_alloc (tree, heap, 5);
opbuild_initialize_real (&build_uses, 10, "build uses"); build_uses = VEC_alloc (tree, heap, 10);
opbuild_initialize_virtual (&build_vuses, 25, "build_vuses"); build_vuses = VEC_alloc (tree, heap, 25);
opbuild_initialize_virtual (&build_v_may_defs, 25, "build_v_may_defs"); build_v_may_defs = VEC_alloc (tree, heap, 25);
opbuild_initialize_virtual (&build_v_must_defs, 25, "build_v_must_defs"); build_v_must_defs = VEC_alloc (tree, heap, 25);
gcc_assert (operand_memory == NULL); gcc_assert (operand_memory == NULL);
operand_memory_index = SSA_OPERAND_MEMORY_SIZE; operand_memory_index = SSA_OPERAND_MEMORY_SIZE;
ops_active = true; ops_active = true;
...@@ -416,11 +247,11 @@ void ...@@ -416,11 +247,11 @@ void
fini_ssa_operands (void) fini_ssa_operands (void)
{ {
struct ssa_operand_memory_d *ptr; struct ssa_operand_memory_d *ptr;
opbuild_free (&build_defs); VEC_free (tree, heap, build_defs);
opbuild_free (&build_uses); VEC_free (tree, heap, build_uses);
opbuild_free (&build_v_must_defs); VEC_free (tree, heap, build_v_must_defs);
opbuild_free (&build_v_may_defs); VEC_free (tree, heap, build_v_may_defs);
opbuild_free (&build_vuses); VEC_free (tree, heap, build_vuses);
free_defs = NULL; free_defs = NULL;
free_uses = NULL; free_uses = NULL;
free_vuses = NULL; free_vuses = NULL;
...@@ -530,8 +361,10 @@ set_virtual_use_link (use_operand_p ptr, tree stmt) ...@@ -530,8 +361,10 @@ set_virtual_use_link (use_operand_p ptr, tree stmt)
#define FINALIZE_OPBUILD build_defs #define FINALIZE_OPBUILD build_defs
#define FINALIZE_OPBUILD_BASE(I) opbuild_elem_real (&build_defs, (I)) #define FINALIZE_OPBUILD_BASE(I) (tree *)VEC_index (tree, \
#define FINALIZE_OPBUILD_ELEM(I) opbuild_elem_real (&build_defs, (I)) build_defs, (I))
#define FINALIZE_OPBUILD_ELEM(I) (tree *)VEC_index (tree, \
build_defs, (I))
#define FINALIZE_FUNC finalize_ssa_def_ops #define FINALIZE_FUNC finalize_ssa_def_ops
#define FINALIZE_ALLOC alloc_def #define FINALIZE_ALLOC alloc_def
#define FINALIZE_FREE free_defs #define FINALIZE_FREE free_defs
...@@ -550,7 +383,7 @@ set_virtual_use_link (use_operand_p ptr, tree stmt) ...@@ -550,7 +383,7 @@ set_virtual_use_link (use_operand_p ptr, tree stmt)
static void static void
finalize_ssa_defs (tree stmt) finalize_ssa_defs (tree stmt)
{ {
unsigned int num = opbuild_num_elems (&build_defs); unsigned int num = VEC_length (tree, build_defs);
/* There should only be a single real definition per assignment. */ /* There should only be a single real definition per assignment. */
gcc_assert ((stmt && TREE_CODE (stmt) != MODIFY_EXPR) || num <= 1); gcc_assert ((stmt && TREE_CODE (stmt) != MODIFY_EXPR) || num <= 1);
...@@ -558,12 +391,14 @@ finalize_ssa_defs (tree stmt) ...@@ -558,12 +391,14 @@ finalize_ssa_defs (tree stmt)
find the elements at the beginning that are the same as the vector. */ find the elements at the beginning that are the same as the vector. */
finalize_ssa_def_ops (stmt); finalize_ssa_def_ops (stmt);
opbuild_clear (&build_defs); VEC_truncate (tree, build_defs, 0);
} }
#define FINALIZE_OPBUILD build_uses #define FINALIZE_OPBUILD build_uses
#define FINALIZE_OPBUILD_BASE(I) opbuild_elem_real (&build_uses, (I)) #define FINALIZE_OPBUILD_BASE(I) (tree *)VEC_index (tree, \
#define FINALIZE_OPBUILD_ELEM(I) opbuild_elem_real (&build_uses, (I)) build_uses, (I))
#define FINALIZE_OPBUILD_ELEM(I) (tree *)VEC_index (tree, \
build_uses, (I))
#define FINALIZE_FUNC finalize_ssa_use_ops #define FINALIZE_FUNC finalize_ssa_use_ops
#define FINALIZE_ALLOC alloc_use #define FINALIZE_ALLOC alloc_use
#define FINALIZE_FREE free_uses #define FINALIZE_FREE free_uses
...@@ -589,25 +424,26 @@ finalize_ssa_uses (tree stmt) ...@@ -589,25 +424,26 @@ finalize_ssa_uses (tree stmt)
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
{ {
unsigned x; unsigned x;
unsigned num = opbuild_num_elems (&build_uses); unsigned num = VEC_length (tree, build_uses);
/* If the pointer to the operand is the statement itself, something is /* If the pointer to the operand is the statement itself, something is
wrong. It means that we are pointing to a local variable (the wrong. It means that we are pointing to a local variable (the
initial call to get_stmt_operands does not pass a pointer to a initial call to get_stmt_operands does not pass a pointer to a
statement). */ statement). */
for (x = 0; x < num; x++) for (x = 0; x < num; x++)
gcc_assert (*(opbuild_elem_real (&build_uses, x)) != stmt); gcc_assert (*((tree *)VEC_index (tree, build_uses, x)) != stmt);
} }
#endif #endif
finalize_ssa_use_ops (stmt); finalize_ssa_use_ops (stmt);
opbuild_clear (&build_uses); VEC_truncate (tree, build_uses, 0);
} }
/* Return a new v_may_def operand vector for STMT, comparing to OLD_OPS_P. */ /* Return a new v_may_def operand vector for STMT, comparing to OLD_OPS_P. */
#define FINALIZE_OPBUILD build_v_may_defs #define FINALIZE_OPBUILD build_v_may_defs
#define FINALIZE_OPBUILD_ELEM(I) opbuild_elem_virtual (&build_v_may_defs, (I)) #define FINALIZE_OPBUILD_ELEM(I) VEC_index (tree, build_v_may_defs, (I))
#define FINALIZE_OPBUILD_BASE(I) opbuild_elem_uid (&build_v_may_defs, (I)) #define FINALIZE_OPBUILD_BASE(I) get_name_decl (VEC_index (tree, \
build_v_may_defs, (I)))
#define FINALIZE_FUNC finalize_ssa_v_may_def_ops #define FINALIZE_FUNC finalize_ssa_v_may_def_ops
#define FINALIZE_ALLOC alloc_maydef #define FINALIZE_ALLOC alloc_maydef
#define FINALIZE_FREE free_maydefs #define FINALIZE_FREE free_maydefs
...@@ -617,8 +453,7 @@ finalize_ssa_uses (tree stmt) ...@@ -617,8 +453,7 @@ finalize_ssa_uses (tree stmt)
#define FINALIZE_USE_PTR(PTR) MAYDEF_OP_PTR (PTR) #define FINALIZE_USE_PTR(PTR) MAYDEF_OP_PTR (PTR)
#define FINALIZE_CORRECT_USE set_virtual_use_link #define FINALIZE_CORRECT_USE set_virtual_use_link
#define FINALIZE_BASE_ZERO 0 #define FINALIZE_BASE_ZERO 0
#define FINALIZE_BASE(VAR) ((TREE_CODE (VAR) == SSA_NAME) \ #define FINALIZE_BASE(VAR) get_name_decl (VAR)
? DECL_UID (SSA_NAME_VAR (VAR)) : DECL_UID ((VAR)))
#define FINALIZE_BASE_TYPE unsigned #define FINALIZE_BASE_TYPE unsigned
#define FINALIZE_INITIALIZE(PTR, VAL, STMT) \ #define FINALIZE_INITIALIZE(PTR, VAL, STMT) \
(PTR)->def_var = (VAL); \ (PTR)->def_var = (VAL); \
...@@ -642,24 +477,25 @@ static inline void ...@@ -642,24 +477,25 @@ static inline void
cleanup_v_may_defs (void) cleanup_v_may_defs (void)
{ {
unsigned x, num; unsigned x, num;
num = opbuild_num_elems (&build_v_may_defs); num = VEC_length (tree, build_v_may_defs);
for (x = 0; x < num; x++) for (x = 0; x < num; x++)
{ {
tree t = opbuild_elem_virtual (&build_v_may_defs, x); tree t = VEC_index (tree, build_v_may_defs, x);
if (TREE_CODE (t) != SSA_NAME) if (TREE_CODE (t) != SSA_NAME)
{ {
var_ann_t ann = var_ann (t); var_ann_t ann = var_ann (t);
ann->in_v_may_def_list = 0; ann->in_v_may_def_list = 0;
} }
} }
opbuild_clear (&build_v_may_defs); VEC_truncate (tree, build_v_may_defs, 0);
} }
#define FINALIZE_OPBUILD build_vuses #define FINALIZE_OPBUILD build_vuses
#define FINALIZE_OPBUILD_ELEM(I) opbuild_elem_virtual (&build_vuses, (I)) #define FINALIZE_OPBUILD_ELEM(I) VEC_index (tree, build_vuses, (I))
#define FINALIZE_OPBUILD_BASE(I) opbuild_elem_uid (&build_vuses, (I)) #define FINALIZE_OPBUILD_BASE(I) get_name_decl (VEC_index (tree, \
build_vuses, (I)))
#define FINALIZE_FUNC finalize_ssa_vuse_ops #define FINALIZE_FUNC finalize_ssa_vuse_ops
#define FINALIZE_ALLOC alloc_vuse #define FINALIZE_ALLOC alloc_vuse
#define FINALIZE_FREE free_vuses #define FINALIZE_FREE free_vuses
...@@ -669,8 +505,7 @@ cleanup_v_may_defs (void) ...@@ -669,8 +505,7 @@ cleanup_v_may_defs (void)
#define FINALIZE_USE_PTR(PTR) VUSE_OP_PTR (PTR) #define FINALIZE_USE_PTR(PTR) VUSE_OP_PTR (PTR)
#define FINALIZE_CORRECT_USE set_virtual_use_link #define FINALIZE_CORRECT_USE set_virtual_use_link
#define FINALIZE_BASE_ZERO 0 #define FINALIZE_BASE_ZERO 0
#define FINALIZE_BASE(VAR) ((TREE_CODE (VAR) == SSA_NAME) \ #define FINALIZE_BASE(VAR) get_name_decl (VAR)
? DECL_UID (SSA_NAME_VAR (VAR)) : DECL_UID ((VAR)))
#define FINALIZE_BASE_TYPE unsigned #define FINALIZE_BASE_TYPE unsigned
#define FINALIZE_INITIALIZE(PTR, VAL, STMT) \ #define FINALIZE_INITIALIZE(PTR, VAL, STMT) \
(PTR)->use_var = (VAL); \ (PTR)->use_var = (VAL); \
...@@ -686,7 +521,7 @@ static void ...@@ -686,7 +521,7 @@ static void
finalize_ssa_vuses (tree stmt) finalize_ssa_vuses (tree stmt)
{ {
unsigned num, num_v_may_defs; unsigned num, num_v_may_defs;
int vuse_index; unsigned vuse_index;
/* Remove superfluous VUSE operands. If the statement already has a /* Remove superfluous VUSE operands. If the statement already has a
V_MAY_DEF operation for a variable 'a', then a VUSE for 'a' is not V_MAY_DEF operation for a variable 'a', then a VUSE for 'a' is not
...@@ -700,39 +535,35 @@ finalize_ssa_vuses (tree stmt) ...@@ -700,39 +535,35 @@ finalize_ssa_vuses (tree stmt)
The VUSE <a_2> is superfluous because it is implied by the V_MAY_DEF The VUSE <a_2> is superfluous because it is implied by the V_MAY_DEF
operation. */ operation. */
num = opbuild_num_elems (&build_vuses); num = VEC_length (tree, build_vuses);
num_v_may_defs = opbuild_num_elems (&build_v_may_defs); num_v_may_defs = VEC_length (tree, build_v_may_defs);
if (num > 0 && num_v_may_defs > 0) if (num > 0 && num_v_may_defs > 0)
{ {
int last = OPBUILD_LAST; for (vuse_index = 0; vuse_index < VEC_length (tree, build_vuses); )
vuse_index = opbuild_first (&build_vuses);
for ( ; vuse_index != OPBUILD_LAST; )
{ {
tree vuse; tree vuse;
vuse = opbuild_elem_virtual (&build_vuses, vuse_index); vuse = VEC_index (tree, build_vuses, vuse_index);
if (TREE_CODE (vuse) != SSA_NAME) if (TREE_CODE (vuse) != SSA_NAME)
{ {
var_ann_t ann = var_ann (vuse); var_ann_t ann = var_ann (vuse);
ann->in_vuse_list = 0; ann->in_vuse_list = 0;
if (ann->in_v_may_def_list) if (ann->in_v_may_def_list)
{ {
vuse_index = opbuild_remove_elem (&build_vuses, vuse_index, VEC_ordered_remove (tree, build_vuses, vuse_index);
last);
continue; continue;
} }
} }
last = vuse_index; vuse_index++;
vuse_index = opbuild_next (&build_vuses, vuse_index);
} }
} }
else else
/* Clear out the in_list bits. */ /* Clear out the in_list bits. */
for (vuse_index = opbuild_first (&build_vuses); for (vuse_index = 0;
vuse_index != OPBUILD_LAST; vuse_index < VEC_length (tree, build_vuses);
vuse_index = opbuild_next (&build_vuses, vuse_index)) vuse_index++)
{ {
tree t = opbuild_elem_virtual (&build_vuses, vuse_index); tree t = VEC_index (tree, build_vuses, vuse_index);
if (TREE_CODE (t) != SSA_NAME) if (TREE_CODE (t) != SSA_NAME)
{ {
var_ann_t ann = var_ann (t); var_ann_t ann = var_ann (t);
...@@ -745,15 +576,16 @@ finalize_ssa_vuses (tree stmt) ...@@ -745,15 +576,16 @@ finalize_ssa_vuses (tree stmt)
cleanup_v_may_defs (); cleanup_v_may_defs ();
/* Free the vuses build vector. */ /* Free the vuses build vector. */
opbuild_clear (&build_vuses); VEC_truncate (tree, build_vuses, 0);
} }
/* Return a new v_must_def operand vector for STMT, comparing to OLD_OPS_P. */ /* Return a new v_must_def operand vector for STMT, comparing to OLD_OPS_P. */
#define FINALIZE_OPBUILD build_v_must_defs #define FINALIZE_OPBUILD build_v_must_defs
#define FINALIZE_OPBUILD_ELEM(I) opbuild_elem_virtual (&build_v_must_defs, (I)) #define FINALIZE_OPBUILD_ELEM(I) VEC_index (tree, build_v_must_defs, (I))
#define FINALIZE_OPBUILD_BASE(I) opbuild_elem_uid (&build_v_must_defs, (I)) #define FINALIZE_OPBUILD_BASE(I) get_name_decl (VEC_index (tree, \
build_v_must_defs, (I)))
#define FINALIZE_FUNC finalize_ssa_v_must_def_ops #define FINALIZE_FUNC finalize_ssa_v_must_def_ops
#define FINALIZE_ALLOC alloc_mustdef #define FINALIZE_ALLOC alloc_mustdef
#define FINALIZE_FREE free_mustdefs #define FINALIZE_FREE free_mustdefs
...@@ -763,8 +595,7 @@ finalize_ssa_vuses (tree stmt) ...@@ -763,8 +595,7 @@ finalize_ssa_vuses (tree stmt)
#define FINALIZE_USE_PTR(PTR) MUSTDEF_KILL_PTR (PTR) #define FINALIZE_USE_PTR(PTR) MUSTDEF_KILL_PTR (PTR)
#define FINALIZE_CORRECT_USE set_virtual_use_link #define FINALIZE_CORRECT_USE set_virtual_use_link
#define FINALIZE_BASE_ZERO 0 #define FINALIZE_BASE_ZERO 0
#define FINALIZE_BASE(VAR) ((TREE_CODE (VAR) == SSA_NAME) \ #define FINALIZE_BASE(VAR) get_name_decl (VAR)
? DECL_UID (SSA_NAME_VAR (VAR)) : DECL_UID ((VAR)))
#define FINALIZE_BASE_TYPE unsigned #define FINALIZE_BASE_TYPE unsigned
#define FINALIZE_INITIALIZE(PTR, VAL, STMT) \ #define FINALIZE_INITIALIZE(PTR, VAL, STMT) \
(PTR)->def_var = (VAL); \ (PTR)->def_var = (VAL); \
...@@ -785,7 +616,7 @@ finalize_ssa_v_must_defs (tree stmt) ...@@ -785,7 +616,7 @@ finalize_ssa_v_must_defs (tree stmt)
having subvars, and have num >1, you have hit a bug. */ having subvars, and have num >1, you have hit a bug. */
finalize_ssa_v_must_def_ops (stmt); finalize_ssa_v_must_def_ops (stmt);
opbuild_clear (&build_v_must_defs); VEC_truncate (tree, build_v_must_defs, 0);
} }
...@@ -807,11 +638,11 @@ finalize_ssa_stmt_operands (tree stmt) ...@@ -807,11 +638,11 @@ finalize_ssa_stmt_operands (tree stmt)
static inline void static inline void
start_ssa_stmt_operands (void) start_ssa_stmt_operands (void)
{ {
gcc_assert (opbuild_num_elems (&build_defs) == 0); gcc_assert (VEC_length (tree, build_defs) == 0);
gcc_assert (opbuild_num_elems (&build_uses) == 0); gcc_assert (VEC_length (tree, build_uses) == 0);
gcc_assert (opbuild_num_elems (&build_vuses) == 0); gcc_assert (VEC_length (tree, build_vuses) == 0);
gcc_assert (opbuild_num_elems (&build_v_may_defs) == 0); gcc_assert (VEC_length (tree, build_v_may_defs) == 0);
gcc_assert (opbuild_num_elems (&build_v_must_defs) == 0); gcc_assert (VEC_length (tree, build_v_must_defs) == 0);
} }
...@@ -820,7 +651,7 @@ start_ssa_stmt_operands (void) ...@@ -820,7 +651,7 @@ start_ssa_stmt_operands (void)
static inline void static inline void
append_def (tree *def_p) append_def (tree *def_p)
{ {
opbuild_append_real (&build_defs, def_p); VEC_safe_push (tree, heap, build_defs, (tree)def_p);
} }
...@@ -829,7 +660,7 @@ append_def (tree *def_p) ...@@ -829,7 +660,7 @@ append_def (tree *def_p)
static inline void static inline void
append_use (tree *use_p) append_use (tree *use_p)
{ {
opbuild_append_real (&build_uses, use_p); VEC_safe_push (tree, heap, build_uses, (tree)use_p);
} }
...@@ -848,7 +679,7 @@ append_v_may_def (tree var) ...@@ -848,7 +679,7 @@ append_v_may_def (tree var)
ann->in_v_may_def_list = 1; ann->in_v_may_def_list = 1;
} }
opbuild_append_virtual (&build_v_may_defs, var); VEC_safe_push (tree, heap, build_v_may_defs, (tree)var);
} }
...@@ -868,7 +699,7 @@ append_vuse (tree var) ...@@ -868,7 +699,7 @@ append_vuse (tree var)
ann->in_vuse_list = 1; ann->in_vuse_list = 1;
} }
opbuild_append_virtual (&build_vuses, var); VEC_safe_push (tree, heap, build_vuses, (tree)var);
} }
...@@ -880,11 +711,11 @@ append_v_must_def (tree var) ...@@ -880,11 +711,11 @@ append_v_must_def (tree var)
unsigned i; unsigned i;
/* Don't allow duplicate entries. */ /* Don't allow duplicate entries. */
for (i = 0; i < opbuild_num_elems (&build_v_must_defs); i++) for (i = 0; i < VEC_length (tree, build_v_must_defs); i++)
if (var == opbuild_elem_virtual (&build_v_must_defs, i)) if (var == VEC_index (tree, build_v_must_defs, i))
return; return;
opbuild_append_virtual (&build_v_must_defs, var); VEC_safe_push (tree, heap, build_v_must_defs, (tree)var);
} }
...@@ -1014,6 +845,9 @@ build_ssa_operands (tree stmt) ...@@ -1014,6 +845,9 @@ build_ssa_operands (tree stmt)
start_ssa_stmt_operands (); start_ssa_stmt_operands ();
parse_ssa_operands (stmt); parse_ssa_operands (stmt);
operand_build_sort_virtual (build_vuses);
operand_build_sort_virtual (build_v_may_defs);
operand_build_sort_virtual (build_v_must_defs);
finalize_ssa_stmt_operands (stmt); finalize_ssa_stmt_operands (stmt);
} }
...@@ -1082,9 +916,9 @@ copy_virtual_operands (tree dest, tree src) ...@@ -1082,9 +916,9 @@ copy_virtual_operands (tree dest, tree src)
FOR_EACH_SSA_TREE_OPERAND (t, src, iter, SSA_OP_VMUSTDEF) FOR_EACH_SSA_TREE_OPERAND (t, src, iter, SSA_OP_VMUSTDEF)
append_v_must_def (t); append_v_must_def (t);
if (opbuild_num_elems (&build_vuses) == 0 if (VEC_length (tree, build_vuses) == 0
&& opbuild_num_elems (&build_v_may_defs) == 0 && VEC_length (tree, build_v_may_defs) == 0
&& opbuild_num_elems (&build_v_must_defs) == 0) && VEC_length (tree, build_v_must_defs) == 0)
return; return;
/* Now commit the virtual operands to this stmt. */ /* Now commit the virtual operands to this stmt. */
...@@ -1148,9 +982,9 @@ create_ssa_artficial_load_stmt (tree new_stmt, tree old_stmt) ...@@ -1148,9 +982,9 @@ create_ssa_artficial_load_stmt (tree new_stmt, tree old_stmt)
start_ssa_stmt_operands (); start_ssa_stmt_operands ();
parse_ssa_operands (new_stmt); parse_ssa_operands (new_stmt);
for (x = 0; x < opbuild_num_elems (&build_vuses); x++) for (x = 0; x < VEC_length (tree, build_vuses); x++)
{ {
tree t = opbuild_elem_virtual (&build_vuses, x); tree t = VEC_index (tree, build_vuses, x);
if (TREE_CODE (t) != SSA_NAME) if (TREE_CODE (t) != SSA_NAME)
{ {
var_ann_t ann = var_ann (t); var_ann_t ann = var_ann (t);
...@@ -1158,9 +992,9 @@ create_ssa_artficial_load_stmt (tree new_stmt, tree old_stmt) ...@@ -1158,9 +992,9 @@ create_ssa_artficial_load_stmt (tree new_stmt, tree old_stmt)
} }
} }
for (x = 0; x < opbuild_num_elems (&build_v_may_defs); x++) for (x = 0; x < VEC_length (tree, build_v_may_defs); x++)
{ {
tree t = opbuild_elem_virtual (&build_v_may_defs, x); tree t = VEC_index (tree, build_v_may_defs, x);
if (TREE_CODE (t) != SSA_NAME) if (TREE_CODE (t) != SSA_NAME)
{ {
var_ann_t ann = var_ann (t); var_ann_t ann = var_ann (t);
...@@ -1168,9 +1002,9 @@ create_ssa_artficial_load_stmt (tree new_stmt, tree old_stmt) ...@@ -1168,9 +1002,9 @@ create_ssa_artficial_load_stmt (tree new_stmt, tree old_stmt)
} }
} }
/* Remove any virtual operands that were found. */ /* Remove any virtual operands that were found. */
opbuild_clear (&build_v_may_defs); VEC_truncate (tree, build_v_may_defs, 0);
opbuild_clear (&build_v_must_defs); VEC_truncate (tree, build_v_must_defs, 0);
opbuild_clear (&build_vuses); VEC_truncate (tree, build_vuses, 0);
/* For each VDEF on the original statement, we want to create a /* For each VDEF on the original statement, we want to create a
VUSE of the V_MAY_DEF result or V_MUST_DEF op on the new VUSE of the V_MAY_DEF result or V_MUST_DEF op on the new
...@@ -1972,7 +1806,6 @@ add_to_addressable_set (tree ref, bitmap *addresses_taken) ...@@ -1972,7 +1806,6 @@ add_to_addressable_set (tree ref, bitmap *addresses_taken)
static void static void
add_call_clobber_ops (tree stmt, tree callee) add_call_clobber_ops (tree stmt, tree callee)
{ {
int i;
unsigned u; unsigned u;
tree t; tree t;
bitmap_iterator bi; bitmap_iterator bi;
...@@ -2010,21 +1843,19 @@ add_call_clobber_ops (tree stmt, tree callee) ...@@ -2010,21 +1843,19 @@ add_call_clobber_ops (tree stmt, tree callee)
&& (!not_read_b || bitmap_empty_p (not_read_b)) && (!not_read_b || bitmap_empty_p (not_read_b))
&& (!not_written_b || bitmap_empty_p (not_written_b))) && (!not_written_b || bitmap_empty_p (not_written_b)))
{ {
/* Process the caches in reverse order so we are always inserting at for (u = 0 ; u < VEC_length (tree, clobbered_vuses); u++)
the head of the list. */
for (i = VEC_length (tree, clobbered_vuses) - 1; i >=0; i--)
{ {
t = VEC_index (tree, clobbered_vuses, i); t = VEC_index (tree, clobbered_vuses, u);
gcc_assert (TREE_CODE (t) != SSA_NAME); gcc_assert (TREE_CODE (t) != SSA_NAME);
var_ann (t)->in_vuse_list = 1; var_ann (t)->in_vuse_list = 1;
opbuild_append_virtual (&build_vuses, t); VEC_safe_push (tree, heap, build_vuses, (tree)t);
} }
for (i = VEC_length (tree, clobbered_v_may_defs) - 1; i >= 0; i--) for (u = 0; u < VEC_length (tree, clobbered_v_may_defs); u++)
{ {
t = VEC_index (tree, clobbered_v_may_defs, i); t = VEC_index (tree, clobbered_v_may_defs, u);
gcc_assert (TREE_CODE (t) != SSA_NAME); gcc_assert (TREE_CODE (t) != SSA_NAME);
var_ann (t)->in_v_may_def_list = 1; var_ann (t)->in_v_may_def_list = 1;
opbuild_append_virtual (&build_v_may_defs, t); VEC_safe_push (tree, heap, build_v_may_defs, (tree)t);
} }
if (s_ann) if (s_ann)
{ {
...@@ -2079,22 +1910,18 @@ add_call_clobber_ops (tree stmt, tree callee) ...@@ -2079,22 +1910,18 @@ add_call_clobber_ops (tree stmt, tree callee)
VEC_truncate (tree, clobbered_v_may_defs, 0); VEC_truncate (tree, clobbered_v_may_defs, 0);
/* Now fill the clobbered cache with the values that have been found. */ /* Now fill the clobbered cache with the values that have been found. */
for (i = opbuild_first (&build_vuses); for (u = 0; u < VEC_length (tree, build_vuses); u++)
i != OPBUILD_LAST;
i = opbuild_next (&build_vuses, i))
VEC_safe_push (tree, heap, clobbered_vuses, VEC_safe_push (tree, heap, clobbered_vuses,
opbuild_elem_virtual (&build_vuses, i)); VEC_index (tree, build_vuses, u));
gcc_assert (opbuild_num_elems (&build_vuses) gcc_assert (VEC_length (tree, build_vuses)
== VEC_length (tree, clobbered_vuses)); == VEC_length (tree, clobbered_vuses));
for (i = opbuild_first (&build_v_may_defs); for (u = 0; u < VEC_length (tree, build_v_may_defs); u++)
i != OPBUILD_LAST;
i = opbuild_next (&build_v_may_defs, i))
VEC_safe_push (tree, heap, clobbered_v_may_defs, VEC_safe_push (tree, heap, clobbered_v_may_defs,
opbuild_elem_virtual (&build_v_may_defs, i)); VEC_index (tree, build_v_may_defs, u));
gcc_assert (opbuild_num_elems (&build_v_may_defs) gcc_assert (VEC_length (tree, build_v_may_defs)
== VEC_length (tree, clobbered_v_may_defs)); == VEC_length (tree, clobbered_v_may_defs));
ssa_call_clobbered_cache_valid = true; ssa_call_clobbered_cache_valid = true;
...@@ -2108,7 +1935,6 @@ add_call_clobber_ops (tree stmt, tree callee) ...@@ -2108,7 +1935,6 @@ add_call_clobber_ops (tree stmt, tree callee)
static void static void
add_call_read_ops (tree stmt) add_call_read_ops (tree stmt)
{ {
int i;
unsigned u; unsigned u;
tree t; tree t;
bitmap_iterator bi; bitmap_iterator bi;
...@@ -2127,14 +1953,12 @@ add_call_read_ops (tree stmt) ...@@ -2127,14 +1953,12 @@ add_call_read_ops (tree stmt)
/* If cache is valid, copy the elements into the build vector. */ /* If cache is valid, copy the elements into the build vector. */
if (ssa_ro_call_cache_valid) if (ssa_ro_call_cache_valid)
{ {
for (i = VEC_length (tree, ro_call_vuses) - 1; i >=0 ; i--) for (u = 0; u < VEC_length (tree, ro_call_vuses); u++)
{ {
/* Process the caches in reverse order so we are always inserting at t = VEC_index (tree, ro_call_vuses, u);
the head of the list. */
t = VEC_index (tree, ro_call_vuses, i);
gcc_assert (TREE_CODE (t) != SSA_NAME); gcc_assert (TREE_CODE (t) != SSA_NAME);
var_ann (t)->in_vuse_list = 1; var_ann (t)->in_vuse_list = 1;
opbuild_append_virtual (&build_vuses, t); VEC_safe_push (tree, heap, build_vuses, (tree)t);
} }
if (s_ann) if (s_ann)
s_ann->makes_aliased_loads = ro_call_aliased_loads; s_ann->makes_aliased_loads = ro_call_aliased_loads;
...@@ -2158,13 +1982,11 @@ add_call_read_ops (tree stmt) ...@@ -2158,13 +1982,11 @@ add_call_read_ops (tree stmt)
VEC_truncate (tree, ro_call_vuses, 0); VEC_truncate (tree, ro_call_vuses, 0);
/* Now fill the clobbered cache with the values that have been found. */ /* Now fill the clobbered cache with the values that have been found. */
for (i = opbuild_first (&build_vuses); for (u = 0; u < VEC_length (tree, build_vuses); u++)
i != OPBUILD_LAST;
i = opbuild_next (&build_vuses, i))
VEC_safe_push (tree, heap, ro_call_vuses, VEC_safe_push (tree, heap, ro_call_vuses,
opbuild_elem_virtual (&build_vuses, i)); VEC_index (tree, build_vuses, u));
gcc_assert (opbuild_num_elems (&build_vuses) gcc_assert (VEC_length (tree, build_vuses)
== VEC_length (tree, ro_call_vuses)); == VEC_length (tree, ro_call_vuses));
ssa_ro_call_cache_valid = true; ssa_ro_call_cache_valid = true;
......
...@@ -63,7 +63,7 @@ FINALIZE_ALLOC (void) ...@@ -63,7 +63,7 @@ FINALIZE_ALLOC (void)
static inline void static inline void
FINALIZE_FUNC (tree stmt) FINALIZE_FUNC (tree stmt)
{ {
int new_i; unsigned new_i;
FINALIZE_TYPE *old_ops, *ptr, *last; FINALIZE_TYPE *old_ops, *ptr, *last;
FINALIZE_BASE_TYPE old_base; FINALIZE_BASE_TYPE old_base;
FINALIZE_TYPE new_list; FINALIZE_TYPE new_list;
...@@ -77,8 +77,8 @@ FINALIZE_FUNC (tree stmt) ...@@ -77,8 +77,8 @@ FINALIZE_FUNC (tree stmt)
else else
old_base = FINALIZE_BASE_ZERO; old_base = FINALIZE_BASE_ZERO;
new_i = opbuild_first (&FINALIZE_OPBUILD); new_i = 0;
while (old_ops && new_i != OPBUILD_LAST) while (old_ops && new_i < VEC_length (tree, FINALIZE_OPBUILD))
{ {
FINALIZE_BASE_TYPE new_base = FINALIZE_OPBUILD_BASE (new_i); FINALIZE_BASE_TYPE new_base = FINALIZE_OPBUILD_BASE (new_i);
if (old_base == new_base) if (old_base == new_base)
...@@ -90,7 +90,7 @@ FINALIZE_FUNC (tree stmt) ...@@ -90,7 +90,7 @@ FINALIZE_FUNC (tree stmt)
FINALIZE_CORRECT_USE (FINALIZE_USE_PTR (last), stmt); FINALIZE_CORRECT_USE (FINALIZE_USE_PTR (last), stmt);
#endif #endif
old_ops = old_ops->next; old_ops = old_ops->next;
new_i = opbuild_next (&FINALIZE_OPBUILD, new_i); new_i++;
} }
else else
if (old_base < new_base) if (old_base < new_base)
...@@ -112,16 +112,14 @@ FINALIZE_FUNC (tree stmt) ...@@ -112,16 +112,14 @@ FINALIZE_FUNC (tree stmt)
FINALIZE_INITIALIZE (ptr, FINALIZE_OPBUILD_ELEM (new_i), stmt); FINALIZE_INITIALIZE (ptr, FINALIZE_OPBUILD_ELEM (new_i), stmt);
last->next = ptr; last->next = ptr;
last = ptr; last = ptr;
new_i = opbuild_next (&FINALIZE_OPBUILD, new_i); new_i++;
} }
if (old_ops) if (old_ops)
old_base = FINALIZE_BASE (FINALIZE_ELEM (old_ops)); old_base = FINALIZE_BASE (FINALIZE_ELEM (old_ops));
} }
/* If there is anything remaining in the opbuild list, simply emit them. */ /* If there is anything remaining in the opbuild list, simply emit them. */
for ( ; for ( ; new_i < VEC_length (tree, FINALIZE_OPBUILD); new_i++)
new_i != OPBUILD_LAST;
new_i = opbuild_next (&FINALIZE_OPBUILD, new_i))
{ {
ptr = FINALIZE_ALLOC (); ptr = FINALIZE_ALLOC ();
FINALIZE_INITIALIZE (ptr, FINALIZE_OPBUILD_ELEM (new_i), stmt); FINALIZE_INITIALIZE (ptr, FINALIZE_OPBUILD_ELEM (new_i), stmt);
...@@ -154,7 +152,7 @@ FINALIZE_FUNC (tree stmt) ...@@ -154,7 +152,7 @@ FINALIZE_FUNC (tree stmt)
for (ptr = FINALIZE_OPS (stmt); ptr; ptr = ptr->next) for (ptr = FINALIZE_OPS (stmt); ptr; ptr = ptr->next)
x++; x++;
gcc_assert (x == opbuild_num_elems (&FINALIZE_OPBUILD)); gcc_assert (x == VEC_length (tree, FINALIZE_OPBUILD));
} }
#endif #endif
} }
......
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