Split up vectorizable_lc_phi and create a vect_transform_lc_phi.
---
 gcc/tree-vect-loop.cc  | 30 +++++++++++++++++-------------
 gcc/tree-vect-stmts.cc |  4 ++--
 gcc/tree-vectorizer.h  |  2 ++
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index b2fa2703d34..7a4fd74c837 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -9031,21 +9031,25 @@ vectorizable_lc_phi (loop_vec_info loop_vinfo,
       && STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def)
     return false;
 
-  if (!vec_stmt) /* transformation not required.  */
+  /* Deal with copies from externs or constants that disguise as
+     loop-closed PHI nodes (PR97886).  */
+  if (!vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
+					 SLP_TREE_VECTYPE (slp_node)))
     {
-      /* Deal with copies from externs or constants that disguise as
-	 loop-closed PHI nodes (PR97886).  */
-      if (!vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
-					     SLP_TREE_VECTYPE (slp_node)))
-	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "incompatible vector types for invariants\n");
-	  return false;
-	}
-      STMT_VINFO_TYPE (stmt_info) = lc_phi_info_type;
-      return true;
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "incompatible vector types for invariants\n");
+      return false;
     }
+  STMT_VINFO_TYPE (stmt_info) = lc_phi_info_type;
+  return true;
+}
+
+bool
+vect_transform_lc_phi (loop_vec_info loop_vinfo,
+		       stmt_vec_info stmt_info, gimple **vec_stmt,
+		       slp_tree slp_node)
+{
 
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
   tree scalar_dest = gimple_phi_result (stmt_info->stmt);
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index e99a1df2c96..26fde7df1ff 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -14234,8 +14234,8 @@ vect_transform_stmt (vec_info *vinfo,
       break;
 
     case lc_phi_info_type:
-      done = vectorizable_lc_phi (as_a <loop_vec_info> (vinfo),
-				  stmt_info, &vec_stmt, slp_node);
+      done = vect_transform_lc_phi (as_a <loop_vec_info> (vinfo),
+				    stmt_info, &vec_stmt, slp_node);
       gcc_assert (done);
       break;
 
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 9f6ca01fd2a..6c7aa428dbd 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2612,6 +2612,8 @@ extern bool vect_transform_cycle_phi (loop_vec_info, stmt_vec_info,
 				      slp_tree, slp_instance);
 extern bool vectorizable_lc_phi (loop_vec_info, stmt_vec_info,
 				 gimple**, slp_tree);
+extern bool vect_transform_lc_phi (loop_vec_info, stmt_vec_info,
+				   gimple**, slp_tree);
 extern bool vectorizable_phi (vec_info *, stmt_vec_info, gimple **, slp_tree,
 			      stmt_vector_for_cost *);
 extern bool vectorizable_recurr (loop_vec_info, stmt_vec_info,

Reply via email to