re PR tree-optimization/87126 (ICE on valid code at -Os and above on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Wed, 29 Aug 2018 06:47:14 +0000 (06:47 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 29 Aug 2018 06:47:14 +0000 (06:47 +0000)
2018-08-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87126
* tree-ssa-sccvn.c (vn_reference_insert): Remove assert.

* gcc.dg/tree-ssa/pr87126.c: New testcase.

From-SVN: r263944

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

index c41507662dddf8cd2bdbc4f8fed495eb1b5467a9..03a98c90ab28b21d33d63459eda3842e79a0b831 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87126
+       * tree-ssa-sccvn.c (vn_reference_insert): Remove assert.
+
 2018-08-28  Jim Wilson  <jimw@sifive.com>
 
        * config/riscv/pic.md: Rewrite.
index 72f5a95984e78374578cbe1f28f557a2c09ca168..e6a9c8610cd282900d9cf009b17fb09eeb80dac1 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87126
+       * gcc.dg/tree-ssa/pr87126.c: New testcase.
+
 2018-08-28 MCC CS <deswurstes@users.noreply.github.com>
 
        PR tree-optimization/87009
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr87126.c b/gcc/testsuite/gcc.dg/tree-ssa/pr87126.c
new file mode 100644 (file)
index 0000000..37232ba
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+
+int a, *b;
+
+void f ()
+{ 
+  int d = 0, e = d;
+  while (a++)
+    ;
+  if (e)
+    goto L2;
+L1:
+  d = e;
+  b = &d;
+L2:
+  if (d)
+    goto L1;
+}
+
+/* The load of d could be eliminated if we'd value-number the
+   irreducible region in RPO of the reducible result.  Likewise
+   a redundant store could be removed.  */
+/* { dg-final { scan-tree-dump-times "d = 0;" 1 "fre1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not " = d;" "fre1" { xfail *-*-* } } } */
index 2556b0c45271a3019421216b9a47b09383f64966..aaac430bb46e1dda432f5f7ad5aac70cd4344857 100644 (file)
@@ -2696,7 +2696,17 @@ vn_reference_insert (tree op, tree result, tree vuse, tree vdef)
      but save a lookup if we deal with already inserted refs here.  */
   if (*slot)
     {
-      gcc_assert (operand_equal_p ((*slot)->result, vr1->result, 0));
+      /* We cannot assert that we have the same value either because
+         when disentangling an irreducible region we may end up visiting
+        a use before the corresponding def.  That's a missed optimization
+        only though.  See gcc.dg/tree-ssa/pr87126.c for example.  */
+      if (dump_file && (dump_flags & TDF_DETAILS)
+         && !operand_equal_p ((*slot)->result, vr1->result, 0))
+       {
+         fprintf (dump_file, "Keeping old value ");
+         print_generic_expr (dump_file, (*slot)->result);
+         fprintf (dump_file, " because of collision\n");
+       }
       free_reference (vr1);
       obstack_free (&vn_tables_obstack, vr1);
       return;