hashval_t hash;
};
-/* Table of constant values and copies indexed by SSA name. When the
- renaming pass finds an assignment of a constant (X_i = C) or a copy
- assignment from another SSA variable (X_i = Y_j), it creates a mapping
- between X_i and the RHS in this table. This mapping is used later on,
- when renaming uses of X_i. If an assignment to X_i is found in this
- table, instead of using X_i, we use the RHS of the statement stored in
- this table (thus performing very simplistic copy and constant
- propagation). */
-static varray_type const_and_copies;
-
/* Stack of dest,src pairs that need to be restored during finalization.
A NULL entry is used to mark the end of pairs which need to be
static void optimize_stmt (struct dom_walk_data *,
basic_block bb,
block_stmt_iterator);
-static inline tree get_value_for (tree, varray_type table);
-static inline void set_value_for (tree, tree, varray_type table);
static tree lookup_avail_expr (tree, bool);
static struct eq_expr_value get_eq_expr_value (tree, int, basic_block);
static hashval_t avail_expr_hash (const void *);
return t;
}
-/* Return the value associated with variable VAR in TABLE. */
-
-static inline tree
-get_value_for (tree var, varray_type table)
-{
- return VARRAY_TREE (table, SSA_NAME_VERSION (var));
-}
-
-/* Associate VALUE to variable VAR in TABLE. */
-
-static inline void
-set_value_for (tree var, tree value, varray_type table)
-{
- VARRAY_TREE (table, SSA_NAME_VERSION (var)) = value;
-}
-
/* Jump threading, redundancy elimination and const/copy propagation.
This pass may expose new symbols that need to be renamed into SSA. For
avail_exprs = htab_create (1024, real_avail_expr_hash, avail_expr_eq, free);
VARRAY_TREE_INIT (avail_exprs_stack, 20, "Available expression stack");
VARRAY_TREE_INIT (block_defs_stack, 20, "Block DEFS stack");
- VARRAY_TREE_INIT (const_and_copies, num_ssa_names, "const_and_copies");
VARRAY_TREE_INIT (const_and_copies_stack, 20, "Block const_and_copies stack");
VARRAY_TREE_INIT (nonzero_vars_stack, 20, "Block nonzero_vars stack");
VARRAY_TREE_INIT (vrp_variables_stack, 20, "Block vrp_variables stack");
rewrite_ssa_into_ssa ();
- if (VARRAY_ACTIVE_SIZE (const_and_copies) <= num_ssa_names)
- {
- VARRAY_GROW (const_and_copies, num_ssa_names);
- VARRAY_GROW (vrp_data, num_ssa_names);
- }
+ if (VARRAY_ACTIVE_SIZE (vrp_data) <= num_ssa_names)
+ VARRAY_GROW (vrp_data, num_ssa_names);
/* Reinitialize the various tables. */
bitmap_clear (nonzero_vars);
htab_empty (avail_exprs);
- VARRAY_CLEAR (const_and_copies);
VARRAY_CLEAR (vrp_data);
for (i = 0; i < num_referenced_vars; i++)
uses_copy[i] = USE_OP (uses, i);
if (TREE_CODE (USE_OP (uses, i)) == SSA_NAME)
- tmp = get_value_for (USE_OP (uses, i), const_and_copies);
+ tmp = SSA_NAME_EQUIV (USE_OP (uses, i));
if (tmp)
SET_USE_OP (uses, i, tmp);
}
vuses_copy[i] = VUSE_OP (vuses, i);
if (TREE_CODE (VUSE_OP (vuses, i)) == SSA_NAME)
- tmp = get_value_for (VUSE_OP (vuses, i), const_and_copies);
+ tmp = SSA_NAME_EQUIV (VUSE_OP (vuses, i));
if (tmp)
SET_VUSE_OP (vuses, i, tmp);
}
/* Get the current value of both operands. */
if (TREE_CODE (op0) == SSA_NAME)
{
- tree tmp = get_value_for (op0, const_and_copies);
+ tree tmp = SSA_NAME_EQUIV (op0);
if (tmp)
op0 = tmp;
}
if (TREE_CODE (op1) == SSA_NAME)
{
- tree tmp = get_value_for (op1, const_and_copies);
+ tree tmp = SSA_NAME_EQUIV (op1);
if (tmp)
op1 = tmp;
}
else if (TREE_CODE (cond) == SSA_NAME)
{
cached_lhs = cond;
- cached_lhs = get_value_for (cached_lhs, const_and_copies);
+ cached_lhs = SSA_NAME_EQUIV (cached_lhs);
if (cached_lhs && ! is_gimple_min_invariant (cached_lhs))
cached_lhs = 0;
}
prev_value = VARRAY_TOP_TREE (const_and_copies_stack);
VARRAY_POP (const_and_copies_stack);
- set_value_for (dest, prev_value, const_and_copies);
+ SET_SSA_NAME_EQUIV (dest, prev_value);
}
}
by this assignment, so unwinding just costs time and space. */
if (i == PHI_NUM_ARGS (phi)
&& may_propagate_copy (lhs, rhs))
- set_value_for (lhs, rhs, const_and_copies);
+ SET_SSA_NAME_EQUIV (lhs, rhs);
/* Now see if we know anything about the nonzero property for the
result of this PHI. */
static void
record_const_or_copy_1 (tree x, tree y, tree prev_x)
{
- set_value_for (x, y, const_and_copies);
+ SET_SSA_NAME_EQUIV (x, y);
VARRAY_PUSH_TREE (const_and_copies_stack, prev_x);
VARRAY_PUSH_TREE (const_and_copies_stack, x);
static void
record_const_or_copy (tree x, tree y)
{
- tree prev_x = get_value_for (x, const_and_copies);
+ tree prev_x = SSA_NAME_EQUIV (x);
if (TREE_CODE (y) == SSA_NAME)
{
- tree tmp = get_value_for (y, const_and_copies);
+ tree tmp = SSA_NAME_EQUIV (y);
if (tmp)
y = tmp;
}
tree prev_x = NULL, prev_y = NULL;
if (TREE_CODE (x) == SSA_NAME)
- prev_x = get_value_for (x, const_and_copies);
+ prev_x = SSA_NAME_EQUIV (x);
if (TREE_CODE (y) == SSA_NAME)
- prev_y = get_value_for (y, const_and_copies);
+ prev_y = SSA_NAME_EQUIV (y);
/* If one of the previous values is invariant, then use that.
Otherwise it doesn't matter which value we choose, just so
nodes of the successors of BB. */
static void
-cprop_into_successor_phis (basic_block bb,
- varray_type const_and_copies,
- bitmap nonzero_vars)
+cprop_into_successor_phis (basic_block bb, bitmap nonzero_vars)
{
edge e;
/* 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));
+ new = SSA_NAME_EQUIV (orig);
if (new
&& (TREE_CODE (new) == SSA_NAME
|| is_gimple_min_invariant (new))
cprop_into_phis (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb)
{
- cprop_into_successor_phis (bb, const_and_copies, nonzero_vars);
+ cprop_into_successor_phis (bb, nonzero_vars);
}
/* Search for redundant computations in STMT. If any are found, then
if (may_optimize_p
&& (TREE_CODE (rhs) == SSA_NAME
|| is_gimple_min_invariant (rhs)))
- set_value_for (lhs, rhs, const_and_copies);
+ SET_SSA_NAME_EQUIV (lhs, rhs);
/* alloca never returns zero and the address of a non-weak symbol
is never zero. NOP_EXPRs and CONVERT_EXPRs can be completely
CONST_AND_COPIES. */
static bool
-cprop_operand (tree stmt, use_operand_p op_p, varray_type const_and_copies)
+cprop_operand (tree stmt, use_operand_p op_p)
{
bool may_have_exposed_new_symbols = false;
tree val;
/* 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));
+ val = SSA_NAME_EQUIV (op);
if (val)
{
tree op_type, val_type;
v_may_def_ops of STMT. */
static bool
-cprop_into_stmt (tree stmt, varray_type const_and_copies)
+cprop_into_stmt (tree stmt)
{
bool may_have_exposed_new_symbols = false;
use_operand_p op_p;
FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_ALL_USES)
{
if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
- may_have_exposed_new_symbols
- |= cprop_operand (stmt, op_p, const_and_copies);
+ may_have_exposed_new_symbols |= cprop_operand (stmt, op_p);
}
if (may_have_exposed_new_symbols)
}
/* Const/copy propagate into USES, VUSES and the RHS of V_MAY_DEFs. */
- may_have_exposed_new_symbols = cprop_into_stmt (stmt, const_and_copies);
+ may_have_exposed_new_symbols = cprop_into_stmt (stmt);
/* If the statement has been modified with constant replacements,
fold its RHS before checking for redundant computations. */
use the value from the const_and_copies table. */
if (TREE_CODE (lhs) == SSA_NAME)
{
- temp = get_value_for (lhs, const_and_copies);
+ temp = SSA_NAME_EQUIV (lhs);
if (temp)
lhs = temp;
}
gcc_assert (!stmt || EXPR_P (stmt) || TREE_CODE (stmt) == PHI_NODE);
- /* If our free list has an element, then use it. Also reuse the
- SSA version number of the element on the free list which helps
- keep sbitmaps and arrays sized HIGHEST_SSA_VERSION smaller. */
+ /* If our free list has an element, then use it. */
if (free_ssanames)
{
- unsigned int save_version;
-
t = free_ssanames;
free_ssanames = TREE_CHAIN (free_ssanames);
#ifdef GATHER_STATISTICS
ssa_name_nodes_reused++;
#endif
- /* Clear the node so that it looks just like one we would have
- received from make_node. */
- save_version = SSA_NAME_VERSION (t);
- memset (t, 0, tree_size (t));
- TREE_SET_CODE (t, SSA_NAME);
- SSA_NAME_VERSION (t) = save_version;
- gcc_assert (ssa_name (save_version) == NULL);
- VARRAY_TREE (ssa_names, save_version) = t;
+ /* The node was cleared out when we put it on the free list, so
+ there is no need to do so again here. */
+ gcc_assert (ssa_name (SSA_NAME_VERSION (t)) == NULL);
+ VARRAY_TREE (ssa_names, SSA_NAME_VERSION (t)) = t;
}
else
{
defining statement. */
if (! SSA_NAME_IN_FREE_LIST (var))
{
+ tree saved_ssa_name_var = SSA_NAME_VAR (var);
+ int saved_ssa_name_version = SSA_NAME_VERSION (var);
+
VARRAY_TREE (ssa_names, SSA_NAME_VERSION (var)) = NULL;
+ memset (var, 0, tree_size (var));
+
+ /* First put back the right tree node so that the tree checking
+ macros do not complain. */
+ TREE_SET_CODE (var, SSA_NAME);
+
+ /* Restore the version number. */
+ SSA_NAME_VERSION (var) = saved_ssa_name_version;
+
+ /* Hopefully this can go away once we have the new incremental
+ SSA updating code installed. */
+ SSA_NAME_VAR (var) = saved_ssa_name_var;
+
+ /* Note this SSA_NAME is now in the first list. */
SSA_NAME_IN_FREE_LIST (var) = 1;
+
+ /* And finally link it into the free list. */
TREE_CHAIN (var) = free_ssanames;
free_ssanames = var;
}