tree-vect-slp.c (vect_slp_analyze_node_operations): Only analyze the first scalar...
authorRichard Biener <rguenther@suse.de>
Fri, 30 Jun 2017 13:19:29 +0000 (13:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 30 Jun 2017 13:19:29 +0000 (13:19 +0000)
2017-06-30  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_slp_analyze_node_operations): Only
analyze the first scalar stmt.  Move vector type computation
for the BB case here from ...
* tree-vect-stmts.c (vect_analyze_stmt): ... here.  Guard
live operation processing in the SLP case properly.

From-SVN: r249839

gcc/ChangeLog
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c

index f4c435f70a2b1ce6f18f7ae68eb70321853f002c..a898fd40917734bdabf1d827174de823d8b9ca24 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-30  Richard Biener  <rguenther@suse.de>
+
+       * tree-vect-slp.c (vect_slp_analyze_node_operations): Only
+       analyze the first scalar stmt.  Move vector type computation
+       for the BB case here from ...
+       * tree-vect-stmts.c (vect_analyze_stmt): ... here.  Guard
+       live operation processing in the SLP case properly.
+
 2017-06-30  Richard Biener  <rguenther@suse.de>
 
        * graph.c (draw_cfg_node_succ_edges): Fix broken dot syntax.
index 9e7a20dbfe433f84b8b85a71e27bad32cb4d7e62..dd8658e32f04cf03f144652ad10980101fd7c06a 100644 (file)
@@ -2437,29 +2437,70 @@ vect_slp_analyze_node_operations (slp_tree node)
     if (!vect_slp_analyze_node_operations (child))
       return false;
 
-  bool res = true;
-  FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
+  stmt = SLP_TREE_SCALAR_STMTS (node)[0];
+  stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+  gcc_assert (stmt_info);
+  gcc_assert (STMT_SLP_TYPE (stmt_info) != loop_vect);
+
+  /* For BB vectorization vector types are assigned here.
+     Memory accesses already got their vector type assigned
+     in vect_analyze_data_refs.  */
+  bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
+  if (bb_vinfo
+      && ! STMT_VINFO_DATA_REF (stmt_info))
     {
-      stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-      gcc_assert (stmt_info);
-      gcc_assert (STMT_SLP_TYPE (stmt_info) != loop_vect);
-
-      /* Push SLP node def-type to stmt operands.  */
-      FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), j, child)
-       if (SLP_TREE_DEF_TYPE (child) != vect_internal_def)
-         STMT_VINFO_DEF_TYPE (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (child)[i]))
-           = SLP_TREE_DEF_TYPE (child);
-      res = vect_analyze_stmt (stmt, &dummy, node);
-      /* Restore def-types.  */
-      FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), j, child)
-       if (SLP_TREE_DEF_TYPE (child) != vect_internal_def)
-         STMT_VINFO_DEF_TYPE (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (child)[i]))
-           = vect_internal_def;
-      if (! res)
-       break;
+      gcc_assert (PURE_SLP_STMT (stmt_info));
+
+      tree scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
+      if (dump_enabled_p ())
+       {
+         dump_printf_loc (MSG_NOTE, vect_location,
+                          "get vectype for scalar type:  ");
+         dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
+         dump_printf (MSG_NOTE, "\n");
+       }
+
+      tree vectype = get_vectype_for_scalar_type (scalar_type);
+      if (!vectype)
+       {
+         if (dump_enabled_p ())
+           {
+             dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                              "not SLPed: unsupported data-type ");
+             dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                scalar_type);
+             dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+           }
+         return false;
+       }
+
+      if (dump_enabled_p ())
+       {
+         dump_printf_loc (MSG_NOTE, vect_location, "vectype:  ");
+         dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
+         dump_printf (MSG_NOTE, "\n");
+       }
+
+      gimple *sstmt;
+      FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, sstmt)
+       STMT_VINFO_VECTYPE (vinfo_for_stmt (sstmt)) = vectype;
     }
 
-  return res;
+  /* Push SLP node def-type to stmt operands.  */
+  FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), j, child)
+    if (SLP_TREE_DEF_TYPE (child) != vect_internal_def)
+      STMT_VINFO_DEF_TYPE (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (child)[0]))
+       = SLP_TREE_DEF_TYPE (child);
+  bool res = vect_analyze_stmt (stmt, &dummy, node);
+  /* Restore def-types.  */
+  FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), j, child)
+    if (SLP_TREE_DEF_TYPE (child) != vect_internal_def)
+      STMT_VINFO_DEF_TYPE (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (child)[0]))
+       = vect_internal_def;
+  if (! res)
+    return false;
+
+  return true;
 }
 
 
index e04390ec4b0ef11fa6bd231e95d7addd1f1d7cc6..9647c111d654f513961ed7791ee0908e3e8d100a 100644 (file)
@@ -8398,7 +8398,6 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node)
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
   enum vect_relevant relevance = STMT_VINFO_RELEVANT (stmt_info);
   bool ok;
-  tree scalar_type, vectype;
   gimple *pattern_stmt;
   gimple_seq pattern_def_seq;
 
@@ -8529,48 +8528,6 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node)
         gcc_unreachable ();
     }
 
-  if (bb_vinfo)
-    {
-      gcc_assert (PURE_SLP_STMT (stmt_info));
-
-      /* Memory accesses already got their vector type assigned
-         in vect_analyze_data_refs.  */
-      if (! STMT_VINFO_DATA_REF (stmt_info))
-       {
-         scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
-         if (dump_enabled_p ())
-           {
-             dump_printf_loc (MSG_NOTE, vect_location,
-                              "get vectype for scalar type:  ");
-             dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
-             dump_printf (MSG_NOTE, "\n");
-           }
-
-         vectype = get_vectype_for_scalar_type (scalar_type);
-         if (!vectype)
-           {
-             if (dump_enabled_p ())
-               {
-                 dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                  "not SLPed: unsupported data-type ");
-                 dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-                                    scalar_type);
-                 dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
-               }
-             return false;
-           }
-
-         if (dump_enabled_p ())
-           {
-             dump_printf_loc (MSG_NOTE, vect_location, "vectype:  ");
-             dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
-             dump_printf (MSG_NOTE, "\n");
-           }
-
-         STMT_VINFO_VECTYPE (stmt_info) = vectype;
-       }
-   }
-
   if (STMT_VINFO_RELEVANT_P (stmt_info))
     {
       gcc_assert (!VECTOR_MODE_P (TYPE_MODE (gimple_expr_type (stmt))));
@@ -8815,20 +8772,20 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       gimple *slp_stmt;
       int i;
-      FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (slp_node), i, slp_stmt)
-       {
-         stmt_vec_info slp_stmt_info = vinfo_for_stmt (slp_stmt);
-         if (STMT_VINFO_LIVE_P (slp_stmt_info)
-             && STMT_VINFO_TYPE (slp_stmt_info) != reduc_vec_info_type)
-           {
-             done = vectorizable_live_operation (slp_stmt, gsi, slp_node, i,
-                                                 &vec_stmt);
-             gcc_assert (done);
-           }
-       }
+      if (STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type)
+       FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (slp_node), i, slp_stmt)
+         {
+           stmt_vec_info slp_stmt_info = vinfo_for_stmt (slp_stmt);
+           if (STMT_VINFO_LIVE_P (slp_stmt_info))
+             {
+               done = vectorizable_live_operation (slp_stmt, gsi, slp_node, i,
+                                                   &vec_stmt);
+               gcc_assert (done);
+             }
+         }
     }
   else if (STMT_VINFO_LIVE_P (stmt_info)
-      && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type)
+          && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type)
     {
       done = vectorizable_live_operation (stmt, gsi, slp_node, -1, &vec_stmt);
       gcc_assert (done);