re PR tree-optimization/89572 (ICE in dyn_cast<gcond*, gimple>(gimple*) / get_loop_ex...
authorRichard Biener <rguenther@suse.de>
Mon, 4 Mar 2019 12:23:17 +0000 (12:23 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Mar 2019 12:23:17 +0000 (12:23 +0000)
2019-03-04  Richard Biener  <rguenther@suse.de>

PR middle-end/89572
* tree-scalar-evolution.c: (get_loop_exit_condition): Use
safe_dyn_cast.

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

From-SVN: r269363

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89572.c [new file with mode: 0644]
gcc/tree-scalar-evolution.c

index 024e018a25c3e8295691c23813a50bd71dfc7645..9fcb067526fa5559fda0381eb5cbe736e3706aed 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-04  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89572
+       * tree-scalar-evolution.c: (get_loop_exit_condition): Use
+       safe_dyn_cast.
+
 2019-03-04  Bin Cheng  <bin.cheng@linux.alibaba.com>
 
        PR tree-optimization/89487
index 0b089b9ceab58d9311b8391449c2323f323285e6..1a5c8673be41b06c3b0b02d9b3fe9246901cadf8 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-04  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89572
+       * gcc.dg/torture/pr89572.c: New testcase.
+
 2018-03-04  Bin Cheng  <bin.cheng@linux.alibaba.com>
 
        PR tree-optimization/89487
diff --git a/gcc/testsuite/gcc.dg/torture/pr89572.c b/gcc/testsuite/gcc.dg/torture/pr89572.c
new file mode 100644 (file)
index 0000000..1c29385
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-finline-functions" } */
+
+int vh, it, k1;
+
+void
+vn (void)
+{
+  ++vh;
+  if (vh == 0 && it == 0)
+    k1 = -k1;
+}
+
+__attribute__ ((returns_twice)) void
+ef (int *uw)
+{
+  while (uw != (void *) 0)
+    {
+      vn ();
+      *uw = 0;
+    }
+}
+
+void
+gu (int *uw)
+{
+  ef (uw);
+}
index 16debb0b34d4eab505d681af71b0f06ae83ddfe0..3de559047dae8e7ac881c9520b242ac99e1344e2 100644 (file)
@@ -910,7 +910,7 @@ get_loop_exit_condition (const struct loop *loop)
       gimple *stmt;
 
       stmt = last_stmt (exit_edge->src);
-      if (gcond *cond_stmt = dyn_cast <gcond *> (stmt))
+      if (gcond *cond_stmt = safe_dyn_cast <gcond *> (stmt))
        res = cond_stmt;
     }