summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-pre.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-21 15:18:58 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-08-21 15:18:58 +0000
commitbfcf04b8d058ecf9917f67a8451cc5be169a9649 (patch)
treed081e2983bcdcea812e826d40060ea64e94eb58a /gcc/tree-ssa-pre.c
parentb0464d7cbaef4239f9a240023309d48634f91a8e (diff)
downloadgcc-bfcf04b8d058ecf9917f67a8451cc5be169a9649.tar.gz
2008-08-21 Richard Guenther <rguenther@suse.de>
* tree-ssa-pre.c (insert_into_preds_of_block): Before inserting a PHI ask VN if it is already available. * tree-ssa-sccvn.h (vn_phi_lookup): Declare. * tree-ssa-sccvn.c (vn_phi_lookup): Export. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139388 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r--gcc/tree-ssa-pre.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index d2a55ae7ddc..606cafa1792 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2896,7 +2896,7 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
pre_expr eprime;
edge_iterator ei;
tree type = get_expr_type (expr);
- tree temp;
+ tree temp, res;
gimple phi;
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -3051,12 +3051,8 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
if (TREE_CODE (type) == COMPLEX_TYPE
|| TREE_CODE (type) == VECTOR_TYPE)
DECL_GIMPLE_REG_P (temp) = 1;
- phi = create_phi_node (temp, block);
- gimple_set_plf (phi, NECESSARY, false);
- VN_INFO_GET (gimple_phi_result (phi))->valnum = gimple_phi_result (phi);
- VN_INFO (gimple_phi_result (phi))->value_id = val;
- VEC_safe_push (gimple, heap, inserted_exprs, phi);
+ phi = create_phi_node (temp, block);
FOR_EACH_EDGE (pred, ei, block->preds)
{
pre_expr ae = avail[pred->src->index];
@@ -3067,6 +3063,20 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
else
add_phi_arg (phi, PRE_EXPR_NAME (avail[pred->src->index]), pred);
}
+ /* If the PHI node is already available, use it. */
+ if ((res = vn_phi_lookup (phi)) != NULL_TREE)
+ {
+ gimple_stmt_iterator gsi = gsi_for_stmt (phi);
+ remove_phi_node (&gsi, true);
+ release_defs (phi);
+ add_to_value (val, get_or_alloc_expr_for_name (res));
+ return false;
+ }
+
+ gimple_set_plf (phi, NECESSARY, false);
+ VN_INFO_GET (gimple_phi_result (phi))->valnum = gimple_phi_result (phi);
+ VN_INFO (gimple_phi_result (phi))->value_id = val;
+ VEC_safe_push (gimple, heap, inserted_exprs, phi);
newphi = get_or_alloc_expr_for_name (gimple_phi_result (phi));
add_to_value (val, newphi);