[PATCH] Adjust BB vectorization function splitting

Richard Biener rguenther@suse.de
Tue Oct 27 14:03:09 GMT 2020


This adjusts the condition when to split at control altering stmts,
only when there's a definition.  It also removes the only use
of --param slp-max-insns-in-bb which a previous change left doing
nothing (but repeatedly print a message for each successive
instruction...).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

2020-10-27  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp.c (vect_slp_bbs): Remove no-op
	slp-max-insns-in-bb check.
	(vect_slp_function): Dump when splitting the function.
	Adjust the split condition for control altering stmts.
	* params.opt (-param=slp-max-insns-in-bb): Remove.
	* doc/invoke.texi (-param=slp-max-insns-in-bb): Likewise.
---
 gcc/doc/invoke.texi |  4 ----
 gcc/params.opt      |  4 ----
 gcc/tree-vect-slp.c | 36 +++++++++++++++++++++++-------------
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index edea7ee25ba..f82eeea097a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -13749,10 +13749,6 @@ code to iterate.  2 allows partial vector loads and stores in all loops.
 The parameter only has an effect on targets that support partial
 vector loads and stores.
 
-@item slp-max-insns-in-bb
-Maximum number of instructions in basic block to be
-considered for SLP vectorization.
-
 @item avoid-fma-max-bits
 Maximum number of bits for which we avoid creating FMAs.
 
diff --git a/gcc/params.opt b/gcc/params.opt
index e05f7ffa446..563c67c11f2 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -855,10 +855,6 @@ The number of prefetches that can run at the same time.
 Common Joined UInteger Var(param_sink_frequency_threshold) Init(75) IntegerRange(0, 100) Param Optimization
 Target block's relative execution frequency (as a percentage) required to sink a statement.
 
--param=slp-max-insns-in-bb=
-Common Joined UInteger Var(param_slp_max_insns_in_bb) Init(1000) Param Optimization
-Maximum number of instructions in basic block to be considered for SLP vectorization.
-
 -param=sms-dfa-history=
 Common Joined UInteger Var(param_sms_dfa_history) IntegerRange(0, 16) Param Optimization
 The number of cycles the swing modulo scheduler considers when checking conflicts using DFA.
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index f544b552a46..ba43adb8a7d 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -4336,14 +4336,6 @@ vect_slp_bbs (vec<basic_block> bbs)
 	  if (!vect_find_stmt_data_reference (NULL, stmt, &datarefs,
 					      &dataref_groups, current_group))
 	    ++current_group;
-
-	  if (insns > param_slp_max_insns_in_bb)
-	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "not vectorized: too many instructions in "
-				 "region.\n");
-	    }
 	}
     }
 
@@ -4386,14 +4378,26 @@ vect_slp_function (function *fun)
       /* Split when a BB is not dominated by the first block.  */
       if (!bbs.is_empty ()
 	  && !dominated_by_p (CDI_DOMINATORS, bb, bbs[0]))
-	split = true;
+	{
+	  if (dump_enabled_p ())
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "splitting region at dominance boundary bb%d\n",
+			     bb->index);
+	  split = true;
+	}
       /* Split when the loop determined by the first block
 	 is exited.  This is because we eventually insert
 	 invariants at region begin.  */
       else if (!bbs.is_empty ()
 	       && bbs[0]->loop_father != bb->loop_father
 	       && !flow_loop_nested_p (bbs[0]->loop_father, bb->loop_father))
-	split = true;
+	{
+	  if (dump_enabled_p ())
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "splitting region at loop %d exit at bb%d\n",
+			     bbs[0]->loop_father->num, bb->index);
+	  split = true;
+	}
 
       if (split && !bbs.is_empty ())
 	{
@@ -4404,11 +4408,17 @@ vect_slp_function (function *fun)
       else
 	bbs.safe_push (bb);
 
-      /* When we have a stmt ending this block we have to insert on
-	 edges when inserting after it.  Avoid this for now.  */
+      /* When we have a stmt ending this block and defining a
+	 value we have to insert on edges when inserting after it for
+	 a vector containing its definition.  Avoid this for now.  */
       if (gimple *last = last_stmt (bb))
-	if (is_ctrl_altering_stmt (last))
+	if (gimple_get_lhs (last)
+	    && is_ctrl_altering_stmt (last))
 	  {
+	    if (dump_enabled_p ())
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "splitting region at control altering "
+			       "definition %G", last);
 	    r |= vect_slp_bbs (bbs);
 	    bbs.truncate (0);
 	  }
-- 
2.26.2


More information about the Gcc-patches mailing list