From: Prathamesh Kulkarni Date: Thu, 21 Nov 2019 20:20:36 +0000 (+0000) Subject: Use safe_dyn_cast instead of dyn_cast in find_loop_guard to fix PR92608. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b30e83f809b2aa65222eb969f8b4523e5e1961f2;p=gcc.git Use safe_dyn_cast instead of dyn_cast in find_loop_guard to fix PR92608. 2019-11-22 Prathamesh Kulkarni 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2525bcd3bc8..ab777929799 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-11-22 Prathamesh Kulkarni + + 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 * config/rs6000/predicates.md (extra_insn_branch_comparison_operator): diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7916f1a23cd..48bf697be0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-22 Prathamesh Kulkarni + + PR tree-optimization/92608 + * gcc.dg/torture/pr92608.c: New test. + 2019-11-21 Iain Sandoe 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 index 00000000000..3a6beaba441 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr92608.c @@ -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; +} diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 49951eb21b6..dbca6429abb 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -586,7 +586,7 @@ find_loop_guard (class loop *loop) next = single_succ (header); else { - cond = dyn_cast (last_stmt (header)); + cond = safe_dyn_cast (last_stmt (header)); if (! cond) return NULL; extract_true_false_edges_from_block (header, &te, &fe);