summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-pre.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-28 12:14:09 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-28 12:14:09 +0000
commit3dc4c394707f371f6082cd4ceb8947c0f256bca1 (patch)
treee22ed45816e3ff1acc6a5f7a1c09d36975f8d64f /gcc/tree-ssa-pre.c
parent613498113654a9e3b6bdcf4c53e6a77d93f0dac8 (diff)
downloadgcc-3dc4c394707f371f6082cd4ceb8947c0f256bca1.tar.gz
2009-01-28 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38926 * tree-ssa-pre.c (add_to_value): Assert we add only expressions with the correct value id to a value. (do_regular_insertion): Use the value number of edoubleprime for the value number of the expr. Revert 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. * gcc.c-torture/compile/pr38926.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143725 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r--gcc/tree-ssa-pre.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 0717a366bf3..a3f91f07d58 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -434,6 +434,7 @@ static tree create_expression_by_pieces (basic_block, pre_expr, gimple_seq *,
gimple, tree);
static tree find_or_generate_expression (basic_block, pre_expr, gimple_seq *,
gimple);
+static unsigned int get_expr_value_id (pre_expr);
/* We can add and remove elements and entries to and from sets
and hash tables, so we use alloc pools for them. */
@@ -559,6 +560,8 @@ add_to_value (unsigned int v, pre_expr e)
{
bitmap_set_t set;
+ gcc_assert (get_expr_value_id (e) == v);
+
if (v >= VEC_length (bitmap_set_t, value_expressions))
{
VEC_safe_grow_cleared (bitmap_set_t, heap, value_expressions,
@@ -2975,7 +2978,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, res;
+ tree temp;
gimple phi;
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -3131,8 +3134,12 @@ 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);
FOR_EACH_EDGE (pred, ei, block->preds)
{
pre_expr ae = avail[pred->src->index];
@@ -3143,20 +3150,6 @@ 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);
@@ -3330,7 +3323,7 @@ do_regular_insertion (basic_block block, basic_block dom)
pre_stats.constified++;
}
else
- info->valnum = PRE_EXPR_NAME (edoubleprime);
+ info->valnum = VN_INFO (PRE_EXPR_NAME (edoubleprime))->valnum;
info->value_id = new_val;
}
}