re PR tree-optimization/63800 (ICE on valid code at -O3 on x86_64-linux-gnu)
authorRichard Biener <rguenther@suse.de>
Mon, 10 Nov 2014 14:31:31 +0000 (14:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 10 Nov 2014 14:31:31 +0000 (14:31 +0000)
2014-11-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/63800
* tree-ssa-pre.c (eliminate_push_avail): Push in a way so
we can restore the previous availability in after_dom_children.
(eliminate_dom_walker::after_dom_children): Restore
previous availability.

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

From-SVN: r217288

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

index a2157f63203c3eeccb0d709244af886cbf144620..663ba2c9748c576f909c0fa9cf402137995ac628 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/63800
+       * tree-ssa-pre.c (eliminate_push_avail): Push in a way so
+       we can restore the previous availability in after_dom_children.
+       (eliminate_dom_walker::after_dom_children): Restore
+       previous availability.
+
 2014-11-10  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/63798
index 9695c2eece640c15ad23c25a1e7c255a40000ae7..a3ef6295428f37623db4928ce4e1d8ad7e054c84 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/63800
+       * gcc.dg/torture/pr63800.c: New testcase.
+
 2014-11-10  Marek Polacek  <polacek@redhat.com>
 
        * c-c++-common/ubsan/align-7.c: Skip for -flto -fno-fat-lto-objects.
diff --git a/gcc/testsuite/gcc.dg/torture/pr63800.c b/gcc/testsuite/gcc.dg/torture/pr63800.c
new file mode 100644 (file)
index 0000000..19546c2
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+int a, b, c, d[2];
+
+int
+fn1 ()
+{
+  int f = 0;
+  d[1] = b = 1; 
+  for (; b; b--)
+    {
+      for (c = 0; c < 2; c++)
+       {
+         d[b] & 1 & b;
+         if (d[0])
+           f = d[b] * a;
+         if (f)
+           return 0;
+       }
+      d[b] && (d[0] = 0);
+    }
+  return 0;
+}
index 776dacf206bf9ee9d136de88683ab33b596baa38..ea991989267d887007d51cba69ed14a41e78c78a 100644 (file)
@@ -3906,8 +3906,11 @@ eliminate_push_avail (tree op)
     {
       if (el_avail.length () <= SSA_NAME_VERSION (valnum))
        el_avail.safe_grow_cleared (SSA_NAME_VERSION (valnum) + 1);
+      tree pushop = op;
+      if (el_avail[SSA_NAME_VERSION (valnum)])
+       pushop = el_avail[SSA_NAME_VERSION (valnum)];
+      el_avail_stack.safe_push (pushop);
       el_avail[SSA_NAME_VERSION (valnum)] = op;
-      el_avail_stack.safe_push (op);
     }
 }
 
@@ -4451,7 +4454,14 @@ eliminate_dom_walker::after_dom_children (basic_block)
 {
   tree entry;
   while ((entry = el_avail_stack.pop ()) != NULL_TREE)
-    el_avail[SSA_NAME_VERSION (VN_INFO (entry)->valnum)] = NULL_TREE;
+    {
+      tree valnum = VN_INFO (entry)->valnum;
+      tree old = el_avail[SSA_NAME_VERSION (valnum)];
+      if (old == entry)
+       el_avail[SSA_NAME_VERSION (valnum)] = NULL_TREE;
+      else
+       el_avail[SSA_NAME_VERSION (valnum)] = entry;
+    }
 }
 
 /* Eliminate fully redundant computations.  */