Commit 8184759d by Kazu Hirata Committed by Kazu Hirata

tree-ssa-dom.c (vrp_element_p): Define.

	* tree-ssa-dom.c (vrp_element_p): Define.
	(vrp_hash_elt): Change the type of records to
	VEC(vrp_element_p,heap).
	(vrp_free): New.
	(tree_ssa_dominator_optimize): Pass vrp_free to htab_create.
	Update uses of VRP records.
	(simplify_cond_and_lookup_avail_expr, record_range): Update
	uses of VRP records.

From-SVN: r100293
parent ddcf783b
2005-05-28 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-dom.c (vrp_element_p): Define.
(vrp_hash_elt): Change the type of records to
VEC(vrp_element_p,heap).
(vrp_free): New.
(tree_ssa_dominator_optimize): Pass vrp_free to htab_create.
Update uses of VRP records.
(simplify_cond_and_lookup_avail_expr, record_range): Update
uses of VRP records.
2005-05-27 Ian Lance Taylor <ian@airs.com> 2005-05-27 Ian Lance Taylor <ian@airs.com>
* c-decl.c (add_stmt): Add C frontend specific version. * c-decl.c (add_stmt): Add C frontend specific version.
......
...@@ -228,12 +228,17 @@ struct vrp_element ...@@ -228,12 +228,17 @@ struct vrp_element
with useful information is very low. */ with useful information is very low. */
static htab_t vrp_data; static htab_t vrp_data;
typedef struct vrp_element *vrp_element_p;
DEF_VEC_P(vrp_element_p);
DEF_VEC_ALLOC_P(vrp_element_p,heap);
/* An entry in the VRP_DATA hash table. We record the variable and a /* An entry in the VRP_DATA hash table. We record the variable and a
varray of VRP_ELEMENT records associated with that variable. */ varray of VRP_ELEMENT records associated with that variable. */
struct vrp_hash_elt struct vrp_hash_elt
{ {
tree var; tree var;
varray_type records; VEC(vrp_element_p,heap) *records;
}; };
/* Array of variables which have their values constrained by operations /* Array of variables which have their values constrained by operations
...@@ -350,6 +355,18 @@ free_all_edge_infos (void) ...@@ -350,6 +355,18 @@ free_all_edge_infos (void)
} }
} }
/* Free an instance of vrp_hash_elt. */
static void
vrp_free (void *data)
{
struct vrp_hash_elt *elt = data;
struct VEC(vrp_element_p,heap) **vrp_elt = &elt->records;
VEC_free (vrp_element_p, heap, *vrp_elt);
free (elt);
}
/* Jump threading, redundancy elimination and const/copy propagation. /* Jump threading, redundancy elimination and const/copy propagation.
This pass may expose new symbols that need to be renamed into SSA. For This pass may expose new symbols that need to be renamed into SSA. For
...@@ -367,7 +384,8 @@ tree_ssa_dominator_optimize (void) ...@@ -367,7 +384,8 @@ tree_ssa_dominator_optimize (void)
/* Create our hash tables. */ /* Create our hash tables. */
avail_exprs = htab_create (1024, real_avail_expr_hash, avail_expr_eq, free); avail_exprs = htab_create (1024, real_avail_expr_hash, avail_expr_eq, free);
vrp_data = htab_create (ceil_log2 (num_ssa_names), vrp_hash, vrp_eq, free); vrp_data = htab_create (ceil_log2 (num_ssa_names), vrp_hash, vrp_eq,
vrp_free);
avail_exprs_stack = VEC_alloc (tree, heap, 20); avail_exprs_stack = VEC_alloc (tree, heap, 20);
const_and_copies_stack = VEC_alloc (tree, heap, 20); const_and_copies_stack = VEC_alloc (tree, heap, 20);
nonzero_vars_stack = VEC_alloc (tree, heap, 20); nonzero_vars_stack = VEC_alloc (tree, heap, 20);
...@@ -1116,7 +1134,7 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb) ...@@ -1116,7 +1134,7 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
the array backwards popping off records associated with our the array backwards popping off records associated with our
block. Once we hit a record not associated with our block block. Once we hit a record not associated with our block
we are done. */ we are done. */
varray_type var_vrp_records; VEC(vrp_element_p,heap) **var_vrp_records;
if (var == NULL) if (var == NULL)
break; break;
...@@ -1127,17 +1145,17 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb) ...@@ -1127,17 +1145,17 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
slot = htab_find_slot (vrp_data, &vrp_hash_elt, NO_INSERT); slot = htab_find_slot (vrp_data, &vrp_hash_elt, NO_INSERT);
vrp_hash_elt_p = (struct vrp_hash_elt *) *slot; vrp_hash_elt_p = (struct vrp_hash_elt *) *slot;
var_vrp_records = vrp_hash_elt_p->records; var_vrp_records = &vrp_hash_elt_p->records;
while (VARRAY_ACTIVE_SIZE (var_vrp_records) > 0) while (VEC_length (vrp_element_p, *var_vrp_records) > 0)
{ {
struct vrp_element *element struct vrp_element *element
= (struct vrp_element *)VARRAY_TOP_GENERIC_PTR (var_vrp_records); = VEC_last (vrp_element_p, *var_vrp_records);
if (element->bb != bb) if (element->bb != bb)
break; break;
VARRAY_POP (var_vrp_records); VEC_pop (vrp_element_p, *var_vrp_records);
} }
} }
...@@ -2041,7 +2059,7 @@ simplify_cond_and_lookup_avail_expr (tree stmt, ...@@ -2041,7 +2059,7 @@ simplify_cond_and_lookup_avail_expr (tree stmt,
int limit; int limit;
tree low, high, cond_low, cond_high; tree low, high, cond_low, cond_high;
int lowequal, highequal, swapped, no_overlap, subset, cond_inverted; int lowequal, highequal, swapped, no_overlap, subset, cond_inverted;
varray_type vrp_records; VEC(vrp_element_p,heap) **vrp_records;
struct vrp_element *element; struct vrp_element *element;
struct vrp_hash_elt vrp_hash_elt, *vrp_hash_elt_p; struct vrp_hash_elt vrp_hash_elt, *vrp_hash_elt_p;
void **slot; void **slot;
...@@ -2094,11 +2112,9 @@ simplify_cond_and_lookup_avail_expr (tree stmt, ...@@ -2094,11 +2112,9 @@ simplify_cond_and_lookup_avail_expr (tree stmt,
return NULL; return NULL;
vrp_hash_elt_p = (struct vrp_hash_elt *) *slot; vrp_hash_elt_p = (struct vrp_hash_elt *) *slot;
vrp_records = vrp_hash_elt_p->records; vrp_records = &vrp_hash_elt_p->records;
if (vrp_records == NULL)
return NULL;
limit = VARRAY_ACTIVE_SIZE (vrp_records); limit = VEC_length (vrp_element_p, *vrp_records);
/* If we have no value range records for this variable, or we are /* If we have no value range records for this variable, or we are
unable to extract a range for this condition, then there is unable to extract a range for this condition, then there is
...@@ -2130,8 +2146,7 @@ simplify_cond_and_lookup_avail_expr (tree stmt, ...@@ -2130,8 +2146,7 @@ simplify_cond_and_lookup_avail_expr (tree stmt,
conditional into the current range. conditional into the current range.
These properties also help us avoid unnecessary work. */ These properties also help us avoid unnecessary work. */
element element = VEC_last (vrp_element_p, *vrp_records);
= (struct vrp_element *)VARRAY_GENERIC_PTR (vrp_records, limit - 1);
if (element->high && element->low) if (element->high && element->low)
{ {
...@@ -2170,8 +2185,7 @@ simplify_cond_and_lookup_avail_expr (tree stmt, ...@@ -2170,8 +2185,7 @@ simplify_cond_and_lookup_avail_expr (tree stmt,
{ {
/* Get the high/low value from the previous element. */ /* Get the high/low value from the previous element. */
struct vrp_element *prev struct vrp_element *prev
= (struct vrp_element *)VARRAY_GENERIC_PTR (vrp_records, = VEC_index (vrp_element_p, *vrp_records, limit - 2);
limit - 2);
low = prev->low; low = prev->low;
high = prev->high; high = prev->high;
...@@ -3311,7 +3325,7 @@ record_range (tree cond, basic_block bb) ...@@ -3311,7 +3325,7 @@ record_range (tree cond, basic_block bb)
{ {
struct vrp_hash_elt *vrp_hash_elt; struct vrp_hash_elt *vrp_hash_elt;
struct vrp_element *element; struct vrp_element *element;
varray_type *vrp_records_p; VEC(vrp_element_p,heap) **vrp_records_p;
void **slot; void **slot;
...@@ -3323,7 +3337,7 @@ record_range (tree cond, basic_block bb) ...@@ -3323,7 +3337,7 @@ record_range (tree cond, basic_block bb)
if (*slot == NULL) if (*slot == NULL)
*slot = (void *) vrp_hash_elt; *slot = (void *) vrp_hash_elt;
else else
free (vrp_hash_elt); vrp_free (vrp_hash_elt);
vrp_hash_elt = (struct vrp_hash_elt *) *slot; vrp_hash_elt = (struct vrp_hash_elt *) *slot;
vrp_records_p = &vrp_hash_elt->records; vrp_records_p = &vrp_hash_elt->records;
...@@ -3334,10 +3348,7 @@ record_range (tree cond, basic_block bb) ...@@ -3334,10 +3348,7 @@ record_range (tree cond, basic_block bb)
element->cond = cond; element->cond = cond;
element->bb = bb; element->bb = bb;
if (*vrp_records_p == NULL) VEC_safe_push (vrp_element_p, heap, *vrp_records_p, element);
VARRAY_GENERIC_PTR_INIT (*vrp_records_p, 2, "vrp records");
VARRAY_PUSH_GENERIC_PTR (*vrp_records_p, element);
VEC_safe_push (tree, heap, vrp_variables_stack, TREE_OPERAND (cond, 0)); VEC_safe_push (tree, heap, vrp_variables_stack, TREE_OPERAND (cond, 0));
} }
} }
......
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