re PR tree-optimization/87168 (ICE on valid code at -Os and above on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Fri, 31 Aug 2018 16:50:13 +0000 (16:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 31 Aug 2018 16:50:13 +0000 (16:50 +0000)
2018-08-31  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87168
* tree-ssa-sccvn.c (SSA_VAL): Add visited output parameter.
(rpo_elim::eliminate_avail): When OP was not visited it must
be available.

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

From-SVN: r264021

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

index e48b983..79aa7ce 100644 (file)
@@ -1,3 +1,10 @@
+2018-08-31  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87168
+       * tree-ssa-sccvn.c (SSA_VAL): Add visited output parameter.
+       (rpo_elim::eliminate_avail): When OP was not visited it must
+       be available.
+
 2018-08-31  David Malcolm  <dmalcolm@redhat.com>
 
        * tree-vrp.c (copy_value_range): Convert param "from" from
index c10f1d2..757dd1b 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-31  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87168
+       * gcc.dg/torture/pr87168.c: New testcase.
+
 2018-08-31  Vlad Lazar  <vlad.lazar@arm.com>
 
        * gcc.target/aarch64/scalar_intrinsics.c (test_vnegd_s64): New.
diff --git a/gcc/testsuite/gcc.dg/torture/pr87168.c b/gcc/testsuite/gcc.dg/torture/pr87168.c
new file mode 100644 (file)
index 0000000..d66ed98
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+int a, b, c, d, e, f, *g;
+
+int main ()
+{ 
+  unsigned i;
+  while (b)
+    { 
+      int j, m;
+L1:
+      f = j;
+L2:
+      if (i && e)
+       { 
+         i = f;
+         goto L2;
+       }
+      j = f;
+      if (a)
+       goto L3;
+      for (m = 0; m < 2; m++)
+       if (d)
+         goto L1;
+      goto L2;
+L3:
+      (&j != g) | c;
+    }
+  return 0;
+}
index 2bf71e5..c333b89 100644 (file)
@@ -456,9 +456,11 @@ VN_INFO (tree name)
 /* Return the SSA value of X.  */
 
 inline tree
-SSA_VAL (tree x)
+SSA_VAL (tree x, bool *visited = NULL)
 {
   vn_ssa_aux_t tem = vn_ssa_aux_hash->find_with_hash (x, SSA_NAME_VERSION (x));
+  if (visited)
+    *visited = tem && tem->visited;
   return tem && tem->visited ? tem->valnum : x;
 }
 
@@ -5681,7 +5683,12 @@ rpo_elim::~rpo_elim ()
 tree
 rpo_elim::eliminate_avail (basic_block bb, tree op)
 {
-  tree valnum = SSA_VAL (op);
+  bool visited;
+  tree valnum = SSA_VAL (op, &visited);
+  /* If we didn't visit OP then it must be defined outside of the
+     region we process and also dominate it.  So it is available.  */
+  if (!visited)
+    return op;
   if (TREE_CODE (valnum) == SSA_NAME)
     {
       if (SSA_NAME_IS_DEFAULT_DEF (valnum))