summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-copy.c
diff options
context:
space:
mode:
authoramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-17 18:13:20 +0000
committeramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-17 18:13:20 +0000
commit56004dc53dd7a2e3dbfeb26a7adf9743e5b82cc6 (patch)
tree48e225e2383797232dc02a86ef7fbfa79ca1a610 /gcc/tree-ssa-copy.c
parent3aaaf63fd1edbedcdd7c589ac28ac72328d71579 (diff)
downloadgcc-56004dc53dd7a2e3dbfeb26a7adf9743e5b82cc6.tar.gz
2004-06-16 Andrew MacLeod <amacleod@redhat.com>
* tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT. * tree-flow-inline.h (get_use_op_ptr): Return a use_operand_p. (get_use_from_ptr, get_def_from_ptr): New. Return operand pointers. (get_def_op_ptr): Return a def_operand_p instead of a 'tree *'. (get_v_may_def_result_ptr): Return a def_operand_p. (get_v_may_def_op_ptr, get_vuse_op_ptr): Return a use_operand_p. (get_v_must_def_op_ptr): Return a def_operand_p. (get_phi_result_ptr): New. Return a pointer to the result of a PHI. (get_phi_arg_def_ptr): New. Return a pointer to an argument of a PHI. (phi_element_for_edge): Remove. * tree-flow.h (propagate_value, replace_exp): Change prototype. (propagate_tree_value): Add new prototype. (phi_element_for_edge): Remove prototype. * tree-into-ssa.c (mark_def_sites): Use new operand types. (prepare_operand_for_rename): Split into two functions. (prepare_use_operand_for_rename): Prepare use operands. (prepare_def_operand_for_rename): Prepare def operands. (rewrite_stmt): Use new operand types. (rewrite_operand): Use new operand types, change parameter type. * tree-outof-ssa.c (replace_variable): Split into two functions. (replace_use_variable): Rewrite uses. (replace_def_variable): Rewrite defs. (rewrite_trees, rewrite_vars_out_of_ssa): Use new operand types. * tree-phinodes.c (make_phi_node, resize_phi_node): Use new types. (add_phi_arg, remove_phi_arg_num): Use new operand types. * tree-ssa-ccp.c (substitute_and_fold): Use new operand types. (ccp_fold, replace_uses_in): Use new operand types. * tree-ssa-copy.c (replace_ssa_names): Rename to replace_ssa_names_ann and no longer set the value, change parameter type. (replace_exp_1): Use new operand types. (propagate_value): Change parameter type, use new operand types. (propagate_tree_value): Propagate_value without SSA operands. (replace_exp, cprop_operand, cprop_into_stmt): Use new operand types. (cprop_into_successor_phis): Use new operand types. * tree-ssa-dom.c (thread_across_edge): Use new operand types. (eliminate_redundant_computations): Use new operand types. * tree-ssa-dse.c (fix_phi_uses): Use new operand_types. (fix_stmt_v_may_defs): Use new operand_types. * tree-ssa-live.c (create_ssa_var_map): Use new operand_types. (build_tree_conflict_graph): Use new operand_types. * tree-ssa-loop.c (duplicate_blocks): Use PHI_ARG_DEF_FROM_EDGE. * tree-ssa-operands.c (struct freelist_d): Remove. (check_optype_freelist, add_optype_freelist): Remove. (allocate_def_optype, allocate_use_optype, allocate_v_may_def_optype, allocate_vuse_optype, allocate_v_must_def_optype): Call ggc_alloc. (free_uses, free_defs, free_vuses, free_v_may_defs, free_v_must_defs): Call ggc_free instead of add_optype_freelist. (init_ssa_operands, fini_ssa_operands): Remove free list code. (finalize_ssa_defs, finalize_ssa_uses): Set new use/def operands. * tree-ssa-operands.h (struct def_optype_d): Change underlying type. (struct use_optype_d): Change underlying type. (def_operand_p, use_operand_p): New types for pointers to operands. (USE_OP, DEF_OP, V_MAY_DEF_RESULT, V_MAY_DEF_OP, VUSE_OP, V_MUST_DEF_OP): Use new pointer type instead of dereferencing directly. (USE_FROM_PTR, DEF_FROM_PTR): New macros to "dereference" operand pointer types. (SET_USE, SET_DEF): New macros to set operands from their pointer. (SET_USE_OP, SET_DEF_OP, SET_V_MAY_DEF_RESULT, SET_V_MAY_DEF_OP, SET_VUSE_OP, SET_V_MUST_DEF_OP): New SET routines for operands. (PHI_RESULT_PTR, PHI_RESULT, SET_PHI_RESULT): Macros to manage the PHI result as an operand. (PHI_ARG_DEF_PTR, PHI_ARG_DEF, SET_PHI_ARG_DEF, PHI_ARG_DEF_FROM_EDGE, PHI_ARG_DEF_PTR_FROM_EDGE): Macros to manage the PHI arguments. * tree-ssa-pre.c (eliminate): Call propagate_tree_value. * tree-tailcall.c (independent_of_stmt_p, propagate_through_phis): Use PHI_ARG_DEF_FROM_EDGE. * tree.h (PHI_RESULT): Renamed to PHI_RESULT_TREE. (PHI_ARG_DEF): Renamed to PHI_ARG_DEF_TREE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83298 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-copy.c')
-rw-r--r--gcc/tree-ssa-copy.c105
1 files changed, 65 insertions, 40 deletions
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 71574d4df00..32db3fa3d86 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -54,31 +54,33 @@ Boston, MA 02111-1307, USA. */
replacements of one SSA_NAME with a different SSA_NAME to use the
APIs defined in this file. */
-/* Given two SSA_NAMEs, replace the one pointed to by OP_P with VAR.
- If *OP_P is a pointer, copy the memory tag used originally by *OP_P into
+/* Given two SSA_NAMEs, replace the annotations for the one referred to by OP
+ with VAR's annmoptations.
+
+ If OP is a pointer, copy the memory tag used originally by OP into
VAR. This is needed in cases where VAR had never been dereferenced in the
program.
If FOR_PROPAGATION is true, then perform additional checks to ensure
- that const/copy propagation of var for *OP_P is valid. */
+ that const/copy propagation of var for OP is valid. */
static void
-replace_ssa_names (tree *op_p,
+replace_ssa_names_ann (tree op,
tree var,
bool for_propagation ATTRIBUTE_UNUSED)
{
#if defined ENABLE_CHECKING
- if (for_propagation && !may_propagate_copy (*op_p, var))
+ if (for_propagation && !may_propagate_copy (op, var))
abort ();
#endif
/* If VAR doesn't have a memory tag, copy the one from the original
operand. Also copy the dereferenced flags. */
- if (POINTER_TYPE_P (TREE_TYPE (*op_p)))
+ if (POINTER_TYPE_P (TREE_TYPE (op)))
{
var_ann_t new_ann = var_ann (SSA_NAME_VAR (var));
- var_ann_t orig_ann = var_ann (SSA_NAME_VAR (*op_p));
+ var_ann_t orig_ann = var_ann (SSA_NAME_VAR (op));
if (new_ann->type_mem_tag == NULL_TREE)
new_ann->type_mem_tag = orig_ann->type_mem_tag;
@@ -88,26 +90,25 @@ replace_ssa_names (tree *op_p,
abort ();
}
- *op_p = var;
-}
+}
+
/* Common code for propagate_value and replace_exp.
- Replace *OP_P with VAL. FOR_PROPAGATION indicates if the replacement
- is done to propagate a value or not. */
+ Replace use operand OP_P with VAL. FOR_PROPAGATION indicates if the
+ replacement is done to propagate a value or not. */
static void
-replace_exp_1 (tree *op_p, tree val, bool for_propagation)
+replace_exp_1 (use_operand_p op_p, tree val, bool for_propagation)
{
if (TREE_CODE (val) == SSA_NAME)
{
- if (TREE_CODE (*op_p) == SSA_NAME)
- replace_ssa_names (op_p, val, for_propagation);
- else
- *op_p = val;
+ if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
+ replace_ssa_names_ann (USE_FROM_PTR (op_p), val, for_propagation);
+ SET_USE (op_p, val);
}
else
- *op_p = lhd_unsave_expr_now (val);
+ SET_USE (op_p, lhd_unsave_expr_now (val));
}
/* Propagate the value VAL (assumed to be a constant or another SSA_NAME)
@@ -117,11 +118,32 @@ replace_exp_1 (tree *op_p, tree val, bool for_propagation)
checks to ensure validity of the const/copy propagation. */
void
-propagate_value (tree *op_p, tree val)
+propagate_value (use_operand_p op_p, tree val)
{
replace_exp_1 (op_p, val, true);
}
+/* Propagate the value VAL (assumed to be a constant or another SSA_NAME)
+ into the tree pointed by OP_P.
+
+ Use this version for const/copy propagation when SSA operands are not
+ available. It will perform the additional checks to ensure validity of
+ the const/copy propagation, but will not update any operand information.
+ Be sure to mark the stmt as modified. */
+
+void
+propagate_tree_value (tree *op_p, tree val)
+{
+ if (TREE_CODE (val) == SSA_NAME)
+ {
+ if (TREE_CODE (*op_p) == SSA_NAME)
+ replace_ssa_names_ann (*op_p, val, true);
+ *op_p = val;
+ }
+ else
+ *op_p = lhd_unsave_expr_now (val);
+}
+
/* Replace *OP_P with value VAL (assumed to be a constant or another SSA_NAME).
Use this version when not const/copy propagating values. For example,
@@ -129,7 +151,7 @@ propagate_value (tree *op_p, tree val)
in specific blocks taking into account actions of PHI nodes. */
void
-replace_exp (tree *op_p, tree val)
+replace_exp (use_operand_p op_p, tree val)
{
replace_exp_1 (op_p, val, false);
}
@@ -138,15 +160,16 @@ replace_exp (tree *op_p, tree val)
CONST_AND_COPIES. */
static bool
-cprop_operand (stmt_ann_t ann, tree *op_p, varray_type const_and_copies)
+cprop_operand (stmt_ann_t ann, use_operand_p op_p, varray_type const_and_copies)
{
bool may_have_exposed_new_symbols = false;
tree val;
+ tree op = USE_FROM_PTR (op_p);
/* 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
CONST_AND_COPIES. */
- val = VARRAY_TREE (const_and_copies, SSA_NAME_VERSION (*op_p));
+ val = VARRAY_TREE (const_and_copies, SSA_NAME_VERSION (op));
if (val)
{
tree op_type, val_type;
@@ -156,13 +179,13 @@ cprop_operand (stmt_ann_t ann, tree *op_p, varray_type const_and_copies)
the renamed virtual operand if we later modify this
statement. Also only allow the new value to be an SSA_NAME
for propagation into virtual operands. */
- if (!is_gimple_reg (*op_p)
- && (get_virtual_var (val) != get_virtual_var (*op_p)
+ if (!is_gimple_reg (op)
+ && (get_virtual_var (val) != get_virtual_var (op)
|| TREE_CODE (val) != SSA_NAME))
return false;
/* Get the toplevel type of each operand. */
- op_type = TREE_TYPE (*op_p);
+ op_type = TREE_TYPE (op);
val_type = TREE_TYPE (val);
/* While both types are pointers, get the type of the object
@@ -180,7 +203,7 @@ cprop_operand (stmt_ann_t ann, tree *op_p, varray_type const_and_copies)
if (!lang_hooks.types_compatible_p (op_type, val_type)
&& TREE_CODE (val) != SSA_NAME)
{
- val = fold_convert (TREE_TYPE (*op_p), val);
+ val = fold_convert (TREE_TYPE (op), val);
if (!is_gimple_min_invariant (val)
&& TREE_CODE (val) != SSA_NAME)
return false;
@@ -190,14 +213,14 @@ cprop_operand (stmt_ann_t ann, tree *op_p, varray_type const_and_copies)
to their interaction with exception handling and some GCC
extensions. */
if (TREE_CODE (val) == SSA_NAME
- && !may_propagate_copy (*op_p, val))
+ && !may_propagate_copy (op, val))
return false;
/* Dump details. */
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, " Replaced '");
- print_generic_expr (dump_file, *op_p, dump_flags);
+ print_generic_expr (dump_file, op, dump_flags);
fprintf (dump_file, "' with %s '",
(TREE_CODE (val) != SSA_NAME ? "constant" : "variable"));
print_generic_expr (dump_file, val, dump_flags);
@@ -207,7 +230,7 @@ cprop_operand (stmt_ann_t ann, tree *op_p, varray_type const_and_copies)
/* If VAL is an ADDR_EXPR or a constant of pointer type, note
that we may have exposed a new symbol for SSA renaming. */
if (TREE_CODE (val) == ADDR_EXPR
- || (POINTER_TYPE_P (TREE_TYPE (*op_p))
+ || (POINTER_TYPE_P (TREE_TYPE (op))
&& is_gimple_min_invariant (val)))
may_have_exposed_new_symbols = true;
@@ -241,8 +264,8 @@ cprop_into_stmt (tree stmt, varray_type const_and_copies)
num_uses = NUM_USES (uses);
for (i = 0; i < num_uses; i++)
{
- tree *op_p = USE_OP_PTR (uses, i);
- if (TREE_CODE (*op_p) == SSA_NAME)
+ use_operand_p op_p = USE_OP_PTR (uses, i);
+ if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
may_have_exposed_new_symbols
|= cprop_operand (ann, op_p, const_and_copies);
}
@@ -251,8 +274,8 @@ cprop_into_stmt (tree stmt, varray_type const_and_copies)
num_vuses = NUM_VUSES (vuses);
for (i = 0; i < num_vuses; i++)
{
- tree *op_p = VUSE_OP_PTR (vuses, i);
- if (TREE_CODE (*op_p) == SSA_NAME)
+ use_operand_p op_p = VUSE_OP_PTR (vuses, i);
+ if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
may_have_exposed_new_symbols
|= cprop_operand (ann, op_p, const_and_copies);
}
@@ -261,8 +284,8 @@ cprop_into_stmt (tree stmt, varray_type const_and_copies)
num_v_may_defs = NUM_V_MAY_DEFS (v_may_defs);
for (i = 0; i < num_v_may_defs; i++)
{
- tree *op_p = V_MAY_DEF_OP_PTR (v_may_defs, i);
- if (TREE_CODE (*op_p) == SSA_NAME)
+ use_operand_p op_p = V_MAY_DEF_OP_PTR (v_may_defs, i);
+ if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
may_have_exposed_new_symbols
|= cprop_operand (ann, op_p, const_and_copies);
}
@@ -317,7 +340,8 @@ cprop_into_successor_phis (basic_block bb,
{
int i;
tree new;
- tree *orig_p;
+ use_operand_p orig_p;
+ tree orig;
/* If the hint is valid (!= phi_num_args), see if it points
us to the desired phi alternative. */
@@ -343,22 +367,23 @@ cprop_into_successor_phis (basic_block bb,
/* The alternative may be associated with a constant, so verify
it is an SSA_NAME before doing anything with it. */
- orig_p = &PHI_ARG_DEF (phi, hint);
- if (TREE_CODE (*orig_p) != SSA_NAME)
+ orig_p = PHI_ARG_DEF_PTR (phi, hint);
+ orig = USE_FROM_PTR (orig_p);
+ if (TREE_CODE (orig) != SSA_NAME)
continue;
/* If the alternative is known to have a nonzero value, record
that fact in the PHI node itself for future use. */
- if (bitmap_bit_p (nonzero_vars, SSA_NAME_VERSION (*orig_p)))
+ if (bitmap_bit_p (nonzero_vars, SSA_NAME_VERSION (orig)))
PHI_ARG_NONZERO (phi, hint) = true;
/* If we have *ORIG_P in our constant/copy table, then replace
ORIG_P with its value in our constant/copy table. */
- new = VARRAY_TREE (const_and_copies, SSA_NAME_VERSION (*orig_p));
+ new = VARRAY_TREE (const_and_copies, SSA_NAME_VERSION (orig));
if (new
&& (TREE_CODE (new) == SSA_NAME
|| is_gimple_min_invariant (new))
- && may_propagate_copy (*orig_p, new))
+ && may_propagate_copy (orig, new))
propagate_value (orig_p, new);
}
}