diff options
author | Richard Biener <rguenther@suse.de> | 2019-03-14 09:14:30 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-03-14 09:14:30 +0000 |
commit | 2552fb9d979782d5265e32f5362850e973afe380 (patch) | |
tree | 65daae78e407a4069a989ac52e4064f417f2b4d7 /gcc | |
parent | 29363afdc38a9f1367bd50984540134a8cf76c72 (diff) | |
download | gcc-2552fb9d979782d5265e32f5362850e973afe380.zip gcc-2552fb9d979782d5265e32f5362850e973afe380.tar.gz gcc-2552fb9d979782d5265e32f5362850e973afe380.tar.bz2 |
re PR tree-optimization/89572 (ICE in dyn_cast<gcond*, gimple>(gimple*) / get_loop_exit_condition(loop const*))
2019-03-14 Richard Biener <rguenther@suse.de>
PR middle-end/89572
* tree-scalar-evolution.c (get_loop_exit_condition): Use
safe_dyn_cast.
* tree-ssa-loop-ivcanon.c (canonicalize_loop_induction_variables):
Use gimple_location_safe.
* gcc.dg/torture/pr89572.c: New testcase.
From-SVN: r269675
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr89572.c | 28 | ||||
-rw-r--r-- | gcc/tree-scalar-evolution.c | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-ivcanon.c | 4 |
5 files changed, 44 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c779ed4..038b1bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-03-14 Richard Biener <rguenther@suse.de> + + PR middle-end/89572 + * tree-scalar-evolution.c (get_loop_exit_condition): Use + safe_dyn_cast. + * tree-ssa-loop-ivcanon.c (canonicalize_loop_induction_variables): + Use gimple_location_safe. + 2019-03-13 Vladimir Makarov <vmakarov@redhat.com> PR target/85860 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 015e934..4ba559d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-14 Richard Biener <rguenther@suse.de> + + PR middle-end/89572 + * gcc.dg/torture/pr89572.c: New testcase. + 2019-03-13 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/87673 diff --git a/gcc/testsuite/gcc.dg/torture/pr89572.c b/gcc/testsuite/gcc.dg/torture/pr89572.c new file mode 100644 index 0000000..1c29385 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr89572.c @@ -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); +} diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index c955352..759bc61 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -875,7 +875,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; } diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 7f8b519..5b6db6a 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -1177,7 +1177,7 @@ canonicalize_loop_induction_variables (struct loop *loop, = niter_desc.may_be_zero && !integer_zerop (niter_desc.may_be_zero); } if (TREE_CODE (niter) == INTEGER_CST) - locus = gimple_location (last_stmt (exit->src)); + locus = gimple_location_safe (last_stmt (exit->src)); else { /* For non-constant niter fold may_be_zero into niter again. */ @@ -1204,7 +1204,7 @@ canonicalize_loop_induction_variables (struct loop *loop, niter = find_loop_niter_by_eval (loop, &exit); if (exit) - locus = gimple_location (last_stmt (exit->src)); + locus = gimple_location_safe (last_stmt (exit->src)); if (TREE_CODE (niter) != INTEGER_CST) exit = NULL; |