The following fixes up two places we access STMT_VINFO_VECTYPE that's
not covered by the fixup in vect_analyze/transform_stmt to set that
from SLP_TREE_VECTYPE.

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

        * tree-vect-loop.cc (vectorizable_reduction): Get the
        output vector type from slp_for_stmt_info.
        * tree-vect-stmts.cc (vect_analyze_stmt): Bail out earlier
        for PURE_SLP_STMT when doing loop stmt analysis.
---
 gcc/tree-vect-loop.cc  |  2 +-
 gcc/tree-vect-stmts.cc | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 9cee5195077..5a0736280ad 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7823,7 +7823,7 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
         inside the loop body. The last operand is the reduction variable,
         which is defined by the loop-header-phi.  */
 
-  tree vectype_out = STMT_VINFO_VECTYPE (stmt_info);
+  tree vectype_out = SLP_TREE_VECTYPE (slp_for_stmt_info);
   STMT_VINFO_REDUC_VECTYPE (reduc_info) = vectype_out;
   STMT_VINFO_REDUC_VECTYPE_IN (reduc_info) = vectype_in;
 
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index b9609488292..717f3e02629 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -13424,6 +13424,14 @@ vect_analyze_stmt (vec_info *vinfo,
         gcc_unreachable ();
     }
 
+  if (PURE_SLP_STMT (stmt_info) && !node)
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "handled only by SLP analysis\n");
+      return opt_result::success ();
+    }
+
   tree saved_vectype = STMT_VINFO_VECTYPE (stmt_info);
   if (node)
     STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (node);
@@ -13437,14 +13445,6 @@ vect_analyze_stmt (vec_info *vinfo,
       *need_to_vectorize = true;
     }
 
-  if (PURE_SLP_STMT (stmt_info) && !node)
-    {
-      if (dump_enabled_p ())
-       dump_printf_loc (MSG_NOTE, vect_location,
-                        "handled only by SLP analysis\n");
-      return opt_result::success ();
-    }
-
   /* When we arrive here with a non-SLP statement and we are supposed
      to use SLP for everything fail vectorization.  */
   if (!node)
-- 
2.43.0

Reply via email to