re PR tree-optimization/89789 (Compile time hog during RPO VN)
authorRichard Biener <rguenther@suse.de>
Mon, 25 Mar 2019 13:53:50 +0000 (13:53 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 25 Mar 2019 13:53:50 +0000 (13:53 +0000)
2019-03-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89789
* tree-ssa-sccvn.c (set_ssa_val_to): Do not allow lattice
changes from non-undefined back to undefined.

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

From-SVN: r269917

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

index d2db34b7189f58bbe7fdd366883532907015239b..3f72f505869d49a6a8ce4f193ea2406660f1ea2c 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89789
+       * tree-ssa-sccvn.c (set_ssa_val_to): Do not allow lattice
+       changes from non-undefined back to undefined.
+
 2019-03-25  Thomas Otto  <thomas.otto@pdv-fs.de>
 
        * dwarf2out.c (comp_dir_string): cached_wd could be set to both a
index 5aead43f1475ab53c8a84be1ecd11ece22d108c2..7e1978bde74dab9280ae7cfc47ad40880a79c4f5 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89789
+       * gcc.dg/torture/pr89789.c: New testcase.
+
 2019-03-25  Nathan Sidwell  <nathan@acm.org>
 
        * g++.dg/abi/lambda-static-1.C: New.
diff --git a/gcc/testsuite/gcc.dg/torture/pr89789.c b/gcc/testsuite/gcc.dg/torture/pr89789.c
new file mode 100644 (file)
index 0000000..2c19fab
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+int x2;
+
+void
+m2 (void)
+{
+  goto gg;
+
+  int fz, vh = 0;
+
+  for (fz = 0; fz < 1; ++fz)
+    {
+      vh ^= x2;
+
+      if (0)
+       {
+gg:
+         x2 %= 1;
+         x2 += vh;
+       }
+    }
+}
index 81604d2912a7db05fede7a38a83aeb198e3fc7d5..872f904ccc5cf4b90b94a772e5029327ab5993b0 100644 (file)
@@ -3746,10 +3746,13 @@ set_ssa_val_to (tree from, tree to)
            }
          return false;
        }
-      else if (currval != VN_TOP
-              && ! is_gimple_min_invariant (currval)
-              && ! ssa_undefined_value_p (currval, false)
-              && is_gimple_min_invariant (to))
+      bool curr_invariant = is_gimple_min_invariant (currval);
+      bool curr_undefined = (TREE_CODE (currval) == SSA_NAME
+                            && ssa_undefined_value_p (currval, false));
+      if (currval != VN_TOP
+         && !curr_invariant
+         && !curr_undefined
+         && is_gimple_min_invariant (to))
        {
          if (dump_file && (dump_flags & TDF_DETAILS))
            {
@@ -3764,6 +3767,24 @@ set_ssa_val_to (tree from, tree to)
            }
          to = from;
        }
+      else if (currval != VN_TOP
+              && !curr_undefined
+              && TREE_CODE (to) == SSA_NAME
+              && ssa_undefined_value_p (to, false))
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           {
+             fprintf (dump_file, "Forcing VARYING instead of changing "
+                      "value number of ");
+             print_generic_expr (dump_file, from);
+             fprintf (dump_file, " from ");
+             print_generic_expr (dump_file, currval);
+             fprintf (dump_file, " (non-undefined) to ");
+             print_generic_expr (dump_file, to);
+             fprintf (dump_file, " (undefined)\n");
+           }
+         to = from;
+       }
       else if (TREE_CODE (to) == SSA_NAME
               && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
        to = from;