diff options
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr94329.f90 | 12 | ||||
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 14 |
4 files changed, 31 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3bfe5ff..52c296c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2020-03-28 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/94329 + * tree-ssa-reassoc.c (reassociate_bb): When calling reassoc_remove_stmt + on the last stmt in a bb, make sure gsi_prev isn't done immediately + after gsi_last_bb. + 2020-03-27 Alan Modra <amodra@gmail.com> PR target/94145 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7876b57..3e51175 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-03-28 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/94329 + * gfortran.dg/pr94329.f90: New test. + 2020-03-27 Jakub Jelinek <jakub@redhat.com> PR c++/94339 diff --git a/gcc/testsuite/gfortran.dg/pr94329.f90 b/gcc/testsuite/gfortran.dg/pr94329.f90 new file mode 100644 index 0000000..9efcf4b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr94329.f90 @@ -0,0 +1,12 @@ +! PR tree-optimization/94329 +! { dg-do compile } +! { dg-options "-O1 -fno-tree-loop-optimize -fwrapv -fcompare-debug" } + +subroutine pr94329 (s, t) + real :: s, t(:,:) + do i = 1,3 + do j = 1,3 + s = t(i,j) + end do + end do +end diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 14f9550..ec1c033 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -6224,8 +6224,11 @@ reassociate_bb (basic_block bb) if (stmt && !gimple_visited_p (stmt)) cfg_cleanup_needed |= maybe_optimize_range_tests (stmt); - for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) + bool do_prev = false; + for (gsi = gsi_last_bb (bb); + !gsi_end_p (gsi); do_prev ? gsi_prev (&gsi) : (void) 0) { + do_prev = true; stmt = gsi_stmt (gsi); if (is_gimple_assign (stmt) @@ -6246,15 +6249,12 @@ reassociate_bb (basic_block bb) release_defs (stmt); /* We might end up removing the last stmt above which places the iterator to the end of the sequence. - Reset it to the last stmt in this case which might - be the end of the sequence as well if we removed - the last statement of the sequence. In which case - we need to bail out. */ + Reset it to the last stmt in this case and make sure + we don't do gsi_prev in that case. */ if (gsi_end_p (gsi)) { gsi = gsi_last_bb (bb); - if (gsi_end_p (gsi)) - break; + do_prev = false; } } continue; |