+2007-08-26 Bernhard Fischer <aldot@gcc.gnu.org>
+
+ * tree-ssa-sccvn.c, tree-ssa-sccvn.h, tree-vn.c,
+ tree-ssa-pre.c: Remove unnecessary trailing whitespace.
+
2007-08-26 H.J. Lu <hongjiu.lu@intel.com>
PR target/32991
Fourth, we eliminate fully redundant expressions.
This is a simple statement walk that replaces redundant
- calculations with the now available values. */
+ calculations with the now available values. */
/* Representations of value numbers:
DEF_VEC_ALLOC_P (vuse_vec, heap);
static VEC(vuse_vec, heap) *expression_vuses;
-
+
/* Mapping from expression to id number we can use in bitmap sets. */
static VEC(tree, heap) *expressions;
static inline bool
constant_expr_p (tree v)
{
- return TREE_CODE (v) != VALUE_HANDLE &&
+ return TREE_CODE (v) != VALUE_HANDLE &&
(TREE_CODE (v) == FIELD_DECL || is_gimple_min_invariant (v));
}
the phis in PRED. SEEN is a bitmap saying which expression we have
translated since we started translation of the toplevel expression.
Return NULL if we can't find a leader for each part of the
- translated expression. */
+ translated expression. */
static tree
phi_translate_1 (tree expr, bitmap_set_t set1, bitmap_set_t set2,
{
tree val;
tree def = PHI_ARG_DEF (phi, e->dest_idx);
-
+
if (is_gimple_min_invariant (def))
return def;
-
+
if (is_undefined_value (def))
return NULL;
-
+
val = get_value_handle (def);
gcc_assert (val);
return def;
}
/* Translate EXPR using phis in PHIBLOCK, so that it has the values of
- the phis in PRED.
+ the phis in PRED.
Return NULL if we can't find a leader for each part of the
- translated expression. */
+ translated expression. */
static tree
phi_translate (tree expr, bitmap_set_t set1, bitmap_set_t set2,
}
/* Return true if OP is an exception handler related operation, such as
- FILTER_EXPRor EXC_PTR_EXPR. */
+ FILTER_EXPR or EXC_PTR_EXPR. */
static bool
is_exception_related (tree op)
static bool
can_value_number_operation (tree op)
{
- return (UNARY_CLASS_P (op)
+ return (UNARY_CLASS_P (op)
&& !is_exception_related (TREE_OPERAND (op, 0)))
|| BINARY_CLASS_P (op)
|| COMPARISON_CLASS_P (op)
NECESSARY (temp) = 0;
VN_INFO_GET (PHI_RESULT (temp))->valnum = PHI_RESULT (temp);
-
+
VEC_safe_push (tree, heap, inserted_exprs, temp);
FOR_EACH_EDGE (pred, ei, block->preds)
add_phi_arg (temp, avail[pred->src->index], pred);
}
/* Add OP to EXP_GEN (block), and possibly to the maximal set if it is
- not defined by a phi node.
+ not defined by a phi node.
PHI nodes can't go in the maximal sets because they are not in
TMP_GEN, so it is possible to get into non-monotonic situations
during ANTIC calculation, because it will *add* bits. */
vh = vn_lookup_with_vuses (t, vuses);
else
vh = vn_lookup (t);
-
+
if (!vh)
return NULL;
exprset = VALUE_HANDLE_EXPR_SET (vh);
}
if (TREE_CODE (op) != TREE_LIST)
add_to_exp_gen (block, op);
-
+
if (TREE_CODE (val) == VALUE_HANDLE)
TREE_TYPE (val) = TREE_TYPE (TREE_OPERAND (vexpr, i));
if (!valvh && !is_invariant)
{
tree defstmt = SSA_NAME_DEF_STMT (val);
-
+
gcc_assert (VN_INFO (val)->valnum == val);
/* PHI nodes can't have vuses and attempts to iterate over
their VUSE operands will crash. */
}
valvh = vn_lookup_or_add_with_stmt (val, defstmt);
}
-
+
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "SCCVN says ");
fprintf (dump_file, ")\n");
}
else
- print_generic_stmt (dump_file, val, 0);
+ print_generic_stmt (dump_file, val, 0);
}
if (valvh)
return valvh;
tree valvh = NULL_TREE;
tree lhsval;
VEC (tree, gc) *vuses = NULL;
-
+
valvh = get_sccvn_value (lhs);
if (valvh)
{
vn_add (lhs, valvh);
- bitmap_value_insert_into_set (AVAIL_OUT (block), lhs);
+ bitmap_value_insert_into_set (AVAIL_OUT (block), lhs);
/* Shortcut for FRE. We have no need to create value expressions,
just want to know what values are available where. */
if (in_fre)
bitmap_value_insert_into_set (AVAIL_OUT (block), lhs);
return true;
}
-
+
lhsval = valvh ? valvh : get_value_handle (lhs);
vuses = copy_vuses_from_stmt (stmt);
STRIP_USELESS_TYPE_CONVERSION (rhs);
tree val = vn_lookup_or_add_with_vuses (newt, vuses);
vn_add (lhs, val);
}
-
+
add_to_exp_gen (block, newt);
- }
-
+ }
+
bitmap_insert_into_set (TMP_GEN (block), lhs);
bitmap_value_insert_into_set (AVAIL_OUT (block), lhs);
return true;
|| TREE_INVARIANT (rhs)
|| DECL_P (rhs))
{
-
+
if (lhsval)
{
set_expression_vuses (rhs, vuses);
tree def = gimple_default_def (cfun, param);
vn_lookup_or_add (def);
- if (!in_fre)
+ if (!in_fre)
{
bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), def);
bitmap_value_insert_into_set (maximal_set, def);
sprime = bitmap_find_leader (AVAIL_OUT (b),
get_value_handle (lhs));
-
+
if (sprime
&& sprime != lhs
&& (TREE_CODE (*rhs_p) != SSA_NAME
init_pre (bool do_fre)
{
basic_block bb;
-
+
next_expression_id = 0;
expressions = NULL;
expression_vuses = NULL;
In order to value number memory, we assign value numbers to vuses.
This enables us to note that, for example, stores to the same
address of the same value from the same starting memory states are
- equivalent.
+ equivalent.
TODO:
1. We can iterate only the changing portions of the SCC's, but
}
/* Get the value numbering info for a given SSA name, creating it if
- it does not exist. */
+ it does not exist. */
vn_ssa_aux_t
VN_INFO_GET (tree name)
if (VEC_index (tree, vr2->vuses, i) != v)
return false;
}
-
+
for (i = 0; VEC_iterate (vn_reference_op_s, vr1->operands, i, vro); i++)
{
if (!vn_reference_op_eq (VEC_index (vn_reference_op_s, vr2->operands, i),
break;
default:
gcc_unreachable ();
-
+
}
VEC_safe_push (vn_reference_op_s, heap, *result, &temp);
/* Follow chains of copies to their destination. */
while (SSA_VAL (rhs) != rhs && TREE_CODE (SSA_VAL (rhs)) == SSA_NAME)
rhs = SSA_VAL (rhs);
-
+
/* The copy may have a more interesting constant filled expression
(we don't, since we know our RHS is just an SSA name). */
VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants;
VN_INFO (PHI_RESULT (phi))->has_constants = false;
VN_INFO (PHI_RESULT (phi))->expr = sameval;
}
-
+
if (TREE_CODE (sameval) == SSA_NAME)
return visit_copy (PHI_RESULT (phi), sameval);
-
+
return set_ssa_val_to (PHI_RESULT (phi), sameval);
}
have been value numbering optimistically, and
iterating. They may become non-constant in this case,
even if they were optimistically constant. */
-
+
VN_INFO (lhs)->has_constants = false;
VN_INFO (lhs)->expr = lhs;
}
if (VEC_length (tree, scc) == 1)
{
tree use = VEC_index (tree, scc, 0);
- if (!VN_INFO (use)->use_processed)
+ if (!VN_INFO (use)->use_processed)
visit_use (use);
}
else
SSA_NAME_VALUE (name) = NULL;
}
}
-
+
VEC_free (vn_ssa_aux_t, heap, vn_ssa_aux_table);
VEC_free (tree, heap, sccstack);
free_vn_table (valid_info);
void vn_reference_insert (tree, tree, VEC (tree, gc) *);
VEC (tree, gc) *shared_vuses_from_stmt (tree);
VEC (tree, gc) *copy_vuses_from_stmt (tree);
-
+
#endif /* TREE_SSA_SCCVN_H */
expressions_equal_p (tree e1, tree e2)
{
tree te1, te2;
-
+
if (e1 == e2)
return true;
return true;
}
- else if (TREE_CODE (e1) == TREE_CODE (e2)
+ else if (TREE_CODE (e1) == TREE_CODE (e2)
&& (te1 == te2
|| types_compatible_p (te1, te2))
&& operand_equal_p (e1, e2, OEP_PURE_SAME))
}
/* Set the value handle for expression E to value V. */
-
+
void
set_value_handle (tree e, tree v)
{
print_generic_expr (dump_file, v, dump_flags);
fprintf (dump_file, " for ");
print_generic_expr (dump_file, expr, dump_flags);
-
+
if (vuses && VEC_length (tree, vuses) != 0)
{
size_t i;
tree vuse;
-
+
fprintf (dump_file, " vuses: (");
for (i = 0; VEC_iterate (tree, vuses, i, vuse); i++)
{
fprintf (dump_file, ",");
}
fprintf (dump_file, ")");
- }
+ }
fprintf (dump_file, "\n");
}
/* Sort the VUSE array so that we can do equality comparisons
quicker on two vuse vecs. */
-void
+void
sort_vuses (VEC (tree,gc) *vuses)
{
if (VEC_length (tree, vuses) > 1)
/* Sort the VUSE array so that we can do equality comparisons
quicker on two vuse vecs. */
-void
+void
sort_vuses_heap (VEC (tree,heap) *vuses)
{
if (VEC_length (tree, vuses) > 1)
if (TREE_CODE (expr) == CALL_EXPR || DECL_P (expr))
return vn_reference_lookup (expr, NULL);
else if (TREE_CODE (expr) == SSA_NAME)
- return SSA_NAME_VALUE (expr);
+ return SSA_NAME_VALUE (expr);
else if (TREE_CODE (expr) == ADDR_EXPR)
return vn_unary_op_lookup (expr);
/* FALLTHROUGH */
/* Search in the value numbering tables for an existing instance of
expression EXPR, and return its value, or NULL if none has been set. STMT
- represents the stmt associated with EXPR. It is used when computing the
+ represents the stmt associated with EXPR. It is used when computing the
hash value for EXPR for reference operations. */
tree
create_value_handle_for_expr (tree expr, VEC(tree, gc) *vuses)
{
tree v;
-
+
v = make_value_handle (TREE_TYPE (expr));
-
+
if (dump_file && (dump_flags & TDF_DETAILS))
print_creation_to_file (v, expr, vuses);
return v;
vn_lookup_or_add (tree expr)
{
tree v = vn_lookup (expr);
-
+
if (v == NULL_TREE)
{
v = create_value_handle_for_expr (expr, NULL);
vn_lookup_or_add_with_vuses (tree expr, VEC (tree, gc) *vuses)
{
tree v;
-
+
if (!vuses || VEC_length (tree, vuses) == 0)
return vn_lookup_or_add (expr);
-
+
v = vn_lookup_with_vuses (expr, vuses);
if (v == NULL_TREE)
{