From 008ec356ad0fdf5dbb45c945b3bc1460d2bec6c9 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 16 May 2018 11:25:41 -0400
Subject: [PATCH 55/67] Various cleanups

---
 gcc/tree-vect-data-refs.c  | 124 +++++++++++++++++++++------------------------
 gcc/tree-vect-loop-manip.c |  59 ++++++++++-----------
 gcc/tree-vect-patterns.c   |  96 +++++++++++++++++------------------
 gcc/tree-vect-stmts.c      |  12 ++---
 gcc/tree-vectorizer.c      |  25 +++++----
 5 files changed, 153 insertions(+), 163 deletions(-)

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index b736928..9e7357d 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -2266,12 +2266,11 @@ vect_find_same_alignment_drs (struct data_dependence_relation *ddr)
   STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_b).safe_push (dra);
   if (optinfo_enabled_p ())
     {
-      OPTINFO_VECT_NOTE << optinfo_printf (
-		       "accesses have the same alignment: ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
-      dump_printf (MSG_NOTE,  " and ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
-      dump_printf (MSG_NOTE, "\n");
+      OPTINFO_VECT_NOTE
+	<< "accesses have the same alignment: "
+	<< slim (DR_REF (dra))
+	<< " and "
+	<< slim (DR_REF (drb));
     }
 }
 
@@ -2988,16 +2987,15 @@ vect_analyze_data_ref_accesses (vec_info *vinfo)
 
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_NOTE << optinfo_printf (
-			       "Detected interleaving ");
+	      pending_optinfo info = OPTINFO_VECT_NOTE
+		<< "Detected interleaving ";
 	      if (DR_IS_READ (dra))
-		dump_printf (MSG_NOTE, "load ");
+		info << "load ";
 	      else
-		dump_printf (MSG_NOTE, "store ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
-	      dump_printf (MSG_NOTE,  " and ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
-	      dump_printf (MSG_NOTE, "\n");
+		info << "store ";
+	      info << slim (DR_REF (dra));
+	      info << " and ";
+	      info << slim (DR_REF (drb));
 	    }
 
 	  /* Link the found element into the group list.  */
@@ -3171,12 +3169,12 @@ dependence_distance_ge_vf (data_dependence_relation *ddr,
 
   if (optinfo_enabled_p ())
     {
-      OPTINFO_VECT_NOTE << optinfo_printf (
-		       "dependence distance between ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr)));
-      dump_printf (MSG_NOTE,  " and ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_B (ddr)));
-      dump_printf (MSG_NOTE,  " is >= VF\n");
+      OPTINFO_VECT_NOTE
+	<< "dependence distance between "
+	<< slim (DR_REF (DDR_A (ddr)))
+	<< " and "
+	<< slim (DR_REF (DDR_B (ddr)))
+	<< " is >= VF";
     }
 
   return true;
@@ -3357,11 +3355,12 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  OPTINFO_VECT_NOTE << optinfo_printf ( "checking that ");
-		  dump_generic_expr (MSG_NOTE, TDF_SLIM, new_pair.first);
-		  dump_printf (MSG_NOTE, " and ");
-		  dump_generic_expr (MSG_NOTE, TDF_SLIM, new_pair.second);
-		  dump_printf (MSG_NOTE, " have different addresses\n");
+		  OPTINFO_VECT_NOTE
+		    << "checking that "
+		    << slim (new_pair.first)
+		    << " and "
+		    << slim (new_pair.second)
+		    << " have different addresses";
 		}
 	      LOOP_VINFO_CHECK_UNEQUAL_ADDRS (loop_vinfo).safe_push (new_pair);
 	    }
@@ -3382,12 +3381,12 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_NOTE << optinfo_printf (
-			       "no need for alias check between ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
-	      dump_printf (MSG_NOTE, " and ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_b));
-	      dump_printf (MSG_NOTE, " when VF is 1\n");
+	      OPTINFO_VECT_NOTE
+		<< "no need for alias check between "
+		<< slim (DR_REF (dr_a))
+		<< " and "
+		<< slim (DR_REF (dr_b))
+		<< " when VF is 1";
 	    }
 	  continue;
 	}
@@ -3481,15 +3480,15 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 					     access_size_b);
 	  if (res >= 0 && optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_NOTE << optinfo_printf (
-			       "can tell at compile time that ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
-	      dump_printf (MSG_NOTE, " and ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_b));
+	      pending_optinfo info = OPTINFO_VECT_NOTE
+		<< "can tell at compile time that "
+		<< slim (DR_REF (dr_a))
+		<< " and "
+		<< slim (DR_REF (dr_b));
 	      if (res == 0)
-		dump_printf (MSG_NOTE, " do not alias\n");
+		info << " do not alias";
 	      else
-		dump_printf (MSG_NOTE, " alias\n");
+		info << " alias";
 	    }
 
 	  if (res == 0)
@@ -3498,8 +3497,8 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	  if (res == 1)
 	    {
 	      if (optinfo_enabled_p ())
-		OPTINFO_VECT_NOTE << optinfo_printf (
-				 "not vectorized: compilation time alias.\n");
+		OPTINFO_VECT_NOTE
+		  << "not vectorized: compilation time alias";
 	      return false;
 	    }
 	}
@@ -4186,28 +4185,23 @@ again:
 
           if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_NOTE << optinfo_printf (
-                               "\touter base_address: ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
-                                 STMT_VINFO_DR_BASE_ADDRESS (stmt_info));
-	      dump_printf (MSG_NOTE, "\n\touter offset from base address: ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
-                                 STMT_VINFO_DR_OFFSET (stmt_info));
-	      dump_printf (MSG_NOTE,
-                           "\n\touter constant offset from base address: ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
-                                 STMT_VINFO_DR_INIT (stmt_info));
-	      dump_printf (MSG_NOTE, "\n\touter step: ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
-                                 STMT_VINFO_DR_STEP (stmt_info));
-	      dump_printf (MSG_NOTE, "\n\touter base alignment: %d\n",
-			   STMT_VINFO_DR_BASE_ALIGNMENT (stmt_info));
-	      dump_printf (MSG_NOTE, "\n\touter base misalignment: %d\n",
-			   STMT_VINFO_DR_BASE_MISALIGNMENT (stmt_info));
-	      dump_printf (MSG_NOTE, "\n\touter offset alignment: %d\n",
-			   STMT_VINFO_DR_OFFSET_ALIGNMENT (stmt_info));
-	      dump_printf (MSG_NOTE, "\n\touter step alignment: %d\n",
-			   STMT_VINFO_DR_STEP_ALIGNMENT (stmt_info));
+	      OPTINFO_VECT_NOTE
+		<< "\touter base_address: "
+		<< slim (STMT_VINFO_DR_BASE_ADDRESS (stmt_info))
+		<< "\n\touter offset from base address: "
+		<< slim (STMT_VINFO_DR_OFFSET (stmt_info))
+		<< "\n\touter constant offset from base address: "
+		<< slim (STMT_VINFO_DR_INIT (stmt_info))
+		<< "\n\touter step: "
+		<< slim (STMT_VINFO_DR_STEP (stmt_info))
+		<< optinfo_printf ("\n\touter base alignment: %d\n",
+				   STMT_VINFO_DR_BASE_ALIGNMENT (stmt_info))
+		<< optinfo_printf ("\n\touter base misalignment: %d\n",
+				   STMT_VINFO_DR_BASE_MISALIGNMENT (stmt_info))
+		<< optinfo_printf ("\n\touter offset alignment: %d\n",
+				   STMT_VINFO_DR_OFFSET_ALIGNMENT (stmt_info))
+		<< optinfo_printf ("\n\touter step alignment: %d\n",
+				   STMT_VINFO_DR_STEP_ALIGNMENT (stmt_info));
 	    }
 	}
 
@@ -4571,9 +4565,9 @@ vect_create_addr_base_for_vector_ref (gimple *stmt,
 
   if (optinfo_enabled_p ())
     {
-      OPTINFO_VECT_NOTE << optinfo_printf ( "created ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, addr_base);
-      dump_printf (MSG_NOTE, "\n");
+      OPTINFO_VECT_NOTE
+	<< "created "
+	<< slim (addr_base);
     }
 
   return addr_base;
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 23ab955..fb4b71a 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -938,10 +938,11 @@ vect_set_loop_condition (struct loop *loop, loop_vec_info loop_vinfo,
   gsi_remove (&loop_cond_gsi, true);
   free_stmt_vec_info (orig_cond);
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "New loop exit condition: ");
-      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0);
+      OPTINFO_VECT_NOTE
+	<< "New loop exit condition: "
+	<< cond_stmt;
     }
 }
 
@@ -1370,17 +1371,16 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
 
   /* Analyze phi functions of the loop header.  */
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "vect_can_advance_ivs_p:\n");
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
       tree evolution_part;
 
       gphi *phi = gsi.phi ();
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
 	{
-          dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
-          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
+	  OPTINFO_VECT_NOTE << "Analyze phi: " << phi;
 	}
 
       /* Skip virtual phi's. The data dependences that are associated with
@@ -1389,9 +1389,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
 	 Skip reduction phis.  */
       if (!iv_phi_p (phi))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
-			     "reduc or virtual phi. skip.\n");
+	  if (optinfo_enabled_p ())
+	    OPTINFO_VECT_NOTE <<"reduc or virtual phi. skip";
 	  continue;
 	}
 
@@ -1401,7 +1400,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
 	= STMT_VINFO_LOOP_PHI_EVOLUTION_PART (vinfo_for_stmt (phi));
       if (evolution_part == NULL_TREE)
         {
-	  if (dump_enabled_p ())
+	  if (optinfo_enabled_p ())
 	    OPTINFO_VECT_FAILURE << "No access function or evolution";
 	  return false;
         }
@@ -1411,7 +1410,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
 
       if (!expr_invariant_in_loop_p (loop, evolution_part))
 	{
-	  if (dump_enabled_p ())
+	  if (optinfo_enabled_p ())
 	    OPTINFO_VECT_FAILURE << "evolution not invariant in loop";
 	  return false;
 	}
@@ -1421,7 +1420,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
 
       if (tree_is_chrec (evolution_part))
 	{
-	  if (dump_enabled_p ())
+	  if (optinfo_enabled_p ())
 	    OPTINFO_VECT_FAILURE << "evolution is chrec";
 	  return false;
 	}
@@ -1497,7 +1496,7 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo,
 
       gphi *phi = gsi.phi ();
       gphi *phi1 = gsi1.phi ();
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
 	{
 	  OPTINFO_VECT_NOTE
 	    << "vect_update_ivs_after_vectorizer: phi: "
@@ -1507,7 +1506,7 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo,
       /* Skip reduction and virtual phis.  */
       if (!iv_phi_p (phi))
 	{
-	  if (dump_enabled_p ())
+	  if (optinfo_enabled_p ())
 	    OPTINFO_VECT_NOTE << "reduc or virtual phi. skip.";
 	  continue;
 	}
@@ -1636,7 +1635,7 @@ vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo,
     {
       int npeel = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
 
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
         OPTINFO_VECT_NOTE
 	  << optinfo_printf ("known peeling = %d", npeel);
 
@@ -1667,7 +1666,7 @@ vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo,
       *bound = align_in_elems - 1;
     }
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       OPTINFO_VECT_NOTE
 	<< "niters for prolog loop: "
@@ -1786,12 +1785,11 @@ vect_prepare_for_masked_peels (loop_vec_info loop_vinfo)
 	}
     }
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
-      OPTINFO_VECT_NOTE << optinfo_printf (
-		       "misalignment for fully-masked loop: ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, misalign_in_elems);
-      dump_printf (MSG_NOTE, "\n");
+      OPTINFO_VECT_NOTE
+	<< "misalignment for fully-masked loop: "
+	<< slim (misalign_in_elems);
     }
 
   LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo) = misalign_in_elems;
@@ -2925,7 +2923,7 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, tree * cond_expr)
 
   create_runtime_alias_checks (LOOP_VINFO_LOOP (loop_vinfo),
 			       &comp_alias_ddrs, cond_expr);
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     OPTINFO_VECT_NOTE
       << optinfo_printf ("created %u versioning for alias checks",
 			 comp_alias_ddrs.length ());
@@ -3063,17 +3061,16 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
       loop_constraint_set (loop, LOOP_C_INFINITE);
     }
 
-  if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOCATION
-      && dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       if (version_alias)
-        dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                         "loop versioned for vectorization because of "
-			 "possible aliasing\n");
+	OPTINFO_VECT_SUCCESS
+	  << ("loop versioned for vectorization because of "
+	      "possible aliasing");
       if (version_align)
-        dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                         "loop versioned for vectorization to enhance "
-			 "alignment\n");
+        OPTINFO_VECT_SUCCESS
+	  << ("loop versioned for vectorization to enhance "
+	      "alignment");
 
     }
   free_original_copy_tables ();
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index aade8f0..f38efac 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -448,7 +448,7 @@ vect_recog_dot_prod_pattern (vec<gimple *> *stmts, tree *type_in,
   pattern_stmt = gimple_build_assign (var, DOT_PROD_EXPR,
 				      oprnd00, oprnd01, oprnd1);
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_recog_dot_prod_pattern: detected: ");
@@ -682,7 +682,7 @@ vect_recog_sad_pattern (vec<gimple *> *stmts, tree *type_in,
   gimple *pattern_stmt = gimple_build_assign (var, SAD_EXPR, sad_oprnd0,
 					      sad_oprnd1, plus_oprnd1);
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_recog_sad_pattern: detected: ");
@@ -964,7 +964,7 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts,
 	       TYPE_UNSIGNED (type));
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_recog_widen_mult_pattern: detected:\n");
 
@@ -1015,7 +1015,7 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts,
 					  gimple_assign_lhs (pattern_stmt));
     }
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
 
   stmts->safe_push (last_stmt);
@@ -1285,7 +1285,7 @@ vect_recog_widen_sum_pattern (vec<gimple *> *stmts, tree *type_in,
   var = vect_recog_temp_ssa_var (type, NULL);
   pattern_stmt = gimple_build_assign (var, WIDEN_SUM_EXPR, oprnd0, oprnd1);
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_recog_widen_sum_pattern: detected: ");
@@ -1584,7 +1584,7 @@ vect_recog_over_widening_pattern (vec<gimple *> *stmts,
       STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt)) = pattern_stmt;
       new_pattern_def_seq (vinfo_for_stmt (stmt), new_def_stmt);
 
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
         {
           dump_printf_loc (MSG_NOTE, vect_location,
                            "created pattern stmt: ");
@@ -1651,7 +1651,7 @@ vect_recog_over_widening_pattern (vec<gimple *> *stmts,
     return NULL;
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_recog_over_widening_pattern: detected: ");
@@ -1788,7 +1788,7 @@ vect_recog_widen_shift_pattern (vec<gimple *> *stmts,
     return NULL;
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_recog_widen_shift_pattern: detected:\n");
 
@@ -1821,7 +1821,7 @@ vect_recog_widen_shift_pattern (vec<gimple *> *stmts,
       STMT_VINFO_VECTYPE (new_stmt_info) = vectype;
     }
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
 
   stmts->safe_push (last_stmt);
@@ -2058,7 +2058,7 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out)
   append_pattern_def_seq (stmt_vinfo, def_stmt);
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
 		     "vect_recog_rotate_pattern: detected:\n");
 
@@ -2066,7 +2066,7 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out)
   var = vect_recog_temp_ssa_var (type, NULL);
   pattern_stmt = gimple_build_assign (var, BIT_IOR_EXPR, var1, var2);
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
 
   stmts->safe_push (last_stmt);
@@ -2197,7 +2197,7 @@ vect_recog_vector_vector_shift_pattern (vec<gimple *> *stmts,
     }
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_recog_vector_vector_shift_pattern: detected:\n");
 
@@ -2205,7 +2205,7 @@ vect_recog_vector_vector_shift_pattern (vec<gimple *> *stmts,
   var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL);
   pattern_stmt = gimple_build_assign (var, rhs_code, oprnd0, def);
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
 
   stmts->safe_push (last_stmt);
@@ -2574,11 +2574,11 @@ vect_recog_mult_pattern (vec<gimple *> *stmts,
     return NULL;
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
 		     "vect_recog_mult_pattern: detected:\n");
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM,
 			  pattern_stmt,0);
 
@@ -2692,7 +2692,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
 	return NULL;
 
       /* Pattern detected.  */
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "vect_recog_divmod_pattern: detected:\n");
 
@@ -2778,7 +2778,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
 				   signmask);
 	}
 
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
 	dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt,
                               0);
 
@@ -3032,7 +3032,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
     }
 
   /* Pattern detected.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_recog_divmod_pattern: detected: ");
@@ -3197,7 +3197,7 @@ vect_recog_mixed_size_cond_pattern (vec<gimple *> *stmts, tree *type_in,
   *type_in = vecitype;
   *type_out = vectype;
 
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_recog_mixed_size_cond_pattern: detected:\n");
 
@@ -3778,9 +3778,9 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
       *type_out = vectype;
       *type_in = vectype;
       stmts->safe_push (last_stmt);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-                         "vect_recog_bool_pattern: detected:\n");
+      if (optinfo_enabled_p ())
+	OPTINFO_VECT_NOTE
+	  << "vect_recog_bool_pattern: detected";
 
       return pattern_stmt;
     }
@@ -3819,9 +3819,9 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
       *type_out = vectype;
       *type_in = vectype;
       stmts->safe_push (last_stmt);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-                         "vect_recog_bool_pattern: detected:\n");
+      if (optinfo_enabled_p ())
+	OPTINFO_VECT_NOTE
+	  << "vect_recog_bool_pattern: detected";
 
       return pattern_stmt;
     }
@@ -3879,9 +3879,9 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
       *type_out = vectype;
       *type_in = vectype;
       stmts->safe_push (last_stmt);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-                         "vect_recog_bool_pattern: detected:\n");
+      if (optinfo_enabled_p ())
+	OPTINFO_VECT_NOTE
+	  << "vect_recog_bool_pattern: detected:";
       return pattern_stmt;
     }
   else
@@ -4017,9 +4017,9 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
       *type_out = vectype1;
       *type_in = vectype1;
       stmts->safe_push (last_stmt);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-                         "vect_recog_mask_conversion_pattern: detected:\n");
+      if (optinfo_enabled_p ())
+	OPTINFO_VECT_NOTE
+	  << "vect_recog_mask_conversion_pattern: detected";
 
       return pattern_stmt;
     }
@@ -4143,9 +4143,9 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
       *type_out = vectype1;
       *type_in = vectype1;
       stmts->safe_push (last_stmt);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-                         "vect_recog_mask_conversion_pattern: detected:\n");
+      if (optinfo_enabled_p ())
+	OPTINFO_VECT_NOTE
+	  << "vect_recog_mask_conversion_pattern: detected";
 
       return pattern_stmt;
     }
@@ -4191,9 +4191,9 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
   *type_out = vectype1;
   *type_in = vectype1;
   stmts->safe_push (last_stmt);
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "vect_recog_mask_conversion_pattern: detected:\n");
+  if (optinfo_enabled_p ())
+    OPTINFO_VECT_NOTE
+      << "vect_recog_mask_conversion_pattern: detected";
 
   return pattern_stmt;
 }
@@ -4377,9 +4377,9 @@ vect_try_gather_scatter_pattern (gimple *stmt, stmt_vec_info last_stmt_info,
   *type_out = vectype;
   *type_in = vectype;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "gather/scatter pattern detected:\n");
+  if (optinfo_enabled_p ())
+    OPTINFO_VECT_NOTE
+      << "gather/scatter pattern detected";
 
   return pattern_stmt;
 }
@@ -4532,11 +4532,11 @@ vect_pattern_recog_1 (vect_recog_func *recog_func,
     }
 
   /* Found a vectorizable pattern.  */
-  if (dump_enabled_p ())
+  if (optinfo_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-                       "%s pattern recognized: ", recog_func->name);
-      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
+      OPTINFO_VECT_NOTE
+	<< optinfo_printf ("%s pattern recognized: ", recog_func->name)
+	<< pattern_stmt;
     }
 
   /* Mark the stmts that are involved in the pattern. */
@@ -4558,11 +4558,11 @@ vect_pattern_recog_1 (vect_recog_func *recog_func,
     {
       stmt_info = vinfo_for_stmt (stmt);
       pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
-      if (dump_enabled_p ())
+      if (optinfo_enabled_p ())
         {
-          dump_printf_loc (MSG_NOTE, vect_location,
-                           "additional pattern stmt: ");
-          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
+	  OPTINFO_VECT_NOTE
+	    << "additional pattern stmt: "
+	    << pattern_stmt;
         }
 
       vect_mark_pattern_stmts (stmt, pattern_stmt, NULL_TREE);
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 9169dc7..55e5029 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -1421,18 +1421,18 @@ vect_get_vec_def_for_operand (tree op, gimple *stmt, tree vectype)
 
   if (optinfo_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-                       "vect_get_vec_def_for_operand: ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, op);
-      dump_printf (MSG_NOTE, "\n");
+      OPTINFO_VECT_NOTE
+	<< "vect_get_vec_def_for_operand: "
+	<< slim (op);
     }
 
   is_simple_use = vect_is_simple_use (op, loop_vinfo, &def_stmt, &dt);
   gcc_assert (is_simple_use);
   if (def_stmt && optinfo_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "  def_stmt =  ");
-      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
+      OPTINFO_VECT_NOTE
+	<< "  def_stmt =  "
+	<< def_stmt;
     }
 
   if (dt == vect_constant_def || dt == vect_external_def)
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index eeb34c6..04a7367 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -737,11 +737,8 @@ vectorize_loops (void)
 
 	if (loop_vectorized_call)
 	  set_uid_loop_bbs (loop_vinfo, loop_vectorized_call);
-        if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOCATION
-	    && dump_enabled_p ())
-          dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                           "loop vectorized\n");
-	OPTINFO_SUCCESS (loop) << "loop vectorized";
+        if (optinfo_enabled_p ())
+	  OPTINFO_VECT_SUCCESS << "loop vectorized";
 	new_loop = vect_transform_loop (loop_vinfo);
 	num_vectorized_loops++;
 	/* Now that the loop has been vectorized, allow it to be unrolled
@@ -787,11 +784,10 @@ vectorize_loops (void)
   vect_location_thing = (gimple *)NULL;
 
   statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
-  if (dump_enabled_p ()
-      || (num_vectorized_loops > 0 && dump_enabled_p ()))
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "vectorized %u loops in function.\n",
-                     num_vectorized_loops);
+  if (optinfo_enabled_p ())
+    OPTINFO_VECT_NOTE
+      << optinfo_printf ("vectorized %u loops in function",
+			 num_vectorized_loops);
 
   /*  ----------- Finalize. -----------  */
 
@@ -1144,9 +1140,12 @@ increase_alignment (void)
       if (alignment && vect_can_force_dr_alignment_p (decl, alignment))
         {
 	  vnode->increase_alignment (alignment);
-          dump_printf (MSG_NOTE, "Increasing alignment of decl: ");
-          dump_generic_expr (MSG_NOTE, TDF_SLIM, decl);
-          dump_printf (MSG_NOTE, "\n");
+	  if (optinfo_enabled_p ())
+	    {
+	      OPTINFO_VECT_NOTE
+		<< "Increasing alignment of decl: "
+		<< slim (decl);
+	    }
         }
     }
 
-- 
1.8.5.3

