re PR tree-optimization/84803 (ICE from ifcvt_memrefs_wont_trap with -O3)
authorRichard Biener <rguenther@suse.de>
Mon, 12 Mar 2018 12:32:28 +0000 (12:32 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 12 Mar 2018 12:32:28 +0000 (12:32 +0000)
2018-03-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/84803
* tree-if-conv.c (ifcvt_memrefs_wont_trap): Don't do anything
for refs DR analysis didn't process.

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

From-SVN: r258446

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr84803.c [new file with mode: 0644]
gcc/tree-if-conv.c

index bc08bae91febed42387026880178d6c44032f3d2..548de755bb7cfd984c191417af0baa6238c0993a 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84803
+       * tree-if-conv.c (ifcvt_memrefs_wont_trap): Don't do anything
+       for refs DR analysis didn't process.
+
 2018-03-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84777
index 69c00d1b23e4c26e92bff54413ca838dd34299b0..c13747ad1b69d601508346b26f99b5c3dbf58028 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84803
+       * gcc.dg/torture/pr84803.c: New testcase.
+
 2018-03-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84813
diff --git a/gcc/testsuite/gcc.dg/torture/pr84803.c b/gcc/testsuite/gcc.dg/torture/pr84803.c
new file mode 100644 (file)
index 0000000..81aad62
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+long a;
+long *b;
+void c ();
+void d ();
+void
+e (long f)
+{
+  if (a)
+    *b = f;
+}
+void
+g ()
+{
+  c (g, e);
+}
+void
+c (int f, int h ())
+{
+  d (f, h, "");
+}
+void
+d (int f, int h (), char *i, char *k)
+{
+  int j;
+  d (f, h, i + 1, k);
+  while (--j)
+    h (*i);
+}
index c68a0c72d988a79f63c42419e1fb2a6b62c700af..71dac4fb48a1c3f500affcf7bb66cc258c3d5b07 100644 (file)
@@ -864,6 +864,11 @@ base_object_writable (tree ref)
 static bool
 ifcvt_memrefs_wont_trap (gimple *stmt, vec<data_reference_p> drs)
 {
+  /* If DR didn't see a reference here we can't use it to tell
+     whether the ref traps or not.  */
+  if (gimple_uid (stmt) == 0)
+    return false;
+
   data_reference_p *master_dr, *base_master_dr;
   data_reference_p a = drs[gimple_uid (stmt) - 1];