From: Richard Biener Date: Mon, 9 Nov 2020 13:32:41 +0000 (+0100) Subject: tree-optimization/97761 - fix SLP live calculation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=96f315213f337c2d5a9268f2d3e8337bbdb71bfc;p=gcc.git tree-optimization/97761 - fix SLP live calculation This removes a premature end of the DFS walk. 2020-11-09 Richard Biener PR tree-optimization/97761 * tree-vect-slp.c (vect_bb_slp_mark_live_stmts): Remove premature end of DFS walk. * gfortran.dg/vect/pr97761.f90: New testcase. --- diff --git a/gcc/testsuite/gfortran.dg/vect/pr97761.f90 b/gcc/testsuite/gfortran.dg/vect/pr97761.f90 new file mode 100644 index 00000000000..250e2bf016e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/pr97761.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! { dg-additional-options "-O1" } + +subroutine ni (ps) + type vector + real x, y + end type + type quad_inductor + type (vector) v1, v2 + end type + type (quad_inductor), dimension(inout) :: ps + integer :: dl, nk = 1.0 + fo = 1.0 + if (f == 1) then + nk = 0.0 + fo = 0.0 + end if + ot = nk * 0.5 + gb = -fo * 0.5 + wu = fo * 0.5 + up = nk * 0.1 + xe = up * 0.1 + do lx = 0, 7 + ps%v2%y = -wu + ps(dl)%v1%x = xe + 1.0 + ps(dl)%v1%y = wu - tn + end do + do lx = 0, 7 + ps(dl)%v1%x = 0.1 - ot + ps(dl)%v1%y = 0.1 - wu + end do +end diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 88e637e30dc..e4c2aa480e5 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3549,12 +3549,10 @@ vect_bb_slp_mark_live_stmts (bb_vec_info bb_vinfo, slp_tree node, unsigned i; stmt_vec_info stmt_info; stmt_vec_info last_stmt = vect_find_last_scalar_stmt_in_slp (node); - bool all_visited = true; FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt_info) { if (svisited.contains (stmt_info)) continue; - all_visited = false; stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info); if (STMT_VINFO_IN_PATTERN_P (orig_stmt_info) && STMT_VINFO_RELATED_STMT (orig_stmt_info) != stmt_info) @@ -3628,8 +3626,6 @@ vect_bb_slp_mark_live_stmts (bb_vec_info bb_vinfo, slp_tree node, if (mark_visited) svisited.add (stmt_info); } - if (all_visited) - return; slp_tree child; FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)