re PR tree-optimization/71059 (gcc ICE at -O3 on valid code on x86_64-linux-gnu in...
authorRichard Biener <rguenther@suse.de>
Thu, 12 May 2016 13:46:26 +0000 (13:46 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 12 May 2016 13:46:26 +0000 (13:46 +0000)
2016-05-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71059
* tree-ssa-pre.c (phi_translate_1): Fully fold translated
nary before looking up or entering the expression into the VN
hashes.
* tree-ssa-sccvn.c (vn_nary_build_or_lookup): Fix comment typo.
Make sure to re-use NARYs without result as inserted by
phi-translation.

* gcc.dg/torture/pr71059.c: New testcase.

From-SVN: r236175

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

index ddea24baf0d2b3d2aaf6f2fa40f05e8a7e4cf062..4edaf4ba2a487ebe22ff3e27814199e653f755fe 100644 (file)
@@ -1,3 +1,13 @@
+2016-05-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71059
+       * tree-ssa-pre.c (phi_translate_1): Fully fold translated
+       nary before looking up or entering the expression into the VN
+       hashes.
+       * tree-ssa-sccvn.c (vn_nary_build_or_lookup): Fix comment typo.
+       Make sure to re-use NARYs without result as inserted by
+       phi-translation.
+
 2016-05-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71062
index 6dca22fd18259ef3732f5fc20ebde0bd95c3b20b..5ecb1a331e56516342bd0fc1c06174f1067cacce 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71059
+       * gcc.dg/torture/pr71059.c: New testcase.
+
 2016-05-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71062
diff --git a/gcc/testsuite/gcc.dg/torture/pr71059.c b/gcc/testsuite/gcc.dg/torture/pr71059.c
new file mode 100644 (file)
index 0000000..7c0ab7f
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+short a, c;
+union {
+    unsigned f0;
+    unsigned short f1;
+} b;
+volatile int d;
+short fn1(short p1) { return p1 + a; }
+void fn2()
+{
+  b.f0 = 0;
+  for (;; b.f0 = fn1(b.f0))
+    (c && b.f1) || d;
+}
index 4a771d3b0be8ec297617e140087baa1805bb84f9..3ce87d9d23f4865541c360b996cb79e475c2d193 100644 (file)
@@ -1464,6 +1464,12 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
            pre_expr constant;
            unsigned int new_val_id;
 
+           PRE_EXPR_NARY (expr) = newnary;
+           constant = fully_constant_expression (expr);
+           PRE_EXPR_NARY (expr) = nary;
+           if (constant != expr)
+             return constant;
+
            tree result = vn_nary_op_lookup_pieces (newnary->length,
                                                    newnary->opcode,
                                                    newnary->type,
@@ -1478,10 +1484,6 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
            if (nary)
              {
                PRE_EXPR_NARY (expr) = nary;
-               constant = fully_constant_expression (expr);
-               if (constant != expr)
-                 return constant;
-
                new_val_id = nary->value_id;
                get_or_alloc_expression_id (expr);
              }
@@ -1495,9 +1497,6 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
                                                 &newnary->op[0],
                                                 result, new_val_id);
                PRE_EXPR_NARY (expr) = nary;
-               constant = fully_constant_expression (expr);
-               if (constant != expr)
-                 return constant;
                get_or_alloc_expression_id (expr);
              }
            add_to_value (new_val_id, expr);
index 1567fb96afb4a392335914714ab485091a2e37d5..730db04ff8bfa47f3b07aba9eac591fce8af37cf 100644 (file)
@@ -1632,7 +1632,7 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops)
 {
   tree result = NULL_TREE;
   /* We will be creating a value number for
-       ROCDE (OPS...).
+       RCODE (OPS...).
      So first simplify and lookup this expression to see if it
      is already available.  */
   mprts_hook = vn_lookup_simplify_result;
@@ -1682,6 +1682,16 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops)
       gimple_seq_add_stmt_without_update (&VN_INFO (result)->expr,
                                          new_stmt);
       VN_INFO (result)->needs_insertion = true;
+      /* ???  PRE phi-translation inserts NARYs without corresponding
+         SSA name result.  Re-use those but set their result according
+        to the stmt we just built.  */
+      vn_nary_op_t nary = NULL;
+      vn_nary_op_lookup_stmt (new_stmt, &nary);
+      if (nary)
+       {
+         gcc_assert (nary->result == NULL_TREE);
+         nary->result = gimple_assign_lhs (new_stmt);
+       }
       /* As all "inserted" statements are singleton SCCs, insert
         to the valid table.  This is strictly needed to
         avoid re-generating new value SSA_NAMEs for the same
@@ -1689,7 +1699,7 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops)
         optimistic table gets cleared after each iteration).
         We do not need to insert into the optimistic table, as
         lookups there will fall back to the valid table.  */
-      if (current_info == optimistic_info)
+      else if (current_info == optimistic_info)
        {
          current_info = valid_info;
          vn_nary_op_insert_stmt (new_stmt, result);