tree-optimization/97761 - fix SLP live calculation
authorRichard Biener <rguenther@suse.de>
Mon, 9 Nov 2020 13:32:41 +0000 (14:32 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 9 Nov 2020 14:50:24 +0000 (15:50 +0100)
This removes a premature end of the DFS walk.

2020-11-09  Richard Biener  <rguenther@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 [new file with mode: 0644]
gcc/tree-vect-slp.c

diff --git a/gcc/testsuite/gfortran.dg/vect/pr97761.f90 b/gcc/testsuite/gfortran.dg/vect/pr97761.f90
new file mode 100644 (file)
index 0000000..250e2bf
--- /dev/null
@@ -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
index 88e637e..e4c2aa4 100644 (file)
@@ -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)