Commit 195da47b by Jeff Law Committed by Jeff Law

tree-ssa-ccp.c (get_default_value): If we have a constant value recorded for an SSA_NAME...


	* tree-ssa-ccp.c (get_default_value): If we have a constant
	value recorded for an SSA_NAME, then use that constant as
	the initial lattice value.
	(substitute_and_fold): Transfer equivalences discovered into
	SSA_NAME_EQUIV.

	* tree.h (SSA_NAME_EQUIV): Add comments.
	(SET_SSA_NAME_EQUIV): Similarly.

From-SVN: r87844
parent 0a4f0294
2004-09-21 Jeff Law <law@redhat.com>
* tree-ssa-ccp.c (get_default_value): If we have a constant
value recorded for an SSA_NAME, then use that constant as
the initial lattice value.
(substitute_and_fold): Transfer equivalences discovered into
SSA_NAME_EQUIV.
* tree.h (SSA_NAME_EQUIV): Add comments.
(SET_SSA_NAME_EQUIV): Similarly.
2004-09-21 David Edelsohn <edelsohn@gnu.org> 2004-09-21 David Edelsohn <edelsohn@gnu.org>
* config/rs6000/linux64.h (PROCESSOR_DEFAULT64): Default to POWER4. * config/rs6000/linux64.h (PROCESSOR_DEFAULT64): Default to POWER4.
......
...@@ -135,7 +135,14 @@ get_default_value (tree var) ...@@ -135,7 +135,14 @@ get_default_value (tree var)
val.lattice_val = UNDEFINED; val.lattice_val = UNDEFINED;
val.const_val = NULL_TREE; val.const_val = NULL_TREE;
if (TREE_CODE (sym) == PARM_DECL || TREE_THIS_VOLATILE (sym)) if (TREE_CODE (var) == SSA_NAME
&& SSA_NAME_EQUIV (var)
&& is_gimple_min_invariant (SSA_NAME_EQUIV (var)))
{
val.lattice_val = CONSTANT;
val.const_val = SSA_NAME_EQUIV (var);
}
else if (TREE_CODE (sym) == PARM_DECL || TREE_THIS_VOLATILE (sym))
{ {
/* Function arguments and volatile variables are considered VARYING. */ /* Function arguments and volatile variables are considered VARYING. */
val.lattice_val = VARYING; val.lattice_val = VARYING;
...@@ -512,6 +519,7 @@ static void ...@@ -512,6 +519,7 @@ static void
substitute_and_fold (void) substitute_and_fold (void)
{ {
basic_block bb; basic_block bb;
unsigned int i;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, fprintf (dump_file,
...@@ -586,6 +594,25 @@ substitute_and_fold (void) ...@@ -586,6 +594,25 @@ substitute_and_fold (void)
} }
} }
} }
/* And transfer what we learned from VALUE_VECTOR into the
SSA_NAMEs themselves. This probably isn't terribly important
since we probably constant propagated the values to their
use sites above. */
for (i = 0; i < num_ssa_names; i++)
{
tree name = ssa_name (i);
value *value;
if (!name)
continue;
value = get_value (name);
if (value->lattice_val == CONSTANT
&& is_gimple_reg (name)
&& is_gimple_min_invariant (value->const_val))
SET_SSA_NAME_EQUIV (name, value->const_val)
}
} }
......
...@@ -1304,13 +1304,14 @@ struct tree_exp GTY(()) ...@@ -1304,13 +1304,14 @@ struct tree_exp GTY(())
#define SSA_NAME_OCCURS_IN_ABNORMAL_PHI(NODE) \ #define SSA_NAME_OCCURS_IN_ABNORMAL_PHI(NODE) \
SSA_NAME_CHECK (NODE)->common.asm_written_flag SSA_NAME_CHECK (NODE)->common.asm_written_flag
/* Nonzero if this SSA_NAME expression is currently on the free list of /* Nonzero if this SSA_NAME expression is currently on the free list of
SSA_NAMES. Using NOTHROW_FLAG seems reasonably safe since throwing SSA_NAMES. Using NOTHROW_FLAG seems reasonably safe since throwing
has no meaning for an SSA_NAME. */ has no meaning for an SSA_NAME. */
#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__ \ #define SSA_NAME_EQUIV(NAME) __extension__ \
({ tree equiv = SSA_NAME_CHECK (NAME)->ssa_name.equiv; \ ({ tree equiv = SSA_NAME_CHECK (NAME)->ssa_name.equiv; \
if (equiv && TREE_CODE (equiv) == SSA_NAME) \ if (equiv && TREE_CODE (equiv) == SSA_NAME) \
...@@ -1318,6 +1319,8 @@ struct tree_exp GTY(()) ...@@ -1318,6 +1319,8 @@ struct tree_exp GTY(())
equiv; \ equiv; \
}) })
/* Record that NAME (an SSA_NAME) is equivalent to EQUIV. */
#define SET_SSA_NAME_EQUIV(NAME, EQUIV)\ #define SET_SSA_NAME_EQUIV(NAME, EQUIV)\
SSA_NAME_CHECK (NAME)->ssa_name.equiv = (EQUIV); SSA_NAME_CHECK (NAME)->ssa_name.equiv = (EQUIV);
......
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