summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-29 11:43:22 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-29 11:43:22 +0000
commit61207d43e04032185fef000bb9e590d28759c9e9 (patch)
treee8b45c160b843a80f4ad20003cdaef3857a01573 /gcc/tree-ssa-ccp.c
parent6d075589ec61545330adf69172b12f4d31496a06 (diff)
downloadgcc-61207d43e04032185fef000bb9e590d28759c9e9.tar.gz
2008-08-29 Richard Guenther <rguenther@suse.de>
* common.opt (ftree-store-ccp): Mark as preserved for backward compatibility. * doc/invoke.texi (-ftree-store-ccp): Remove documentation. * tree-pass.h (pass_store_ccp): Remove. * tree-ssa-propagate.h (struct prop_value_d): Remove mem_ref field. (first_vdef): Remove declaration. (get_value_loaded_by): Likewise. * tree-ssa-ccp.c (do_store_ccp): Remove. (get_default_value): Simplify as do_store_ccp is always false now. Do not initialize mem_ref. (set_value_varying): Likewise. (canonicalize_float_value): Likewise. (set_lattice_value): Likewise. (likely_value): Likewise. (surely_varying_stmt_p): Likewise. (ccp_initialize): Likewise. (ccp_lattice_meet): Likewise. (ccp_visit_phi_node): Likewise. (ccp_fold): Likewise. (evaluate_stmt): Likewise. (visit_assignment): Likewise. (ccp_visit_stmt): Likewise. (execute_ssa_ccp): Fold into ... (do_ssa_ccp): ... this. (do_ssa_store_ccp): Remove. (gate_store_ccp): Likewise. (pass_store_ccp): Likewise. * tree-ssa-copy.c (copy_prop_visit_phi_node): Do not initialize mem_ref. * tree-ssa-propagate.c (first_vdef): Remove. (get_value_loaded_by): Likewise. (replace_vuses_in): Likewise. (substitute_and_fold): Do not call replace_vuses_in. * opts.c (decode_options): Do not set flag_tree_store_ccp. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139764 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c163
1 files changed, 9 insertions, 154 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 57aa473481c..870a244ac6d 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -227,9 +227,6 @@ typedef enum
doing the store). */
static prop_value_t *const_val;
-/* True if we are also propagating constants in stores and loads. */
-static bool do_store_ccp;
-
/* Dump constant propagation value VAL to file OUTF prefixed by PREFIX. */
static void
@@ -321,10 +318,10 @@ static prop_value_t
get_default_value (tree var)
{
tree sym = SSA_NAME_VAR (var);
- prop_value_t val = { UNINITIALIZED, NULL_TREE, NULL_TREE };
+ prop_value_t val = { UNINITIALIZED, NULL_TREE };
tree cst_val;
- if (!do_store_ccp && !is_gimple_reg (var))
+ if (!is_gimple_reg (var))
{
/* Short circuit for regular CCP. We are not interested in any
non-register when DO_STORE_CCP is false. */
@@ -336,7 +333,6 @@ get_default_value (tree var)
initial value. */
val.lattice_val = CONSTANT;
val.value = cst_val;
- val.mem_ref = sym;
}
else
{
@@ -401,7 +397,6 @@ set_value_varying (tree var)
val->lattice_val = VARYING;
val->value = NULL_TREE;
- val->mem_ref = NULL_TREE;
}
/* For float types, modify the value of VAL to make ccp work correctly
@@ -447,7 +442,6 @@ canonicalize_float_value (prop_value_t *val)
{
val->lattice_val = UNDEFINED;
val->value = NULL;
- val->mem_ref = NULL;
return;
}
}
@@ -469,8 +463,7 @@ set_lattice_value (tree var, prop_value_t new_val)
gcc_assert (old_val->lattice_val < new_val.lattice_val
|| (old_val->lattice_val == new_val.lattice_val
&& ((!old_val->value && !new_val.value)
- || operand_equal_p (old_val->value, new_val.value, 0))
- && old_val->mem_ref == new_val.mem_ref));
+ || operand_equal_p (old_val->value, new_val.value, 0))));
if (old_val->lattice_val != new_val.lattice_val)
{
@@ -524,8 +517,7 @@ likely_value (gimple stmt)
/* If we are not doing store-ccp, statements with loads
and/or stores will never fold into a constant. */
- if (!do_store_ccp
- && !ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
+ if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
return VARYING;
/* Note that only a GIMPLE_SINGLE_RHS assignment can satisfy
@@ -613,15 +605,7 @@ surely_varying_stmt_p (gimple stmt)
return true;
if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
- {
- if (!do_store_ccp)
- return true;
-
- /* We can only handle simple loads and stores. */
- if (!stmt_makes_single_load (stmt)
- && !stmt_makes_single_store (stmt))
- return true;
- }
+ return true;
/* If it is a call and does not return a value or is not a
builtin and not an indirect call, it is varying. */
@@ -692,7 +676,7 @@ ccp_initialize (void)
{
gimple phi = gsi_stmt (i);
- if (!do_store_ccp && !is_gimple_reg (gimple_phi_result (phi)))
+ if (!is_gimple_reg (gimple_phi_result (phi)))
prop_set_simulate_again (phi, false);
else
prop_set_simulate_again (phi, true);
@@ -747,14 +731,10 @@ ccp_lattice_meet (prop_value_t *val1, prop_value_t *val2)
/* any M VARYING = VARYING. */
val1->lattice_val = VARYING;
val1->value = NULL_TREE;
- val1->mem_ref = NULL_TREE;
}
else if (val1->lattice_val == CONSTANT
&& val2->lattice_val == CONSTANT
- && simple_cst_equal (val1->value, val2->value) == 1
- && (!do_store_ccp
- || (val1->mem_ref && val2->mem_ref
- && operand_equal_p (val1->mem_ref, val2->mem_ref, 0))))
+ && simple_cst_equal (val1->value, val2->value) == 1)
{
/* Ci M Cj = Ci if (i == j)
Ci M Cj = VARYING if (i != j)
@@ -763,14 +743,12 @@ ccp_lattice_meet (prop_value_t *val1, prop_value_t *val2)
they come from the same memory reference. */
val1->lattice_val = CONSTANT;
val1->value = val1->value;
- val1->mem_ref = val1->mem_ref;
}
else
{
/* Any other combination is VARYING. */
val1->lattice_val = VARYING;
val1->value = NULL_TREE;
- val1->mem_ref = NULL_TREE;
}
}
@@ -805,7 +783,6 @@ ccp_visit_phi_node (gimple phi)
case UNDEFINED:
new_val.lattice_val = UNDEFINED;
new_val.value = NULL_TREE;
- new_val.mem_ref = NULL_TREE;
break;
default:
@@ -837,7 +814,6 @@ ccp_visit_phi_node (gimple phi)
{
arg_val.lattice_val = CONSTANT;
arg_val.value = arg;
- arg_val.mem_ref = NULL_TREE;
}
else
arg_val = *(get_value (arg));
@@ -941,25 +917,6 @@ ccp_fold (gimple stmt)
}
}
- else if (do_store_ccp && stmt_makes_single_load (stmt))
- {
- /* If the RHS is a memory load, see if the VUSEs associated with
- it are a valid constant for that memory load. */
- prop_value_t *val = get_value_loaded_by (stmt, const_val);
- if (val && val->mem_ref)
- {
- if (operand_equal_p (val->mem_ref, rhs, 0))
- return val->value;
-
- /* If RHS is extracting REALPART_EXPR or IMAGPART_EXPR of a
- complex type with a known constant value, return it. */
- if ((TREE_CODE (rhs) == REALPART_EXPR
- || TREE_CODE (rhs) == IMAGPART_EXPR)
- && operand_equal_p (val->mem_ref, TREE_OPERAND (rhs, 0), 0))
- return fold_build1 (TREE_CODE (rhs), TREE_TYPE (rhs), val->value);
- }
- }
-
if (kind == tcc_reference)
{
if (TREE_CODE (rhs) == VIEW_CONVERT_EXPR
@@ -1324,8 +1281,6 @@ evaluate_stmt (gimple stmt)
ccp_lattice_t likelyvalue = likely_value (stmt);
bool is_constant;
- val.mem_ref = NULL_TREE;
-
fold_defer_overflow_warnings ();
/* If the statement is likely to have a CONSTANT result, then try
@@ -1429,21 +1384,6 @@ visit_assignment (gimple stmt, tree *output_p)
prop_value_t *nval = get_value (rhs);
val = *nval;
}
- else if (do_store_ccp && stmt_makes_single_load (stmt))
- {
- /* Same as above, but the RHS is not a gimple register and yet
- has a known VUSE. If STMT is loading from the same memory
- location that created the SSA_NAMEs for the virtual operands,
- we can propagate the value on the RHS. */
- prop_value_t *nval = get_value_loaded_by (stmt, const_val);
-
- if (nval
- && nval->mem_ref
- && operand_equal_p (nval->mem_ref, rhs, 0))
- val = *nval;
- else
- val = evaluate_stmt (stmt);
- }
else
val = evaluate_stmt (stmt);
}
@@ -1468,46 +1408,6 @@ visit_assignment (gimple stmt, tree *output_p)
retval = SSA_PROP_INTERESTING;
}
}
- else if (do_store_ccp && stmt_makes_single_store (stmt))
- {
- /* Otherwise, set the names in VDEF operands to the new
- constant value and mark the LHS as the memory reference
- associated with VAL. */
- ssa_op_iter i;
- tree vdef;
- bool changed;
-
- /* Mark VAL as stored in the LHS of this assignment. */
- if (val.lattice_val == CONSTANT)
- val.mem_ref = lhs;
-
- /* Set the value of every VDEF to VAL. */
- changed = false;
- FOR_EACH_SSA_TREE_OPERAND (vdef, stmt, i, SSA_OP_VIRTUAL_DEFS)
- {
- /* See PR 29801. We may have VDEFs for read-only variables
- (see the handling of unmodifiable variables in
- add_virtual_operand); do not attempt to change their value. */
- if (get_symbol_constant_value (SSA_NAME_VAR (vdef)) != NULL_TREE)
- continue;
-
- changed |= set_lattice_value (vdef, val);
- }
-
- /* Note that for propagation purposes, we are only interested in
- visiting statements that load the exact same memory reference
- stored here. Those statements will have the exact same list
- of virtual uses, so it is enough to set the output of this
- statement to be its first virtual definition. */
- *output_p = first_vdef (stmt);
- if (changed)
- {
- if (val.lattice_val == VARYING)
- retval = SSA_PROP_VARYING;
- else
- retval = SSA_PROP_INTERESTING;
- }
- }
return retval;
}
@@ -1595,7 +1495,7 @@ ccp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
Mark them VARYING. */
FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
{
- prop_value_t v = { VARYING, NULL_TREE, NULL_TREE };
+ prop_value_t v = { VARYING, NULL_TREE };
set_lattice_value (def, v);
}
@@ -1606,9 +1506,8 @@ ccp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
/* Main entry point for SSA Conditional Constant Propagation. */
static unsigned int
-execute_ssa_ccp (bool store_ccp)
+do_ssa_ccp (void)
{
- do_store_ccp = store_ccp;
ccp_initialize ();
ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
if (ccp_finalize ())
@@ -1618,13 +1517,6 @@ execute_ssa_ccp (bool store_ccp)
}
-static unsigned int
-do_ssa_ccp (void)
-{
- return execute_ssa_ccp (false);
-}
-
-
static bool
gate_ccp (void)
{
@@ -1653,43 +1545,6 @@ struct gimple_opt_pass pass_ccp =
};
-static unsigned int
-do_ssa_store_ccp (void)
-{
- /* If STORE-CCP is not enabled, we just run regular CCP. */
- return execute_ssa_ccp (flag_tree_store_ccp != 0);
-}
-
-static bool
-gate_store_ccp (void)
-{
- /* STORE-CCP is enabled only with -ftree-store-ccp, but when
- -fno-tree-store-ccp is specified, we should run regular CCP.
- That's why the pass is enabled with either flag. */
- return flag_tree_store_ccp != 0 || flag_tree_ccp != 0;
-}
-
-
-struct gimple_opt_pass pass_store_ccp =
-{
- {
- GIMPLE_PASS,
- "store_ccp", /* name */
- gate_store_ccp, /* gate */
- do_ssa_store_ccp, /* execute */
- NULL, /* sub */
- NULL, /* next */
- 0, /* static_pass_number */
- TV_TREE_STORE_CCP, /* tv_id */
- PROP_cfg | PROP_ssa | PROP_alias, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- TODO_dump_func | TODO_verify_ssa
- | TODO_verify_stmts | TODO_ggc_collect/* todo_flags_finish */
- }
-};
-
/* A subroutine of fold_stmt_r. Attempts to fold *(A+O) to A[X].
BASE is an array type. OFFSET is a byte displacement. ORIG_TYPE
is the desired result type. */