diff options
author | kazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-05-16 18:10:20 +0000 |
---|---|---|
committer | kazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-05-16 18:10:20 +0000 |
commit | 20bd2b8f26d4b7957c48def53e01dad3819ef351 (patch) | |
tree | 190b74b60da193369716ce267136a6cac2bec1b2 /gcc/tree-ssa-copy.c | |
parent | 43f0dc660b1640bdd34653a3c3a948d448aa6ca1 (diff) | |
download | gcc-20bd2b8f26d4b7957c48def53e01dad3819ef351.tar.gz |
* tree-ssa-copy.c (copy_prop_visit_assignment): Clean up by
folding a COND_EXPR_COND in a nondestructive manner.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99782 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-copy.c')
-rw-r--r-- | gcc/tree-ssa-copy.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index dd4c5debc5c..5f4033d3a9b 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -594,32 +594,18 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p) { enum ssa_prop_result retval; tree cond; - use_operand_p use_p; - ssa_op_iter iter; - unsigned num; - cond = COND_EXPR_COND (stmt); retval = SSA_PROP_VARYING; - num = NUM_SSA_OPERANDS (stmt, SSA_OP_USE); /* 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) - && num >= 1) + && TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME + && TREE_CODE (TREE_OPERAND (cond, 1)) == SSA_NAME) { - unsigned i; - tree *orig; - - /* 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)); - } + tree op0 = get_last_copy_of (TREE_OPERAND (cond, 0)); + tree op1 = get_last_copy_of (TREE_OPERAND (cond, 1)); /* See if we can determine the predicate's value. */ if (dump_file && (dump_flags & TDF_DETAILS)) @@ -629,22 +615,20 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p) print_generic_stmt (dump_file, cond, 0); } - /* We can fold COND only and get a useful result only when we - have the same SSA_NAME on both sides of a comparison - operator. */ - if (TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME - && TREE_OPERAND (cond, 0) == TREE_OPERAND (cond, 1)) + /* We can fold COND and get a useful result only when we have + the same SSA_NAME on both sides of a comparison operator. */ + if (op0 == op1) { - *taken_edge_p = find_taken_edge (bb_for_stmt (stmt), fold (cond)); - if (*taken_edge_p) - retval = SSA_PROP_INTERESTING; + tree folded_cond = fold_binary (TREE_CODE (cond), boolean_type_node, + op0, op1); + 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) |