[PATCH] Remove dead code in BB vectorization

Richard Biener <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
The following removes the dead bail-out from unrolling during BB
vectorization which is catched earlier and handled by failing
discovery.

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

	* tree-vect-slp.cc (vect_build_slp_instance): Remove dead code.
	(vect_analyze_slp_instance): Likewise.
---
 gcc/tree-vect-slp.cc | 181 ++++++++++++++++---------------------------
 1 file changed, 65 insertions(+), 116 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 1a832b53e3d..30f70453b2b 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -4347,72 +4347,47 @@ vect_build_slp_instance (vec_info *vinfo,
       /* Calculate the unrolling factor based on the smallest type.  */
       poly_uint64 unrolling_factor
 	= calculate_unrolling_factor (max_nunits, group_size);
+      gcc_assert (!is_a <bb_vec_info> (vinfo)
+		  || known_eq (unrolling_factor, 1U));
 
-      if (maybe_ne (unrolling_factor, 1U)
-	  && is_a <bb_vec_info> (vinfo))
-	{
-	  unsigned HOST_WIDE_INT const_max_nunits;
-	  if (!max_nunits.is_constant (&const_max_nunits)
-	      || const_max_nunits > group_size)
-	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "Build SLP failed: store group "
-				 "size not a multiple of the vector size "
-				 "in basic block SLP\n");
-	      vect_free_slp_tree (node);
-	      return false;
-	    }
-	  /* Fatal mismatch.  */
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
-			     "SLP discovery succeeded but node needs "
-			     "splitting\n");
-	  memset (matches, true, group_size);
-	  matches[group_size / const_max_nunits * const_max_nunits] = false;
-	  vect_free_slp_tree (node);
-	}
-      else
-	{
-	  /* Create a new SLP instance.  */
-	  slp_instance new_instance = XNEW (class _slp_instance);
-	  SLP_INSTANCE_TREE (new_instance) = node;
-	  SLP_INSTANCE_LOADS (new_instance) = vNULL;
-	  SLP_INSTANCE_ROOT_STMTS (new_instance) = root_stmt_infos;
-	  SLP_INSTANCE_REMAIN_DEFS (new_instance) = remain;
-	  SLP_INSTANCE_KIND (new_instance) = kind;
-	  new_instance->reduc_phis = NULL;
-	  new_instance->cost_vec = vNULL;
-	  new_instance->subgraph_entries = vNULL;
-
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
-			     "SLP size %u vs. limit %u.\n",
-			     tree_size, max_tree_size);
+      /* Create a new SLP instance.  */
+      slp_instance new_instance = XNEW (class _slp_instance);
+      SLP_INSTANCE_TREE (new_instance) = node;
+      SLP_INSTANCE_LOADS (new_instance) = vNULL;
+      SLP_INSTANCE_ROOT_STMTS (new_instance) = root_stmt_infos;
+      SLP_INSTANCE_REMAIN_DEFS (new_instance) = remain;
+      SLP_INSTANCE_KIND (new_instance) = kind;
+      new_instance->reduc_phis = NULL;
+      new_instance->cost_vec = vNULL;
+      new_instance->subgraph_entries = vNULL;
 
-	  vinfo->slp_instances.safe_push (new_instance);
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "SLP size %u vs. limit %u.\n",
+			 tree_size, max_tree_size);
 
-	  /* ???  We've replaced the old SLP_INSTANCE_GROUP_SIZE with
-	     the number of SLP lanes of the root in a few places.
-	     Verify that assumption holds.  */
-	  gcc_assert (SLP_TREE_LANES (SLP_INSTANCE_TREE (new_instance))
-		       == group_size);
+      vinfo->slp_instances.safe_push (new_instance);
 
-	  if (dump_enabled_p ())
-	    {
-	      if (kind == slp_inst_kind_reduc_group)
-		dump_printf_loc (MSG_NOTE, vect_location,
-				 "SLP discovery of size %d reduction group "
-				 "succeeded\n", group_size);
-	      dump_printf_loc (MSG_NOTE, vect_location,
-			       "Final SLP tree for instance %p:\n",
-			       (void *) new_instance);
-	      vect_print_slp_graph (MSG_NOTE, vect_location,
-				    SLP_INSTANCE_TREE (new_instance));
-	    }
+      /* ???  We've replaced the old SLP_INSTANCE_GROUP_SIZE with
+	 the number of SLP lanes of the root in a few places.
+	 Verify that assumption holds.  */
+      gcc_assert (SLP_TREE_LANES (SLP_INSTANCE_TREE (new_instance))
+		  == group_size);
 
-	  return true;
+      if (dump_enabled_p ())
+	{
+	  if (kind == slp_inst_kind_reduc_group)
+	    dump_printf_loc (MSG_NOTE, vect_location,
+			     "SLP discovery of size %d reduction group "
+			     "succeeded\n", group_size);
+	  dump_printf_loc (MSG_NOTE, vect_location,
+			   "Final SLP tree for instance %p:\n",
+			   (void *) new_instance);
+	  vect_print_slp_graph (MSG_NOTE, vect_location,
+				SLP_INSTANCE_TREE (new_instance));
 	}
+
+      return true;
     }
   /* Failed to SLP.  */
 
@@ -5257,68 +5232,42 @@ vect_analyze_slp_instance (vec_info *vinfo,
       /* Calculate the unrolling factor based on the smallest type.  */
       poly_uint64 unrolling_factor
 	= calculate_unrolling_factor (max_nunits, group_size);
+      gcc_assert (!is_a <bb_vec_info> (vinfo)
+		  || known_eq (unrolling_factor, 1U));
 
-      if (maybe_ne (unrolling_factor, 1U)
-	  && is_a <bb_vec_info> (vinfo))
-	{
-	  unsigned HOST_WIDE_INT const_max_nunits;
-	  if (!max_nunits.is_constant (&const_max_nunits)
-	      || const_max_nunits > group_size)
-	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "Build SLP failed: store group "
-				 "size not a multiple of the vector size "
-				 "in basic block SLP\n");
-	      vect_free_slp_tree (node);
-	      return false;
-	    }
-	  /* Fatal mismatch.  */
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
-			     "SLP discovery succeeded but node needs "
-			     "splitting\n");
-	  memset (matches, true, group_size);
-	  matches[group_size / const_max_nunits * const_max_nunits] = false;
-	  vect_free_slp_tree (node);
-	}
-      else
-	{
-	  /* Create a new SLP instance.  */
-	  slp_instance new_instance = XNEW (class _slp_instance);
-	  SLP_INSTANCE_TREE (new_instance) = node;
-	  SLP_INSTANCE_LOADS (new_instance) = vNULL;
-	  SLP_INSTANCE_ROOT_STMTS (new_instance) = root_stmt_infos;
-	  SLP_INSTANCE_REMAIN_DEFS (new_instance) = remain;
-	  SLP_INSTANCE_KIND (new_instance) = kind;
-	  new_instance->reduc_phis = NULL;
-	  new_instance->cost_vec = vNULL;
-	  new_instance->subgraph_entries = vNULL;
-
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
-			     "SLP size %u vs. limit %u.\n",
-			     tree_size, max_tree_size);
+      /* Create a new SLP instance.  */
+      slp_instance new_instance = XNEW (class _slp_instance);
+      SLP_INSTANCE_TREE (new_instance) = node;
+      SLP_INSTANCE_LOADS (new_instance) = vNULL;
+      SLP_INSTANCE_ROOT_STMTS (new_instance) = root_stmt_infos;
+      SLP_INSTANCE_REMAIN_DEFS (new_instance) = remain;
+      SLP_INSTANCE_KIND (new_instance) = kind;
+      new_instance->reduc_phis = NULL;
+      new_instance->cost_vec = vNULL;
+      new_instance->subgraph_entries = vNULL;
 
-	  vinfo->slp_instances.safe_push (new_instance);
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "SLP size %u vs. limit %u.\n",
+			 tree_size, max_tree_size);
 
-	  /* ???  We've replaced the old SLP_INSTANCE_GROUP_SIZE with
-	     the number of SLP lanes of the root in a few places.
-	     Verify that assumption holds.  */
-	  gcc_assert (SLP_TREE_LANES (SLP_INSTANCE_TREE (new_instance))
-		      == group_size);
+      vinfo->slp_instances.safe_push (new_instance);
 
-	  if (dump_enabled_p ())
-	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
-			       "Final SLP tree for instance %p:\n",
-			       (void *) new_instance);
-	      vect_print_slp_graph (MSG_NOTE, vect_location,
-				    SLP_INSTANCE_TREE (new_instance));
-	    }
+      /* ???  We've replaced the old SLP_INSTANCE_GROUP_SIZE with
+	 the number of SLP lanes of the root in a few places.
+	 Verify that assumption holds.  */
+      gcc_assert (SLP_TREE_LANES (SLP_INSTANCE_TREE (new_instance))
+		  == group_size);
 
-	  return true;
+      if (dump_enabled_p ())
+	{
+	  dump_printf_loc (MSG_NOTE, vect_location,
+			   "Final SLP tree for instance %p:\n",
+			   (void *) new_instance);
+	  vect_print_slp_graph (MSG_NOTE, vect_location,
+				SLP_INSTANCE_TREE (new_instance));
 	}
+      return true;
     }
   /* Failed to SLP.  */
 
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.