This removes a premature end of the DFS walk.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2020-11-09  Richard Biener  <rguent...@suse.de>

        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.
---
 gcc/testsuite/gfortran.dg/vect/pr97761.f90 | 32 ++++++++++++++++++++++
 gcc/tree-vect-slp.c                        |  4 ---
 2 files changed, 32 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/vect/pr97761.f90

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)
-- 
2.26.2

Reply via email to