re PR tree-optimization/89710 (ICE in dyn_cast<gcond*, gimple>(gimple*) / should_dupl...
authorRichard Biener <rguenther@suse.de>
Thu, 14 Mar 2019 11:07:41 +0000 (11:07 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 14 Mar 2019 11:07:41 +0000 (11:07 +0000)
2019-03-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89710
* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use
safe_dyn_cast.

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

From-SVN: r269679

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89710.c [new file with mode: 0644]
gcc/tree-ssa-loop-ch.c

index 86a231956c06dde8d96113aaacd3a5ae949e86cd..329954b78ac72d5b1adef7b2c4f6df0b220df4a3 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89710
+       * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use
+       safe_dyn_cast.
+
 2019-03-14  Martin Liska  <mliska@suse.cz>
 
        * coverage.c (coverage_begin_function): Stream also
index b0f9efa63fe63145fe4f52359f9c0437b31eb0a3..3536cf145e22ad672865957f1e7850fa6a03cf7e 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89710
+       * gcc.dg/torture/pr89710.c: New testcase.
+
 2019-03-14  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/89698
diff --git a/gcc/testsuite/gcc.dg/torture/pr89710.c b/gcc/testsuite/gcc.dg/torture/pr89710.c
new file mode 100644 (file)
index 0000000..01e875e
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+void
+gm (int *);
+
+__attribute__ ((returns_twice)) void
+jg (void)
+{
+}
+
+void
+eb (void)
+{
+  int r6 = 0;
+
+  if (r6 != 0)
+    gm (&r6);
+}
+
+void
+gm (int *r6)
+{
+  jg ();
+
+  for (;;)
+    {
+      eb ();
+      *r6 = 0;
+    }
+}
index f65e2b505675153295702e01366a90e04ef4087e..25f562b0cec0c358f9e04f600db6887a6c122cb9 100644 (file)
@@ -100,7 +100,7 @@ should_duplicate_loop_header_p (basic_block header, struct loop *loop,
       return false;
     }
 
-  gcond *last = dyn_cast <gcond *> (last_stmt (header));
+  gcond *last = safe_dyn_cast <gcond *> (last_stmt (header));
   if (!last)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))