re PR tree-optimization/77646 (GCC Segfault with -O3)
authorRichard Biener <rguenther@suse.de>
Tue, 20 Sep 2016 12:20:37 +0000 (12:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 20 Sep 2016 12:20:37 +0000 (12:20 +0000)
2016-09-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/77646
* tree-ssa-sccvn.c (visit_reference_op_call): Always value-number
a VDEF.

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

From-SVN: r240261

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

index cef1504d9620cadddc7b042fa0c29bd28869e96f..7ab0b82009e3351fd7d8e22ff13802054dcc59fe 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77646
+       * tree-ssa-sccvn.c (visit_reference_op_call): Always value-number
+       a VDEF.
+
 2016-09-20  Tamar Christina  <tamar.christina@arm.com>
 
        * config/aarch64/arm_neon.h: Add gnu_inline and artificial
index ca54995cc6ada65d2ad22a397adbdd857d832f3e..9588beddba047e0657024b951a5ffb55c401178d 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77646
+       * gcc.dg/torture/pr77646.c: New testcase.
+
 2016-09-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/77434
diff --git a/gcc/testsuite/gcc.dg/torture/pr77646.c b/gcc/testsuite/gcc.dg/torture/pr77646.c
new file mode 100644 (file)
index 0000000..1b19900
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+struct e {
+    int (*f)();
+    void (*g)();
+} * c;
+int a;
+void *h();
+typedef struct { struct e j; } k;
+int l() { return a; }
+const struct e b = {l};
+void m()
+{
+  k *d = h();
+  d->j = b;
+  c = (struct e *)d;
+  struct e *i = c;
+  if (i->f(c))
+    while (i->f(c))
+      i->g();
+}
index e120b4f72dcd14931b6999b207cef0666aba39fa..bf5e97ae2f03846a8b907f41a1531f3053dbd51b 100644 (file)
@@ -3470,6 +3470,10 @@ visit_reference_op_call (tree lhs, gcall *stmt)
     {
       if (vnresult->result_vdef && vdef)
        changed |= set_ssa_val_to (vdef, vnresult->result_vdef);
+      else if (vdef)
+       /* If the call was discovered to be pure or const reflect
+          that as far as possible.  */
+       changed |= set_ssa_val_to (vdef, vuse_ssa_val (gimple_vuse (stmt)));
 
       if (!vnresult->result && lhs)
        vnresult->result = lhs;