diff mbox series

[2/8] Introduce VECT_SCOPE macro

Message ID 1529008375-20819-3-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series v2 of optimization records patch kit | expand

Commit Message

David Malcolm June 14, 2018, 8:32 p.m. UTC
The vectorizer code has numerous instances of:

  if (dump_enabled_p ())
    dump_printf_loc (MSG_NOTE, vect_location,
                     "=== some message ===\n");

In each case, the dump_printf_loc is a MSG_NODE at vect_location.

In almost all cases the message is of the form
  "=== foo ===\n"

The exceptions are:
  "===== analyze_loop_nest =====\n"
which uses 4 equal signs rather than 3, and
  "===vect_slp_analyze_bb===\n"
which is missing the spaces.

In most cases (but not always) the message matches the function name.

This patch replaces all of these with a macro, taking the message
as an argument (and forcing the use of three dashes and a space).

The idea is to later convert this macro to use an RAII type
that pushes and pops scope, so that the nesting structure appears
in the dumpfile and -fopt-info logs (and in the remarks and
optimization records introduced later in this patch kit).

The message is usually the function name, but not always.
Should I split this out into two macros? e.g. a VECT_FUNCTION_SCOPE
that uses __FUNCTION__?

Would DUMP_VECT_SCOPE be a better name, perhaps?

gcc/ChangeLog:
	* tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
	Replace dump_printf_loc call with VECT_SCOPE.
	(vect_slp_analyze_instance_dependence): Likewise.
	(vect_enhance_data_refs_alignment): Likewise.
	(vect_analyze_data_refs_alignment): Likewise.
	(vect_slp_analyze_and_verify_instance_alignment
	(vect_analyze_data_ref_accesses): Likewise.
	(vect_prune_runtime_alias_test_list): Likewise.
	(vect_analyze_data_refs): Likewise.
	* tree-vect-loop-manip.c (vect_update_inits_of_drs): Likewise.
	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
	(vect_analyze_scalar_cycles_1): Likewise.
	(vect_get_loop_niters): Likewise.
	(vect_analyze_loop_form_1): Likewise.
	(vect_update_vf_for_slp): Likewise.
	(vect_analyze_loop_operations): Likewise.
	(vect_analyze_loop): Likewise.
	(vectorizable_induction): Likewise.
	(vect_transform_loop): Likewise.
	* tree-vect-patterns.c (vect_pattern_recog): Likewise.
	* tree-vect-slp.c (vect_analyze_slp): Likewise.
	(vect_make_slp_decision): Likewise.
	(vect_detect_hybrid_slp): Likewise.
	(vect_slp_analyze_operations): Likewise.
	(vect_slp_bb): Likewise.
	* tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise.
	(vectorizable_bswap): Likewise.
	(vectorizable_call): Likewise.
	(vectorizable_simd_clone_call): Likewise.
	(vectorizable_conversion): Likewise.
	(vectorizable_assignment): Likewise.
	(vectorizable_shift): Likewise.
	(vectorizable_operation): Likewise.
	* tree-vectorizer.h (VECT_SCOPE): New macro.
---
 gcc/tree-vect-data-refs.c  | 32 ++++++++------------------------
 gcc/tree-vect-loop-manip.c |  4 +---
 gcc/tree-vect-loop.c       | 39 ++++++++++-----------------------------
 gcc/tree-vect-patterns.c   |  4 +---
 gcc/tree-vect-slp.c        | 18 +++++-------------
 gcc/tree-vect-stmts.c      | 32 ++++++++------------------------
 gcc/tree-vectorizer.h      | 10 ++++++++++
 7 files changed, 43 insertions(+), 96 deletions(-)

Comments

Jeff Law June 15, 2018, 8:11 p.m. UTC | #1
On 06/14/2018 02:32 PM, David Malcolm wrote:
> The vectorizer code has numerous instances of:
> 
>   if (dump_enabled_p ())
>     dump_printf_loc (MSG_NOTE, vect_location,
>                      "=== some message ===\n");
> 
> In each case, the dump_printf_loc is a MSG_NODE at vect_location.
> 
> In almost all cases the message is of the form
>   "=== foo ===\n"
> 
> The exceptions are:
>   "===== analyze_loop_nest =====\n"
> which uses 4 equal signs rather than 3, and
>   "===vect_slp_analyze_bb===\n"
> which is missing the spaces.
> 
> In most cases (but not always) the message matches the function name.
> 
> This patch replaces all of these with a macro, taking the message
> as an argument (and forcing the use of three dashes and a space).
> 
> The idea is to later convert this macro to use an RAII type
> that pushes and pops scope, so that the nesting structure appears
> in the dumpfile and -fopt-info logs (and in the remarks and
> optimization records introduced later in this patch kit).
> 
> The message is usually the function name, but not always.
> Should I split this out into two macros? e.g. a VECT_FUNCTION_SCOPE
> that uses __FUNCTION__?
> 
> Would DUMP_VECT_SCOPE be a better name, perhaps?
> 
> gcc/ChangeLog:
> 	* tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
> 	Replace dump_printf_loc call with VECT_SCOPE.
> 	(vect_slp_analyze_instance_dependence): Likewise.
> 	(vect_enhance_data_refs_alignment): Likewise.
> 	(vect_analyze_data_refs_alignment): Likewise.
> 	(vect_slp_analyze_and_verify_instance_alignment
> 	(vect_analyze_data_ref_accesses): Likewise.
> 	(vect_prune_runtime_alias_test_list): Likewise.
> 	(vect_analyze_data_refs): Likewise.
> 	* tree-vect-loop-manip.c (vect_update_inits_of_drs): Likewise.
> 	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
> 	(vect_analyze_scalar_cycles_1): Likewise.
> 	(vect_get_loop_niters): Likewise.
> 	(vect_analyze_loop_form_1): Likewise.
> 	(vect_update_vf_for_slp): Likewise.
> 	(vect_analyze_loop_operations): Likewise.
> 	(vect_analyze_loop): Likewise.
> 	(vectorizable_induction): Likewise.
> 	(vect_transform_loop): Likewise.
> 	* tree-vect-patterns.c (vect_pattern_recog): Likewise.
> 	* tree-vect-slp.c (vect_analyze_slp): Likewise.
> 	(vect_make_slp_decision): Likewise.
> 	(vect_detect_hybrid_slp): Likewise.
> 	(vect_slp_analyze_operations): Likewise.
> 	(vect_slp_bb): Likewise.
> 	* tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise.
> 	(vectorizable_bswap): Likewise.
> 	(vectorizable_call): Likewise.
> 	(vectorizable_simd_clone_call): Likewise.
> 	(vectorizable_conversion): Likewise.
> 	(vectorizable_assignment): Likewise.
> 	(vectorizable_shift): Likewise.
> 	(vectorizable_operation): Likewise.
> 	* tree-vectorizer.h (VECT_SCOPE): New macro.
OK.  But rather than using a macro, *consider* just using a normal
function.  I'm less and less inclined to use macros as I get older :-)

If there's a solid reason to use a macro, then that's fine.

DUMP_VECT_SCOPE seems better than VEC_SCOPE.
Jeff
Richard Biener June 18, 2018, 9:26 a.m. UTC | #2
On Fri, Jun 15, 2018 at 10:11 PM Jeff Law <law@redhat.com> wrote:
>
> On 06/14/2018 02:32 PM, David Malcolm wrote:
> > The vectorizer code has numerous instances of:
> >
> >   if (dump_enabled_p ())
> >     dump_printf_loc (MSG_NOTE, vect_location,
> >                      "=== some message ===\n");
> >
> > In each case, the dump_printf_loc is a MSG_NODE at vect_location.
> >
> > In almost all cases the message is of the form
> >   "=== foo ===\n"
> >
> > The exceptions are:
> >   "===== analyze_loop_nest =====\n"
> > which uses 4 equal signs rather than 3, and
> >   "===vect_slp_analyze_bb===\n"
> > which is missing the spaces.
> >
> > In most cases (but not always) the message matches the function name.
> >
> > This patch replaces all of these with a macro, taking the message
> > as an argument (and forcing the use of three dashes and a space).
> >
> > The idea is to later convert this macro to use an RAII type
> > that pushes and pops scope, so that the nesting structure appears
> > in the dumpfile and -fopt-info logs (and in the remarks and
> > optimization records introduced later in this patch kit).
> >
> > The message is usually the function name, but not always.
> > Should I split this out into two macros? e.g. a VECT_FUNCTION_SCOPE
> > that uses __FUNCTION__?
> >
> > Would DUMP_VECT_SCOPE be a better name, perhaps?
> >
> > gcc/ChangeLog:
> >       * tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
> >       Replace dump_printf_loc call with VECT_SCOPE.
> >       (vect_slp_analyze_instance_dependence): Likewise.
> >       (vect_enhance_data_refs_alignment): Likewise.
> >       (vect_analyze_data_refs_alignment): Likewise.
> >       (vect_slp_analyze_and_verify_instance_alignment
> >       (vect_analyze_data_ref_accesses): Likewise.
> >       (vect_prune_runtime_alias_test_list): Likewise.
> >       (vect_analyze_data_refs): Likewise.
> >       * tree-vect-loop-manip.c (vect_update_inits_of_drs): Likewise.
> >       * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
> >       (vect_analyze_scalar_cycles_1): Likewise.
> >       (vect_get_loop_niters): Likewise.
> >       (vect_analyze_loop_form_1): Likewise.
> >       (vect_update_vf_for_slp): Likewise.
> >       (vect_analyze_loop_operations): Likewise.
> >       (vect_analyze_loop): Likewise.
> >       (vectorizable_induction): Likewise.
> >       (vect_transform_loop): Likewise.
> >       * tree-vect-patterns.c (vect_pattern_recog): Likewise.
> >       * tree-vect-slp.c (vect_analyze_slp): Likewise.
> >       (vect_make_slp_decision): Likewise.
> >       (vect_detect_hybrid_slp): Likewise.
> >       (vect_slp_analyze_operations): Likewise.
> >       (vect_slp_bb): Likewise.
> >       * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise.
> >       (vectorizable_bswap): Likewise.
> >       (vectorizable_call): Likewise.
> >       (vectorizable_simd_clone_call): Likewise.
> >       (vectorizable_conversion): Likewise.
> >       (vectorizable_assignment): Likewise.
> >       (vectorizable_shift): Likewise.
> >       (vectorizable_operation): Likewise.
> >       * tree-vectorizer.h (VECT_SCOPE): New macro.
> OK.  But rather than using a macro, *consider* just using a normal
> function.  I'm less and less inclined to use macros as I get older :-)
>
> If there's a solid reason to use a macro, then that's fine.
>
> DUMP_VECT_SCOPE seems better than VEC_SCOPE.

Agreed on DUMP_VECT_SCOPE, using a function would somewhat
defeat the purpose of the dump_enabled_p () check.

Richard.

> Jeff
David Malcolm June 18, 2018, 7:06 p.m. UTC | #3
On Fri, 2018-06-15 at 14:11 -0600, Jeff Law wrote:
> On 06/14/2018 02:32 PM, David Malcolm wrote:
> > The vectorizer code has numerous instances of:
> > 
> >   if (dump_enabled_p ())
> >     dump_printf_loc (MSG_NOTE, vect_location,
> >                      "=== some message ===\n");
> > 
> > In each case, the dump_printf_loc is a MSG_NODE at vect_location.
> > 
> > In almost all cases the message is of the form
> >   "=== foo ===\n"
> > 
> > The exceptions are:
> >   "===== analyze_loop_nest =====\n"
> > which uses 4 equal signs rather than 3, and
> >   "===vect_slp_analyze_bb===\n"
> > which is missing the spaces.
> > 
> > In most cases (but not always) the message matches the function
> > name.
> > 
> > This patch replaces all of these with a macro, taking the message
> > as an argument (and forcing the use of three dashes and a space).
> > 
> > The idea is to later convert this macro to use an RAII type
> > that pushes and pops scope, so that the nesting structure appears
> > in the dumpfile and -fopt-info logs (and in the remarks and
> > optimization records introduced later in this patch kit).
> > 
> > The message is usually the function name, but not always.
> > Should I split this out into two macros? e.g. a VECT_FUNCTION_SCOPE
> > that uses __FUNCTION__?
> > 
> > Would DUMP_VECT_SCOPE be a better name, perhaps?
> > 
> > gcc/ChangeLog:
> > 	* tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
> > 	Replace dump_printf_loc call with VECT_SCOPE.
> > 	(vect_slp_analyze_instance_dependence): Likewise.
> > 	(vect_enhance_data_refs_alignment): Likewise.
> > 	(vect_analyze_data_refs_alignment): Likewise.
> > 	(vect_slp_analyze_and_verify_instance_alignment
> > 	(vect_analyze_data_ref_accesses): Likewise.
> > 	(vect_prune_runtime_alias_test_list): Likewise.
> > 	(vect_analyze_data_refs): Likewise.
> > 	* tree-vect-loop-manip.c (vect_update_inits_of_drs): Likewise.
> > 	* tree-vect-loop.c (vect_determine_vectorization_factor):
> > Likewise.
> > 	(vect_analyze_scalar_cycles_1): Likewise.
> > 	(vect_get_loop_niters): Likewise.
> > 	(vect_analyze_loop_form_1): Likewise.
> > 	(vect_update_vf_for_slp): Likewise.
> > 	(vect_analyze_loop_operations): Likewise.
> > 	(vect_analyze_loop): Likewise.
> > 	(vectorizable_induction): Likewise.
> > 	(vect_transform_loop): Likewise.
> > 	* tree-vect-patterns.c (vect_pattern_recog): Likewise.
> > 	* tree-vect-slp.c (vect_analyze_slp): Likewise.
> > 	(vect_make_slp_decision): Likewise.
> > 	(vect_detect_hybrid_slp): Likewise.
> > 	(vect_slp_analyze_operations): Likewise.
> > 	(vect_slp_bb): Likewise.
> > 	* tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized):
> > Likewise.
> > 	(vectorizable_bswap): Likewise.
> > 	(vectorizable_call): Likewise.
> > 	(vectorizable_simd_clone_call): Likewise.
> > 	(vectorizable_conversion): Likewise.
> > 	(vectorizable_assignment): Likewise.
> > 	(vectorizable_shift): Likewise.
> > 	(vectorizable_operation): Likewise.
> > 	* tree-vectorizer.h (VECT_SCOPE): New macro.
> 
> OK.  But rather than using a macro, *consider* just using a normal
> function.  I'm less and less inclined to use macros as I get older :-
> )
> 
> If there's a solid reason to use a macro, then that's fine.

The reason for doing it as a macro is that I'm planning to turn this
into an RAII-style class for pushing and popping scopes, capturing the
nesting.  That wouldn't work if it was a function.

> DUMP_VECT_SCOPE seems better than VEC_SCOPE.

Thanks.  I've committed the DUMP_VECT_SCOPE version of the patch as
r261710 (after usual testing)

Dave
diff mbox series

Patch

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 3eb67c9..fbc37d9 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -562,9 +562,7 @@  vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo,
   unsigned int i;
   struct data_dependence_relation *ddr;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_analyze_data_ref_dependences ===\n");
+  VECT_SCOPE ("vect_analyze_data_ref_dependences");
 
   LOOP_VINFO_DDRS (loop_vinfo)
     .create (LOOP_VINFO_DATAREFS (loop_vinfo).length ()
@@ -741,9 +739,7 @@  vect_slp_analyze_node_dependences (slp_instance instance, slp_tree node,
 bool
 vect_slp_analyze_instance_dependence (slp_instance instance)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_slp_analyze_instance_dependence ===\n");
+  VECT_SCOPE ("vect_slp_analyze_instance_dependence");
 
   /* The stores of this instance are at the root of the SLP tree.  */
   slp_tree store = SLP_INSTANCE_TREE (instance);
@@ -1685,9 +1681,7 @@  vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
   unsigned int mis, same_align_drs_max = 0;
   hash_table<peel_info_hasher> peeling_htab (1);
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_enhance_data_refs_alignment ===\n");
+  VECT_SCOPE ("vect_enhance_data_refs_alignment");
 
   /* Reset data so we can safely be called multiple times.  */
   LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo).truncate (0);
@@ -2345,9 +2339,7 @@  vect_find_same_alignment_drs (struct data_dependence_relation *ddr)
 bool
 vect_analyze_data_refs_alignment (loop_vec_info vinfo)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_analyze_data_refs_alignment ===\n");
+  VECT_SCOPE ("vect_analyze_data_refs_alignment");
 
   /* Mark groups of data references with same alignment using
      data dependence information.  */
@@ -2426,9 +2418,7 @@  vect_slp_analyze_and_verify_node_alignment (slp_tree node)
 bool
 vect_slp_analyze_and_verify_instance_alignment (slp_instance instance)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_slp_analyze_and_verify_instance_alignment ===\n");
+  VECT_SCOPE ("vect_slp_analyze_and_verify_instance_alignment");
 
   slp_tree node;
   unsigned i;
@@ -2931,9 +2921,7 @@  vect_analyze_data_ref_accesses (vec_info *vinfo)
   vec<data_reference_p> datarefs = vinfo->datarefs;
   struct data_reference *dr;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_analyze_data_ref_accesses ===\n");
+  VECT_SCOPE ("vect_analyze_data_ref_accesses");
 
   if (datarefs.is_empty ())
     return true;
@@ -3379,9 +3367,7 @@  vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
   unsigned int i;
   tree length_factor;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_prune_runtime_alias_test_list ===\n");
+  VECT_SCOPE ("vect_prune_runtime_alias_test_list");
 
   /* Step values are irrelevant for aliasing if the number of vector
      iterations is equal to the number of scalar iterations (which can
@@ -4075,9 +4061,7 @@  vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf)
   struct data_reference *dr;
   tree scalar_type;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_analyze_data_refs ===\n");
+  VECT_SCOPE ("vect_analyze_data_refs");
 
   if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo))
     loop = LOOP_VINFO_LOOP (loop_vinfo);
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 7443e7f..326c8dd 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -1733,9 +1733,7 @@  vect_update_inits_of_drs (loop_vec_info loop_vinfo, tree niters,
   vec<data_reference_p> datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
   struct data_reference *dr;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_update_inits_of_dr ===\n");
+  VECT_SCOPE ("vect_update_inits_of_dr");
 
   /* Adjust niters to sizetype and insert stmts on loop preheader edge.  */
   if (!types_compatible_p (sizetype, TREE_TYPE (niters)))
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 385d62f..77bd909 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -296,9 +296,7 @@  vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
   unsigned i;
   auto_vec<stmt_vec_info> mask_producers;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_determine_vectorization_factor ===\n");
+  VECT_SCOPE ("vect_determine_vectorization_factor");
 
   for (i = 0; i < nbbs; i++)
     {
@@ -479,9 +477,7 @@  vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
   gphi_iterator gsi;
   bool double_reduc;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_analyze_scalar_cycles ===\n");
+  VECT_SCOPE ("vect_analyze_scalar_cycles");
 
   /* First - identify all inductions.  Reduction detection assumes that all the
      inductions have been identified, therefore, this order must not be
@@ -727,9 +723,7 @@  vect_get_loop_niters (struct loop *loop, tree *assumptions,
   *assumptions = boolean_true_node;
   *number_of_iterationsm1 = chrec_dont_know;
   *number_of_iterations = chrec_dont_know;
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== get_loop_niters ===\n");
+  VECT_SCOPE ("get_loop_niters");
 
   if (!exit)
     return cond;
@@ -1170,9 +1164,7 @@  vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 			  tree *assumptions, tree *number_of_iterationsm1,
 			  tree *number_of_iterations, gcond **inner_loop_cond)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_analyze_loop_form ===\n");
+  VECT_SCOPE ("vect_analyze_loop_form");
 
   /* Different restrictions apply when we are considering an inner-most loop,
      vs. an outer (nested) loop.
@@ -1422,9 +1414,7 @@  vect_update_vf_for_slp (loop_vec_info loop_vinfo)
   poly_uint64 vectorization_factor;
   int i;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_update_vf_for_slp ===\n");
+  VECT_SCOPE ("vect_update_vf_for_slp");
 
   vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
   gcc_assert (known_ne (vectorization_factor, 0U));
@@ -1527,9 +1517,7 @@  vect_analyze_loop_operations (loop_vec_info loop_vinfo)
   bool need_to_vectorize = false;
   bool ok;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_analyze_loop_operations ===\n");
+  VECT_SCOPE ("vect_analyze_loop_operations");
 
   stmt_vector_for_cost cost_vec;
   cost_vec.create (2);
@@ -2308,9 +2296,7 @@  vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo)
   targetm.vectorize.autovectorize_vector_sizes (&vector_sizes);
   unsigned int next_size = 0;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "===== analyze_loop_nest =====\n");
+  VECT_SCOPE ("analyze_loop_nest");
 
   if (loop_outer (loop)
       && loop_vec_info_for_loop (loop_outer (loop))
@@ -7460,9 +7446,7 @@  vectorizable_induction (gimple *phi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = induc_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-                         "=== vectorizable_induction ===\n");
+      VECT_SCOPE ("vectorizable_induction");
       vect_model_induction_cost (stmt_info, ncopies, cost_vec);
       return true;
     }
@@ -8335,8 +8319,7 @@  vect_transform_loop (loop_vec_info loop_vinfo)
   bool check_profitability = false;
   unsigned int th;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vec_transform_loop ===\n");
+  VECT_SCOPE ("vec_transform_loop");
 
   /* Use the more conservative vectorization threshold.  If the number
      of iterations is constant assume the cost check has been performed
@@ -8618,9 +8601,7 @@  vect_transform_loop (loop_vec_info loop_vinfo)
 		{
 		  slp_scheduled = true;
 
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_NOTE, vect_location,
-				     "=== scheduling SLP instances ===\n");
+		  VECT_SCOPE ("scheduling SLP instances");
 
 		  vect_schedule_slp (loop_vinfo);
 		}
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 74f08cf..23f1ab8 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -4669,9 +4669,7 @@  vect_pattern_recog (vec_info *vinfo)
   auto_vec<gimple *, 1> stmts_to_replace;
   gimple *stmt;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_pattern_recog ===\n");
+  VECT_SCOPE ("vect_pattern_recog");
 
   if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo))
     {
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 0a96a93..ab703da 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2177,8 +2177,7 @@  vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size)
   unsigned int i;
   gimple *first_element;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_analyze_slp ===\n");
+  VECT_SCOPE ("vect_analyze_slp");
 
   /* Find SLP sequences starting from groups of grouped stores.  */
   FOR_EACH_VEC_ELT (vinfo->grouped_stores, i, first_element)
@@ -2231,9 +2230,7 @@  vect_make_slp_decision (loop_vec_info loop_vinfo)
   slp_instance instance;
   int decided_to_slp = 0;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_make_slp_decision ==="
-                     "\n");
+  VECT_SCOPE ("vect_make_slp_decision");
 
   FOR_EACH_VEC_ELT (slp_instances, i, instance)
     {
@@ -2399,9 +2396,7 @@  vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
   vec<slp_instance> slp_instances = LOOP_VINFO_SLP_INSTANCES (loop_vinfo);
   slp_instance instance;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_detect_hybrid_slp ==="
-                     "\n");
+  VECT_SCOPE ("vect_detect_hybrid_slp");
 
   /* First walk all pattern stmt in the loop and mark defs of uses as
      hybrid because immediate uses in them are not recorded.  */
@@ -2622,9 +2617,7 @@  vect_slp_analyze_operations (vec_info *vinfo)
   slp_instance instance;
   int i;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_slp_analyze_operations ===\n");
+  VECT_SCOPE ("vect_slp_analyze_operations");
 
   scalar_stmts_to_slp_tree_map_t *visited
     = new scalar_stmts_to_slp_tree_map_t ();
@@ -2981,8 +2974,7 @@  vect_slp_bb (basic_block bb)
   bool any_vectorized = false;
   auto_vector_sizes vector_sizes;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "===vect_slp_analyze_bb===\n");
+  VECT_SCOPE ("vect_slp_analyze_bb");
 
   /* Autodetect first vector size we try.  */
   current_vector_size = 0;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 9f365e3..d683665 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -640,9 +640,7 @@  vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
   bool live_p;
   enum vect_relevant relevant;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_mark_stmts_to_be_vectorized ===\n");
+  VECT_SCOPE ("vect_mark_stmts_to_be_vectorized");
 
   auto_vec<gimple *, 64> worklist;
 
@@ -3027,9 +3025,7 @@  vectorizable_bswap (gimple *stmt, gimple_stmt_iterator *gsi,
   if (! vec_stmt)
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_bswap ==="
-                         "\n");
+      VECT_SCOPE ("vectorizable_bswap");
       if (! slp_node)
 	{
 	  record_stmt_cost (cost_vec,
@@ -3346,9 +3342,7 @@  vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_call ==="
-                         "\n");
+      VECT_SCOPE ("vectorizable_call");
       vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, cost_vec);
       if (ifn != IFN_LAST && modifier == NARROW && !slp_node)
 	record_stmt_cost (cost_vec, ncopies / 2,
@@ -4023,9 +4017,7 @@  vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
 	    STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (sll);
 	  }
       STMT_VINFO_TYPE (stmt_info) = call_simd_clone_vec_info_type;
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-			 "=== vectorizable_simd_clone_call ===\n");
+      VECT_SCOPE ("vectorizable_simd_clone_call");
 /*      vect_model_simple_cost (stmt_info, ncopies, dt, slp_node, cost_vec); */
       return true;
     }
@@ -4865,9 +4857,7 @@  vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 
   if (!vec_stmt)		/* transformation not required.  */
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-                         "=== vectorizable_conversion ===\n");
+      VECT_SCOPE ("vectorizable_conversion");
       if (code == FIX_TRUNC_EXPR || code == FLOAT_EXPR)
         {
 	  STMT_VINFO_TYPE (stmt_info) = type_conversion_vec_info_type;
@@ -5279,9 +5269,7 @@  vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-                         "=== vectorizable_assignment ===\n");
+      VECT_SCOPE ("vectorizable_assignment");
       vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, cost_vec);
       return true;
     }
@@ -5644,9 +5632,7 @@  vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = shift_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-                         "=== vectorizable_shift ===\n");
+      VECT_SCOPE ("vectorizable_shift");
       vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, cost_vec);
       return true;
     }
@@ -5968,9 +5954,7 @@  vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = op_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-                         "=== vectorizable_operation ===\n");
+      VECT_SCOPE ("vectorizable_operation");
       vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, cost_vec);
       return true;
     }
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index f4b4dec..2255d96 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -1425,6 +1425,16 @@  vect_get_scalar_dr_size (struct data_reference *dr)
 /* Source location */
 extern source_location vect_location;
 
+/* If dumping is enabled, emit a MSG_NOTE at vect_location about
+   entering MSG within the vectorizer.  MSG should be a string literal. */
+
+#define VECT_SCOPE(MSG) \
+  do {						\
+    if (dump_enabled_p ())			\
+      dump_printf_loc (MSG_NOTE, vect_location, \
+		       "=== " MSG " ===\n");	\
+  } while (0)
+
 /*-----------------------------------------------------------------*/
 /* Function prototypes.                                            */
 /*-----------------------------------------------------------------*/