Commit 3aecd08b by Jeff Law Committed by Jeff Law

tree-ssa-ccp.c (get_default_value): Use SSA_NAME_VALUE rather than…

tree-ssa-ccp.c (get_default_value): Use SSA_NAME_VALUE rather than SSA_NAME_EQUIV and SET_SSA_NAME_EQUIV.


	* tree-ssa-ccp.c (get_default_value): Use SSA_NAME_VALUE rather
	than SSA_NAME_EQUIV and SET_SSA_NAME_EQUIV.
	(substitute_and_fold):  Likewise.
	* tree-ssa-dom.c (tree_ssa_dominator_optimize): Remove everything
	except invariants from SSA_NAME_VALUE.
	(thread_across_edge): Use SSA_NAME_VALUE rather than SSA_NAME_EQUIV
	and SET_SSA_NAME_EQUIV.
	(restore_vars_to_original_value, record_const_or_copy): Likewise.
	(record_equivalences_from_phis, record_const_or_copy_1): Likewise.
	(record_equality, cprop_into_successor_phis): Likewise.
	(record_equivalences_from_stmt, cprop_operand): Likewise.
	(lookup_avail_expr): Likewise.
	* tree-ssa-pre.c (fini_pre): Remove everything except invariants
	from SSA_NAME_VALUE.
	* tree.h (SSA_NAME_EQUIV, SET_SSA_NAME_EQUIV): Kill.
	(struct tree_ssa_name):  Kill EQUIV field.  Remove GGC skip
	annotation from the VALUE_HANDLE field.

From-SVN: r87979
parent 0c482362
2004-09-23 Jeff Law <law@redhat.com>
* tree-ssa-ccp.c (get_default_value): Use SSA_NAME_VALUE rather
than SSA_NAME_EQUIV and SET_SSA_NAME_EQUIV.
(substitute_and_fold): Likewise.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Remove everything
except invariants from SSA_NAME_VALUE.
(thread_across_edge): Use SSA_NAME_VALUE rather than SSA_NAME_EQUIV
and SET_SSA_NAME_EQUIV.
(restore_vars_to_original_value, record_const_or_copy): Likewise.
(record_equivalences_from_phis, record_const_or_copy_1): Likewise.
(record_equality, cprop_into_successor_phis): Likewise.
(record_equivalences_from_stmt, cprop_operand): Likewise.
(lookup_avail_expr): Likewise.
* tree-ssa-pre.c (fini_pre): Remove everything except invariants
from SSA_NAME_VALUE.
* tree.h (SSA_NAME_EQUIV, SET_SSA_NAME_EQUIV): Kill.
(struct tree_ssa_name): Kill EQUIV field. Remove GGC skip
annotation from the VALUE_HANDLE field.
2004-09-21 Fariborz Jahanian <fjahanian@apple.com> 2004-09-21 Fariborz Jahanian <fjahanian@apple.com>
PR c++/13989 PR c++/13989
PR c++/9844 PR c++/9844
......
...@@ -136,11 +136,11 @@ get_default_value (tree var) ...@@ -136,11 +136,11 @@ get_default_value (tree var)
val.const_val = NULL_TREE; val.const_val = NULL_TREE;
if (TREE_CODE (var) == SSA_NAME if (TREE_CODE (var) == SSA_NAME
&& SSA_NAME_EQUIV (var) && SSA_NAME_VALUE (var)
&& is_gimple_min_invariant (SSA_NAME_EQUIV (var))) && is_gimple_min_invariant (SSA_NAME_VALUE (var)))
{ {
val.lattice_val = CONSTANT; val.lattice_val = CONSTANT;
val.const_val = SSA_NAME_EQUIV (var); val.const_val = SSA_NAME_VALUE (var);
} }
else if (TREE_CODE (sym) == PARM_DECL || TREE_THIS_VOLATILE (sym)) else if (TREE_CODE (sym) == PARM_DECL || TREE_THIS_VOLATILE (sym))
{ {
...@@ -611,7 +611,7 @@ substitute_and_fold (void) ...@@ -611,7 +611,7 @@ substitute_and_fold (void)
if (value->lattice_val == CONSTANT if (value->lattice_val == CONSTANT
&& is_gimple_reg (name) && is_gimple_reg (name)
&& is_gimple_min_invariant (value->const_val)) && is_gimple_min_invariant (value->const_val))
SET_SSA_NAME_EQUIV (name, value->const_val) SSA_NAME_VALUE (name) = value->const_val;
} }
} }
......
...@@ -404,6 +404,24 @@ tree_ssa_dominator_optimize (void) ...@@ -404,6 +404,24 @@ tree_ssa_dominator_optimize (void)
/* Free nonzero_vars. */ /* Free nonzero_vars. */
BITMAP_XFREE (nonzero_vars); BITMAP_XFREE (nonzero_vars);
BITMAP_XFREE (need_eh_cleanup); BITMAP_XFREE (need_eh_cleanup);
/* Finally, remove everything except invariants in SSA_NAME_VALUE.
Long term we will be able to let everything in SSA_NAME_VALUE
persist. However, for now, we know this is the safe thing to
do. */
for (i = 0; i < num_ssa_names; i++)
{
tree name = ssa_name (i);
tree value;
if (!name)
continue;
value = SSA_NAME_VALUE (name);
if (value && !is_gimple_min_invariant (value))
SSA_NAME_VALUE (name) = NULL;
}
} }
static bool static bool
...@@ -503,8 +521,8 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e) ...@@ -503,8 +521,8 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
uses_copy[i] = USE_OP (uses, i); uses_copy[i] = USE_OP (uses, i);
if (TREE_CODE (USE_OP (uses, i)) == SSA_NAME) if (TREE_CODE (USE_OP (uses, i)) == SSA_NAME)
tmp = SSA_NAME_EQUIV (USE_OP (uses, i)); tmp = SSA_NAME_VALUE (USE_OP (uses, i));
if (tmp) if (tmp && TREE_CODE (tmp) != VALUE_HANDLE)
SET_USE_OP (uses, i, tmp); SET_USE_OP (uses, i, tmp);
} }
...@@ -515,8 +533,8 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e) ...@@ -515,8 +533,8 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
vuses_copy[i] = VUSE_OP (vuses, i); vuses_copy[i] = VUSE_OP (vuses, i);
if (TREE_CODE (VUSE_OP (vuses, i)) == SSA_NAME) if (TREE_CODE (VUSE_OP (vuses, i)) == SSA_NAME)
tmp = SSA_NAME_EQUIV (VUSE_OP (vuses, i)); tmp = SSA_NAME_VALUE (VUSE_OP (vuses, i));
if (tmp) if (tmp && TREE_CODE (tmp) != VALUE_HANDLE)
SET_VUSE_OP (vuses, i, tmp); SET_VUSE_OP (vuses, i, tmp);
} }
...@@ -607,15 +625,15 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e) ...@@ -607,15 +625,15 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
/* Get the current value of both operands. */ /* Get the current value of both operands. */
if (TREE_CODE (op0) == SSA_NAME) if (TREE_CODE (op0) == SSA_NAME)
{ {
tree tmp = SSA_NAME_EQUIV (op0); tree tmp = SSA_NAME_VALUE (op0);
if (tmp) if (tmp && TREE_CODE (tmp) != VALUE_HANDLE)
op0 = tmp; op0 = tmp;
} }
if (TREE_CODE (op1) == SSA_NAME) if (TREE_CODE (op1) == SSA_NAME)
{ {
tree tmp = SSA_NAME_EQUIV (op1); tree tmp = SSA_NAME_VALUE (op1);
if (tmp) if (tmp && TREE_CODE (tmp) != VALUE_HANDLE)
op1 = tmp; op1 = tmp;
} }
...@@ -654,7 +672,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e) ...@@ -654,7 +672,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
else if (TREE_CODE (cond) == SSA_NAME) else if (TREE_CODE (cond) == SSA_NAME)
{ {
cached_lhs = cond; cached_lhs = cond;
cached_lhs = SSA_NAME_EQUIV (cached_lhs); cached_lhs = SSA_NAME_VALUE (cached_lhs);
if (cached_lhs && ! is_gimple_min_invariant (cached_lhs)) if (cached_lhs && ! is_gimple_min_invariant (cached_lhs))
cached_lhs = 0; cached_lhs = 0;
} }
...@@ -809,7 +827,7 @@ restore_vars_to_original_value (void) ...@@ -809,7 +827,7 @@ restore_vars_to_original_value (void)
prev_value = VARRAY_TOP_TREE (const_and_copies_stack); prev_value = VARRAY_TOP_TREE (const_and_copies_stack);
VARRAY_POP (const_and_copies_stack); VARRAY_POP (const_and_copies_stack);
SET_SSA_NAME_EQUIV (dest, prev_value); SSA_NAME_VALUE (dest) = prev_value;
} }
} }
...@@ -1067,7 +1085,7 @@ record_equivalences_from_phis (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -1067,7 +1085,7 @@ record_equivalences_from_phis (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
by this assignment, so unwinding just costs time and space. */ by this assignment, so unwinding just costs time and space. */
if (i == PHI_NUM_ARGS (phi) if (i == PHI_NUM_ARGS (phi)
&& may_propagate_copy (lhs, rhs)) && may_propagate_copy (lhs, rhs))
SET_SSA_NAME_EQUIV (lhs, rhs); SSA_NAME_VALUE (lhs) = rhs;
/* Now see if we know anything about the nonzero property for the /* Now see if we know anything about the nonzero property for the
result of this PHI. */ result of this PHI. */
...@@ -1463,7 +1481,7 @@ record_dominating_conditions (tree cond) ...@@ -1463,7 +1481,7 @@ record_dominating_conditions (tree cond)
static void static void
record_const_or_copy_1 (tree x, tree y, tree prev_x) record_const_or_copy_1 (tree x, tree y, tree prev_x)
{ {
SET_SSA_NAME_EQUIV (x, y); SSA_NAME_VALUE (x) = y;
VARRAY_PUSH_TREE (const_and_copies_stack, prev_x); VARRAY_PUSH_TREE (const_and_copies_stack, prev_x);
VARRAY_PUSH_TREE (const_and_copies_stack, x); VARRAY_PUSH_TREE (const_and_copies_stack, x);
...@@ -1475,11 +1493,11 @@ record_const_or_copy_1 (tree x, tree y, tree prev_x) ...@@ -1475,11 +1493,11 @@ record_const_or_copy_1 (tree x, tree y, tree prev_x)
static void static void
record_const_or_copy (tree x, tree y) record_const_or_copy (tree x, tree y)
{ {
tree prev_x = SSA_NAME_EQUIV (x); tree prev_x = SSA_NAME_VALUE (x);
if (TREE_CODE (y) == SSA_NAME) if (TREE_CODE (y) == SSA_NAME)
{ {
tree tmp = SSA_NAME_EQUIV (y); tree tmp = SSA_NAME_VALUE (y);
if (tmp) if (tmp)
y = tmp; y = tmp;
} }
...@@ -1496,9 +1514,9 @@ record_equality (tree x, tree y) ...@@ -1496,9 +1514,9 @@ record_equality (tree x, tree y)
tree prev_x = NULL, prev_y = NULL; tree prev_x = NULL, prev_y = NULL;
if (TREE_CODE (x) == SSA_NAME) if (TREE_CODE (x) == SSA_NAME)
prev_x = SSA_NAME_EQUIV (x); prev_x = SSA_NAME_VALUE (x);
if (TREE_CODE (y) == SSA_NAME) if (TREE_CODE (y) == SSA_NAME)
prev_y = SSA_NAME_EQUIV (y); prev_y = SSA_NAME_VALUE (y);
/* If one of the previous values is invariant, then use that. /* If one of the previous values is invariant, then use that.
Otherwise it doesn't matter which value we choose, just so Otherwise it doesn't matter which value we choose, just so
...@@ -1509,7 +1527,7 @@ record_equality (tree x, tree y) ...@@ -1509,7 +1527,7 @@ record_equality (tree x, tree y)
prev_x = x, x = y, y = prev_x, prev_x = prev_y; prev_x = x, x = y, y = prev_x, prev_x = prev_y;
else if (prev_x && TREE_INVARIANT (prev_x)) else if (prev_x && TREE_INVARIANT (prev_x))
x = y, y = prev_x, prev_x = prev_y; x = y, y = prev_x, prev_x = prev_y;
else if (prev_y) else if (prev_y && TREE_CODE (prev_y) != VALUE_HANDLE)
y = prev_y; y = prev_y;
/* After the swapping, we must have one SSA_NAME. */ /* After the swapping, we must have one SSA_NAME. */
...@@ -2233,7 +2251,7 @@ cprop_into_successor_phis (basic_block bb, bitmap nonzero_vars) ...@@ -2233,7 +2251,7 @@ cprop_into_successor_phis (basic_block bb, bitmap nonzero_vars)
/* If we have *ORIG_P in our constant/copy table, then replace /* If we have *ORIG_P in our constant/copy table, then replace
ORIG_P with its value in our constant/copy table. */ ORIG_P with its value in our constant/copy table. */
new = SSA_NAME_EQUIV (orig); new = SSA_NAME_VALUE (orig);
if (new if (new
&& (TREE_CODE (new) == SSA_NAME && (TREE_CODE (new) == SSA_NAME
|| is_gimple_min_invariant (new)) || is_gimple_min_invariant (new))
...@@ -2378,7 +2396,7 @@ record_equivalences_from_stmt (tree stmt, ...@@ -2378,7 +2396,7 @@ record_equivalences_from_stmt (tree stmt,
if (may_optimize_p if (may_optimize_p
&& (TREE_CODE (rhs) == SSA_NAME && (TREE_CODE (rhs) == SSA_NAME
|| is_gimple_min_invariant (rhs))) || is_gimple_min_invariant (rhs)))
SET_SSA_NAME_EQUIV (lhs, rhs); SSA_NAME_VALUE (lhs) = rhs;
/* alloca never returns zero and the address of a non-weak symbol /* alloca never returns zero and the address of a non-weak symbol
is never zero. NOP_EXPRs and CONVERT_EXPRs can be completely is never zero. NOP_EXPRs and CONVERT_EXPRs can be completely
...@@ -2500,8 +2518,8 @@ cprop_operand (tree stmt, use_operand_p op_p) ...@@ -2500,8 +2518,8 @@ cprop_operand (tree stmt, use_operand_p op_p)
/* If the operand has a known constant value or it is known to be a /* If the operand has a known constant value or it is known to be a
copy of some other variable, use the value or copy stored in copy of some other variable, use the value or copy stored in
CONST_AND_COPIES. */ CONST_AND_COPIES. */
val = SSA_NAME_EQUIV (op); val = SSA_NAME_VALUE (op);
if (val) if (val && TREE_CODE (val) != VALUE_HANDLE)
{ {
tree op_type, val_type; tree op_type, val_type;
...@@ -2886,8 +2904,8 @@ lookup_avail_expr (tree stmt, bool insert) ...@@ -2886,8 +2904,8 @@ lookup_avail_expr (tree stmt, bool insert)
use the value from the const_and_copies table. */ use the value from the const_and_copies table. */
if (TREE_CODE (lhs) == SSA_NAME) if (TREE_CODE (lhs) == SSA_NAME)
{ {
temp = SSA_NAME_EQUIV (lhs); temp = SSA_NAME_VALUE (lhs);
if (temp) if (temp && TREE_CODE (temp) != VALUE_HANDLE)
lhs = temp; lhs = temp;
} }
......
...@@ -1964,6 +1964,8 @@ static void ...@@ -1964,6 +1964,8 @@ static void
fini_pre (void) fini_pre (void)
{ {
basic_block bb; basic_block bb;
unsigned int i;
bsi_commit_edge_inserts (NULL); bsi_commit_edge_inserts (NULL);
obstack_free (&grand_bitmap_obstack, NULL); obstack_free (&grand_bitmap_obstack, NULL);
...@@ -1992,6 +1994,20 @@ fini_pre (void) ...@@ -1992,6 +1994,20 @@ fini_pre (void)
} }
BITMAP_XFREE (need_eh_cleanup); BITMAP_XFREE (need_eh_cleanup);
/* Wipe out pointers to VALUE_HANDLEs. In the not terribly distant
future we will want them to be persistent though. */
for (i = 0; i < num_ssa_names; i++)
{
tree name = ssa_name (i);
if (!name)
continue;
if (SSA_NAME_VALUE (name)
&& TREE_CODE (SSA_NAME_VALUE (name)) == VALUE_HANDLE)
SSA_NAME_VALUE (name) = NULL;
}
} }
......
...@@ -1312,20 +1312,6 @@ struct tree_exp GTY(()) ...@@ -1312,20 +1312,6 @@ struct tree_exp GTY(())
#define SSA_NAME_IN_FREE_LIST(NODE) \ #define SSA_NAME_IN_FREE_LIST(NODE) \
SSA_NAME_CHECK (NODE)->common.nothrow_flag SSA_NAME_CHECK (NODE)->common.nothrow_flag
/* If NAME is equivalent to some other SSA_NAME or an invariant, then
return the equivalent SSA_NAME or invariant, else return NULL. */
#define SSA_NAME_EQUIV(NAME) __extension__ \
({ tree equiv = SSA_NAME_CHECK (NAME)->ssa_name.equiv; \
if (equiv && TREE_CODE (equiv) == SSA_NAME) \
equiv = ssa_name (SSA_NAME_VERSION (equiv)); \
equiv; \
})
/* Record that NAME (an SSA_NAME) is equivalent to EQUIV. */
#define SET_SSA_NAME_EQUIV(NAME, EQUIV)\
SSA_NAME_CHECK (NAME)->ssa_name.equiv = (EQUIV);
/* Attributes for SSA_NAMEs for pointer-type variables. */ /* Attributes for SSA_NAMEs for pointer-type variables. */
#define SSA_NAME_PTR_INFO(N) \ #define SSA_NAME_PTR_INFO(N) \
SSA_NAME_CHECK (N)->ssa_name.ptr_info SSA_NAME_CHECK (N)->ssa_name.ptr_info
...@@ -1357,8 +1343,12 @@ struct tree_ssa_name GTY(()) ...@@ -1357,8 +1343,12 @@ struct tree_ssa_name GTY(())
/* Pointer attributes used for alias analysis. */ /* Pointer attributes used for alias analysis. */
struct ptr_info_def *ptr_info; struct ptr_info_def *ptr_info;
/* Value for SSA name used by GVN. */ /* Value for SSA name used by various passes.
tree GTY((skip)) value_handle;
Right now only invariants are allowed to persist beyond a pass in
this field; in the future we will allow VALUE_HANDLEs to persist
as well. */
tree value_handle;
/* Auxiliary information stored with the ssa name. */ /* Auxiliary information stored with the ssa name. */
PTR GTY((skip)) aux; PTR GTY((skip)) aux;
......
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