The following makes vect_analyze_stmt call vectorizable_* with all
STMT_VINFO_VECTYPE NULL_TREE but restores the value for eventual
iteration with single-lane SLP.  It clears it for every stmt during
vect_transform_stmt.

Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for
pushing after that long-running git operation finished.

Tamar, this should resolve what you've seen.

        * tree-vect-stmts.cc (vect_transform_stmt): Clear
        STMT_VINFO_VECTYPE for all stmts.
        (vect_analyze_stmt): Likewise.  But restore at the end again.
        * tree-vect-data-refs.cc (bump_vector_ptr): BUMP is always
        specified.
---
 gcc/tree-vect-stmts.cc | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 7435add077e..9da2a4b5ed6 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12623,10 +12623,8 @@ vect_analyze_stmt (vec_info *vinfo,
         gcc_unreachable ();
     }
 
-  if (! STMT_VINFO_DATA_REF (stmt_info))
-    STMT_VINFO_VECTYPE (stmt_info) = NULL_TREE;
-  else
-    STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (node);
+  tree saved_vectype = STMT_VINFO_VECTYPE (stmt_info);
+  STMT_VINFO_VECTYPE (stmt_info) = NULL_TREE;
 
   if (STMT_VINFO_RELEVANT_P (stmt_info))
     {
@@ -12672,6 +12670,8 @@ vect_analyze_stmt (vec_info *vinfo,
                                              stmt_info, NULL, node,
                                              cost_vec))));
 
+  STMT_VINFO_VECTYPE (stmt_info) = saved_vectype;
+
   if (!ok)
     return opt_result::failure_at (stmt_info->stmt,
                                   "not vectorized:"
@@ -12715,10 +12715,7 @@ vect_transform_stmt (vec_info *vinfo,
     dump_printf_loc (MSG_NOTE, vect_location,
                     "------>vectorizing statement: %G", stmt_info->stmt);
 
-  if (! STMT_VINFO_DATA_REF (stmt_info))
-    STMT_VINFO_VECTYPE (stmt_info) = NULL_TREE;
-  else
-    STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (slp_node);
+  STMT_VINFO_VECTYPE (stmt_info) = NULL_TREE;
 
   switch (SLP_TREE_TYPE (slp_node))
     {
-- 
2.43.0

Reply via email to