diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-22 04:07:23 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-22 04:07:23 +0000 |
commit | 92481a4d0a1baf5aceacafc74fed24ddcd2995aa (patch) | |
tree | ba1ee7d893d35a339821c16a830d1a3c262c07e7 /gcc/tree-ssa-ccp.c | |
parent | 6c06b97256ed18dc19a35441db46fbd9e2f1a678 (diff) | |
download | gcc-92481a4d0a1baf5aceacafc74fed24ddcd2995aa.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87844 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 81ce67321c5..5fe1e1de66f 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -135,7 +135,14 @@ get_default_value (tree var) val.lattice_val = UNDEFINED; 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. */ val.lattice_val = VARYING; @@ -512,6 +519,7 @@ static void substitute_and_fold (void) { basic_block bb; + unsigned int i; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, @@ -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) + } } |