Use safe_dyn_cast instead of dyn_cast in find_loop_guard to fix PR92608.
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Thu, 21 Nov 2019 20:20:36 +0000 (20:20 +0000)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Thu, 21 Nov 2019 20:20:36 +0000 (20:20 +0000)
2019-11-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

PR tree-optimization/92608
* tree-ssa-loop-unswitch.c (find_loop_guard): Use safe_dyn_cast instead
of dyn_cast.

testsuite/
* gcc.dg/torture/pr92608.c: New test.

From-SVN: r278598

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

index 2525bcd3bc8c62fc75bea725420168f5be212c4b..ab7779297995c5dfb22488d303365b5b16c9192a 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR tree-optimization/92608
+       * tree-ssa-loop-unswitch.c (find_loop_guard): Use safe_dyn_cast instead
+       of dyn_cast.
+
 2019-11-21  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * config/rs6000/predicates.md (extra_insn_branch_comparison_operator):
index 7916f1a23cdb544052b16d614c24bfc954ccca1d..48bf697be0e9c044371ae8ad0e989e3568b3cf57 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR tree-optimization/92608
+       * gcc.dg/torture/pr92608.c: New test.
+
 2019-11-21  Iain Sandoe  <iain@sandoe.co.uk>
 
        PR testsuite/92619
diff --git a/gcc/testsuite/gcc.dg/torture/pr92608.c b/gcc/testsuite/gcc.dg/torture/pr92608.c
new file mode 100644 (file)
index 0000000..3a6beab
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-funswitch-loops" } */
+
+int op, bs;
+
+void
+q0 (void)
+{
+  op += 1 % (op == bs);
+}
+
+void __attribute__ ((returns_twice))
+co (void)
+{
+}
+
+void __attribute__ ((simd))
+uq (void)
+{
+  q0 ();
+  co ();
+
+  while (bs < 1)
+    ++bs;
+}
index 49951eb21b63f7845247b4703be38d8df715b9ce..dbca6429abbf8efe76421ee1c69cc20e7a632f39 100644 (file)
@@ -586,7 +586,7 @@ find_loop_guard (class loop *loop)
        next = single_succ (header);
       else
        {
-         cond = dyn_cast <gcond *> (last_stmt (header));
+         cond = safe_dyn_cast <gcond *> (last_stmt (header));
          if (! cond)
            return NULL;
          extract_true_false_edges_from_block (header, &te, &fe);