diff mbox series

Fix PR89572

Message ID alpine.LSU.2.20.1903041321100.32209@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR89572 | expand

Commit Message

Richard Biener March 4, 2019, 12:21 p.m. UTC
Bootstrapped & tested on x86_64-unknown-linux-gnu, applied.

Richard.

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.
diff mbox series

Patch

Index: gcc/tree-scalar-evolution.c
===================================================================
--- gcc/tree-scalar-evolution.c	(revision 269361)
+++ gcc/tree-scalar-evolution.c	(working copy)
@@ -910,7 +910,7 @@  get_loop_exit_condition (const struct lo
       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;
     }
 
Index: gcc/testsuite/gcc.dg/torture/pr89572.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr89572.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr89572.c	(working copy)
@@ -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);
+}