Commit 691aed8c by Kazu Hirata Committed by Kazu Hirata

tree-ssa-copy.c (copy_prop_visit_assignment): Clean up by folding a…

tree-ssa-copy.c (copy_prop_visit_assignment): Clean up by folding a COND_EXPR_COND in a nondestructive manner.

	* tree-ssa-copy.c (copy_prop_visit_assignment): Clean up by
	folding a COND_EXPR_COND in a nondestructive manner.

From-SVN: r99782
parent fe2d45c7
2005-05-16 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-copy.c (copy_prop_visit_assignment): Clean up by
folding a COND_EXPR_COND in a nondestructive manner.
2005-05-16 Fariborz Jahanian <fjahanian@apple.com> 2005-05-16 Fariborz Jahanian <fjahanian@apple.com>
* config/rs6000/altivec.md (altivec_vmrghb, altivec_vmrghh, * config/rs6000/altivec.md (altivec_vmrghb, altivec_vmrghh,
......
...@@ -594,32 +594,18 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p) ...@@ -594,32 +594,18 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p)
{ {
enum ssa_prop_result retval; enum ssa_prop_result retval;
tree cond; tree cond;
use_operand_p use_p;
ssa_op_iter iter;
unsigned num;
cond = COND_EXPR_COND (stmt); cond = COND_EXPR_COND (stmt);
retval = SSA_PROP_VARYING; retval = SSA_PROP_VARYING;
num = NUM_SSA_OPERANDS (stmt, SSA_OP_USE);
/* The only conditionals that we may be able to compute statically /* The only conditionals that we may be able to compute statically
are predicates involving at least one SSA_NAME. */ are predicates involving two SSA_NAMEs. */
if (COMPARISON_CLASS_P (cond) if (COMPARISON_CLASS_P (cond)
&& num >= 1) && TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME
&& TREE_CODE (TREE_OPERAND (cond, 1)) == SSA_NAME)
{ {
unsigned i; tree op0 = get_last_copy_of (TREE_OPERAND (cond, 0));
tree *orig; tree op1 = get_last_copy_of (TREE_OPERAND (cond, 1));
/* Save the original operands. */
orig = xmalloc (sizeof (tree) * num);
i = 0;
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
{
tree use = USE_FROM_PTR (use_p);
orig[i++] = use;
SET_USE (use_p, get_last_copy_of (use));
}
/* See if we can determine the predicate's value. */ /* See if we can determine the predicate's value. */
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
...@@ -629,22 +615,20 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p) ...@@ -629,22 +615,20 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p)
print_generic_stmt (dump_file, cond, 0); print_generic_stmt (dump_file, cond, 0);
} }
/* We can fold COND only and get a useful result only when we /* We can fold COND and get a useful result only when we have
have the same SSA_NAME on both sides of a comparison the same SSA_NAME on both sides of a comparison operator. */
operator. */ if (op0 == op1)
if (TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME
&& TREE_OPERAND (cond, 0) == TREE_OPERAND (cond, 1))
{ {
*taken_edge_p = find_taken_edge (bb_for_stmt (stmt), fold (cond)); tree folded_cond = fold_binary (TREE_CODE (cond), boolean_type_node,
if (*taken_edge_p) op0, op1);
retval = SSA_PROP_INTERESTING; if (folded_cond)
{
basic_block bb = bb_for_stmt (stmt);
*taken_edge_p = find_taken_edge (bb, folded_cond);
if (*taken_edge_p)
retval = SSA_PROP_INTERESTING;
}
} }
/* Restore the original operands. */
i = 0;
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
SET_USE (use_p, orig[i++]);
free (orig);
} }
if (dump_file && (dump_flags & TDF_DETAILS) && *taken_edge_p) if (dump_file && (dump_flags & TDF_DETAILS) && *taken_edge_p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment