]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/38926 (ice in find_or_generate_expression, at tree-ssa-pre...
authorRichard Guenther <rguenther@suse.de>
Wed, 28 Jan 2009 12:14:09 +0000 (12:14 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 28 Jan 2009 12:14:09 +0000 (12:14 +0000)
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.

From-SVN: r143725

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr38926.c [new file with mode: 0644]
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c
gcc/tree-ssa-sccvn.h

index 66eb17200ced9787ba57ae8d97bd7103c508bdb9..526398f92c83233090d394e6212bfab9b2b89f03 100644 (file)
@@ -1,3 +1,19 @@
+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.
+
 2009-01-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/38934
index ae3d55a57ae249e32778c13fc5452a0fd41468d9..d3b7034f21af728f0c9ed7ac457e376c09f66377 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-28  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/38926
+       * gcc.c-torture/compile/pr38926.c: New testcase.
+
 2009-01-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/38934
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38926.c b/gcc/testsuite/gcc.c-torture/compile/pr38926.c
new file mode 100644 (file)
index 0000000..9c71a79
--- /dev/null
@@ -0,0 +1,41 @@
+static inline int foo (unsigned _si1)
+{
+  if (_si1 != 0)
+    if (_si1 > 2147483647)
+      return 1;
+  return 0;
+}
+
+static inline unsigned bar (unsigned _left, int _right)
+{
+  return (unsigned) _right >= 8 ? 1 : _left >> _right;
+}
+
+unsigned g_2;
+unsigned g_67;
+volatile unsigned g_162;
+
+static inline int func_62 (unsigned p_63)
+{
+  p_63 = g_2 & g_67;
+  if (g_2)
+    ;
+  else if (p_63)
+    return 1;
+  g_67 = bar (p_63, g_2);
+  return 0;
+}
+
+unsigned baz (void)
+{
+  if (g_2)
+    for (; g_2 <= -16; g_2 = foo (g_2))
+      {
+        for (; g_162; g_162)
+          func_62 (func_62 (0));
+        if (g_67)
+          break;
+      }
+  return g_2;
+}
+
index 0717a366bf380b6ab8d6fa78615374ed55dae69f..a3f91f07d58a8f14dc48fc1840434d4ab301f889 100644 (file)
@@ -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;
                    }
                }
index d9d5bc27d763826e8c98c10431be5ee6d7f04b90..87ddcb6872c26be03cb4f13dfee6437f9256004c 100644 (file)
@@ -1481,7 +1481,7 @@ static VEC(tree, heap) *shared_lookup_phiargs;
    value number if it exists in the hash table.  Return NULL_TREE if
    it does not exist in the hash table. */
 
-tree
+static tree
 vn_phi_lookup (gimple phi)
 {
   void **slot;
index 74f43c3df2ea429af0337f8a3b97fed3fcc701a5..df0f3dfe6e710d0c35463fc3ea36b8bd72f1b0aa 100644 (file)
@@ -184,7 +184,6 @@ vn_reference_t vn_reference_insert (tree, tree, VEC (tree, gc) *);
 vn_reference_t vn_reference_insert_pieces (VEC (tree, gc) *,
                                           VEC (vn_reference_op_s, heap) *,
                                           tree, unsigned int);
-tree vn_phi_lookup (gimple);
 
 hashval_t vn_nary_op_compute_hash (const vn_nary_op_t);
 int vn_nary_op_eq (const void *, const void *);