From 3e6d808a8a3fe40d3bf9486936501d0fd353316e Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 14 May 2018 15:41:47 -0400
Subject: [PATCH 37/67] FIXME: eliminate vect_location_writeln; WIP on
 reworking all uses

---
 gcc/optimization-records.cc |   2 +-
 gcc/optimization-records.h  |   2 +-
 gcc/optinfo.cc              |   2 +-
 gcc/tree-vect-data-refs.c   | 196 ++++++++++++++++++++---------------------
 gcc/tree-vect-loop.c        |  47 ----------
 gcc/tree-vect-slp.c         | 142 +++++++++++++++---------------
 gcc/tree-vect-stmts.c       | 209 ++++++++++++++++++++++----------------------
 gcc/tree-vectorizer.h       |   4 -
 8 files changed, 274 insertions(+), 330 deletions(-)

diff --git a/gcc/optimization-records.cc b/gcc/optimization-records.cc
index dbcc203..8398141 100644
--- a/gcc/optimization-records.cc
+++ b/gcc/optimization-records.cc
@@ -155,7 +155,7 @@ optimization_record_enabled_p ()
 /* FIXME.  */
 
 void
-maybe_record_optimization (const optinfo *optinfo)
+maybe_record_optinfo (const optinfo *optinfo)
 {
   /* Bail immediately if recording not enabled.  */
   if (!records)
diff --git a/gcc/optimization-records.h b/gcc/optimization-records.h
index 02b6a96..a52987b 100644
--- a/gcc/optimization-records.h
+++ b/gcc/optimization-records.h
@@ -41,7 +41,7 @@ extern const char *opt_record_kind_to_string (enum opt_record_kind kind);
 // FIXME: maybe make this inline?
 extern bool optimization_record_enabled_p ();
 
-extern void maybe_record_optimization (const optinfo *);
+extern void maybe_record_optinfo (const optinfo *);
 
 extern void maybe_record_optimization_va (enum opt_record_kind kind,
 					  gimple *stmt,
diff --git a/gcc/optinfo.cc b/gcc/optinfo.cc
index 5f3ebb4..9b3c5d1 100644
--- a/gcc/optinfo.cc
+++ b/gcc/optinfo.cc
@@ -92,7 +92,7 @@ void
 optinfo::emit () const
 {
   /* -fsave-optimization-record and remarks.  */
-  maybe_record_optimization (this);
+  maybe_record_optinfo (this);
 
   /* -fopt-info.  */
   if (1)
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 7500c64..d0138f9 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -73,10 +73,10 @@ vect_lanes_optab_supported_p (const char *name, convert_optab optab,
       if (!int_mode_for_size (bits, limit_p).exists (&array_mode))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-			     "no array mode for %s["
-			     HOST_WIDE_INT_PRINT_DEC "]\n",
-			     GET_MODE_NAME (mode), count);
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	      << optinfo_printf ("no array mode for %s["
+				 HOST_WIDE_INT_PRINT_DEC "]",
+				 GET_MODE_NAME (mode), count);
 	  return false;
 	}
     }
@@ -84,16 +84,17 @@ vect_lanes_optab_supported_p (const char *name, convert_optab optab,
   if (convert_optab_handler (optab, array_mode, mode) == CODE_FOR_nothing)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-                         "cannot use %s<%s><%s>\n", name,
-                         GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	  << optinfo_printf ("cannot use %s<%s><%s>", name,
+			     GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
       return false;
     }
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
-                     "can use %s<%s><%s>\n", name, GET_MODE_NAME (array_mode),
-                     GET_MODE_NAME (mode));
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+      << optinfo_printf ("can use %s<%s><%s>", name,
+			 GET_MODE_NAME (array_mode),
+			 GET_MODE_NAME (mode));
 
   return true;
 }
@@ -183,9 +184,10 @@ vect_check_nonzero_value (loop_vec_info loop_vinfo, tree value)
 
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK, "need run-time check that ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, value);
-      dump_printf (MSG_NOTE, " is nonzero\n");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	<< "need run-time check that "
+	<< slim (value)
+	<< " is nonzero";
     }
   LOOP_VINFO_CHECK_NONZERO (loop_vinfo).safe_push (value);
 }
@@ -417,19 +419,18 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
       int dist = dist_v[loop_depth];
 
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_REMARK,
-                         "dependence distance  = %d.\n", dist);
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	  << optinfo_printf ("dependence distance  = %d", dist);
 
       if (dist == 0)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
-	                       "dependence distance == 0 between ");
-	      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_MISSED_OPTIMIZATION, "\n");
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+		<< "dependence distance == 0 between "
+		<< slim (DR_REF (dra))
+		<< " and "
+		<< slim (DR_REF (drb));
 	    }
 
 	  /* When we perform grouped accesses and perform implicit CSE
@@ -499,9 +500,9 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	     vectorization factor.  */
 	  *max_vf = abs (dist);
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_REMARK,
-	                     "adjusting maximal vectorization factor to %i\n",
-	                     *max_vf);
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	      << optinfo_printf ("adjusting maximal vectorization factor to %i",
+				 *max_vf);
 	}
 
       if (abs_dist >= *max_vf)
@@ -509,8 +510,8 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	  /* Dependence distance does not create dependence, as far as
 	     vectorization is concerned, in this case.  */
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_REMARK,
-	                     "dependence distance >= VF.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	      << optinfo_printf ("dependence distance >= VF");
 	  continue;
 	}
 
@@ -544,8 +545,8 @@ vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo,
   struct data_dependence_relation *ddr;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
-                     "=== vect_analyze_data_ref_dependences ===\n");
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+      << "=== vect_analyze_data_ref_dependences ===";
 
   LOOP_VINFO_DDRS (loop_vinfo)
     .create (LOOP_VINFO_DATAREFS (loop_vinfo).length ()
@@ -619,12 +620,11 @@ vect_slp_analyze_data_ref_dependence (struct data_dependence_relation *ddr)
     }
   else if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK,
-		       "determined dependence between ");
-      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");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	<< "determined dependence between "
+	<< slim (DR_REF (dra))
+	<< " and "
+	<< slim (DR_REF (drb));
     }
 
   return true;
@@ -713,8 +713,8 @@ bool
 vect_slp_analyze_instance_dependence (slp_instance instance)
 {
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
-                     "=== vect_slp_analyze_instance_dependence ===\n");
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+      << "=== 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);
@@ -774,17 +774,14 @@ vect_record_base_alignment (vec_info *vinfo, gimple *stmt,
       entry = drb;
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
-			   "recording new base alignment for ");
-	  dump_generic_expr (MSG_NOTE, TDF_SLIM, drb->base_address);
-	  dump_printf (MSG_NOTE, "\n");
-	  vect_location_writeln (OPT_RECORD_REMARK,
-			   "  alignment:    %d\n", drb->base_alignment);
-	  vect_location_writeln (OPT_RECORD_REMARK,
-			   "  misalignment: %d\n", drb->base_misalignment);
-	  vect_location_writeln (OPT_RECORD_REMARK,
-			   "  based on:     ");
-	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	    << "recording new base alignment for "
+	    << slim (drb->base_address)
+	    << "\n"
+	    << optinfo_printf ("  alignment:    %d\n", drb->base_alignment)
+	    << optinfo_printf ("  misalignment: %d\n", drb->base_misalignment)
+	    << optinfo_printf ("  based on:     ")
+	    << stmt;
 	}
     }
 }
@@ -856,8 +853,8 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
-                     "vect_compute_data_ref_alignment:\n");
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+      << "vect_compute_data_ref_alignment:";
 
   if (loop_vinfo)
     loop = LOOP_VINFO_LOOP (loop_vinfo);
@@ -893,7 +890,7 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
       if (optinfo_enabled_p ())
 	{
 	  if (step_preserves_misalignment_p)
-	    vect_location_writeln (OPT_RECORD_REMARK,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			     "inner step divides the vector alignment.\n");
 	  else
 	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << (
@@ -955,7 +952,7 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 	                       "can't force alignment of ref: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
 	      dump_printf (MSG_NOTE, "\n");
@@ -968,7 +965,7 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 	 the analysis phase, before deciding to vectorize the loop.  */
       if (optinfo_enabled_p ())
         {
-          vect_location_writeln (OPT_RECORD_REMARK, "force alignment of ");
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "force alignment of ");
           dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
           dump_printf (MSG_NOTE, "\n");
         }
@@ -1068,7 +1065,7 @@ vect_update_misalignment_for_peel (struct data_reference *dr,
     }
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK, "Setting misalignment " \
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "Setting misalignment " \
 		     "to unknown (-1).\n");
   SET_DR_MISALIGNMENT (dr, DR_MISALIGNMENT_UNKNOWN);
 }
@@ -1103,7 +1100,7 @@ verify_data_ref_alignment (data_reference_p dr)
     }
 
   if (supportable_dr_alignment != dr_aligned && optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		     "Vectorizing an unaligned access.\n");
 
   return true;
@@ -1200,7 +1197,7 @@ vector_alignment_reachable_p (struct data_reference *dr)
 		int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 	                   "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
 	  dump_printf (MSG_NOTE,
 	               ". misalignment = %d.\n", DR_MISALIGNMENT (dr));
@@ -1254,7 +1251,7 @@ vect_get_data_access_cost (struct data_reference *dr,
     vect_get_store_cost (dr, ncopies, inside_cost, body_cost_vec);
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                      "vect_get_data_access_cost: inside_cost = %d, "
                      "outside_cost = %d.\n", *inside_cost, *outside_cost);
 }
@@ -1645,7 +1642,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
   hash_table<peel_info_hasher> peeling_htab (1);
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                      "=== vect_enhance_data_refs_alignment ===\n");
 
   /* Reset data so we can safely be called multiple times.  */
@@ -2005,7 +2002,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
 	    npeel /= GROUP_SIZE (stmt_info);
 
           if (optinfo_enabled_p ())
-            vect_location_writeln (OPT_RECORD_REMARK,
+            EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                              "Try peeling by %d\n", npeel);
         }
 
@@ -2040,7 +2037,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
                 {
                   do_peeling = false;
                   if (optinfo_enabled_p ())
-                    vect_location_writeln (OPT_RECORD_REMARK,
+                    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                         "Disable peeling, max peels reached: %d\n", max_peel);
                 }
             }
@@ -2091,9 +2088,9 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
 	  SET_DR_MISALIGNMENT (dr0, 0);
 	  if (optinfo_enabled_p ())
             {
-              vect_location_writeln (OPT_RECORD_REMARK,
+              EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                                "Alignment of access forced using peeling.\n");
-              vect_location_writeln (OPT_RECORD_REMARK,
+              EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                                "Peeling for alignment will be applied.\n");
             }
 
@@ -2215,12 +2212,12 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
           dr = STMT_VINFO_DATA_REF (stmt_info);
 	  SET_DR_MISALIGNMENT (dr, 0);
 	  if (optinfo_enabled_p ())
-            vect_location_writeln (OPT_RECORD_REMARK,
+            EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                              "Alignment of access forced using versioning.\n");
         }
 
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_REMARK,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                          "Versioning for alignment will be applied.\n");
 
       /* Peeling and versioning can't be done together at this time.  */
@@ -2284,7 +2281,7 @@ vect_find_same_alignment_drs (struct data_dependence_relation *ddr)
   STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_b).safe_push (dra);
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK,
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		       "accesses have the same alignment: ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
       dump_printf (MSG_NOTE,  " and ");
@@ -2303,7 +2300,7 @@ bool
 vect_analyze_data_refs_alignment (loop_vec_info vinfo)
 {
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                      "=== vect_analyze_data_refs_alignment ===");
 
   /* Mark groups of data references with same alignment using
@@ -2384,7 +2381,7 @@ bool
 vect_slp_analyze_and_verify_instance_alignment (slp_instance instance)
 {
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                      "=== vect_slp_analyze_and_verify_instance_alignment ===\n");
 
   slp_tree node;
@@ -2439,7 +2436,7 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 	                       "Step ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, step);
 	      dump_printf (MSG_NOTE,
@@ -2471,7 +2468,7 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	  GROUP_GAP (stmt_info) = groupsize - 1;
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 	                       "Detected single element interleaving ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr));
 	      dump_printf (MSG_NOTE, " step ");
@@ -2496,7 +2493,7 @@ vect_analyze_group_access_1 (struct data_reference *dr)
           return true;
         }
 
-      vect_location_writeln (OPT_RECORD_REMARK, "using strided accesses\n");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "using strided accesses\n");
       STMT_VINFO_STRIDED_P (stmt_info) = true;
       return true;
     }
@@ -2612,7 +2609,7 @@ vect_analyze_group_access_1 (struct data_reference *dr)
       GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "Detected interleaving ");
 	  if (DR_IS_READ (dr))
 	    dump_printf (MSG_NOTE, "load ");
@@ -2622,7 +2619,7 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 		       (unsigned)groupsize);
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	  if (GROUP_GAP (vinfo_for_stmt (stmt)) != 0)
-	    vect_location_writeln (OPT_RECORD_REMARK,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			     "There is a gap of %u elements after the group\n",
 			     GROUP_GAP (vinfo_for_stmt (stmt)));
 	}
@@ -2707,7 +2704,7 @@ vect_analyze_data_ref_access (struct data_reference *dr)
       if (loop->safelen < 2)
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_REMARK,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			     "zero step in inner loop of nest\n");
 	  return false;
 	}
@@ -2724,7 +2721,7 @@ vect_analyze_data_ref_access (struct data_reference *dr)
       if (integer_zerop (step))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_REMARK,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 	                     "zero step in outer loop.\n");
 	  return DR_IS_READ (dr);
 	}
@@ -2747,7 +2744,7 @@ vect_analyze_data_ref_access (struct data_reference *dr)
   if (loop && nested_in_vect_loop_p (loop, stmt))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_REMARK,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 	                 "grouped access in outer loop.\n");
       return false;
     }
@@ -2889,7 +2886,7 @@ vect_analyze_data_ref_accesses (vec_info *vinfo)
   struct data_reference *dr;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                      "=== vect_analyze_data_ref_accesses ===\n");
 
   if (datarefs.is_empty ())
@@ -3014,7 +3011,7 @@ vect_analyze_data_ref_accesses (vec_info *vinfo)
 
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			       "Detected interleaving ");
 	      if (DR_IS_READ (dra))
 		dump_printf (MSG_NOTE, "load ");
@@ -3197,7 +3194,7 @@ dependence_distance_ge_vf (data_dependence_relation *ddr,
 
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK,
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		       "dependence distance between ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr)));
       dump_printf (MSG_NOTE,  " and ");
@@ -3239,7 +3236,7 @@ vect_check_lower_bound (loop_vec_info loop_vinfo, tree expr, bool unsigned_p,
 	    lower_bounds[i].min_value = min_value;
 	    if (optinfo_enabled_p ())
 	      {
-		vect_location_writeln (OPT_RECORD_REMARK,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 				 "updating run-time check to ");
 		dump_lower_bound (MSG_NOTE, lower_bounds[i]);
 		dump_printf (MSG_NOTE, "\n");
@@ -3251,7 +3248,7 @@ vect_check_lower_bound (loop_vec_info loop_vinfo, tree expr, bool unsigned_p,
   vec_lower_bound lower_bound (expr, unsigned_p, min_value);
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK, "need a run-time check that ");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "need a run-time check that ");
       dump_lower_bound (MSG_NOTE, lower_bound);
       dump_printf (MSG_NOTE, "\n");
     }
@@ -3336,7 +3333,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
   tree length_factor;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                      "=== vect_prune_runtime_alias_test_list ===\n");
 
   /* Step values are irrelevant for aliasing if the number of vector
@@ -3385,7 +3382,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_REMARK, "checking that ");
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << 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);
@@ -3410,7 +3407,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			       "no need for alias check between ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
 	      dump_printf (MSG_NOTE, " and ");
@@ -3433,7 +3430,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	  bool unsigned_p = dr_known_forward_stride_p (dr_a);
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK, "no alias between ");
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "no alias 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));
@@ -3509,7 +3506,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 					     access_size_b);
 	  if (res >= 0 && optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			       "can tell at compile time that ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
 	      dump_printf (MSG_NOTE, " and ");
@@ -3526,7 +3523,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	  if (res == 1)
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_REMARK,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 				 "not vectorized: compilation time alias.\n");
 	      return false;
 	    }
@@ -3548,7 +3545,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
   unsigned int count = (comp_alias_ddrs.length ()
 			+ check_unequal_addrs.length ());
 
-  vect_location_writeln (OPT_RECORD_REMARK,
+  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		   "improved number of alias checks from %d to %d\n",
 		   may_alias_ddrs.length (), count);
   if ((int) count > PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS))
@@ -3936,7 +3933,7 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf)
   tree scalar_type;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		     "=== vect_analyze_data_refs ===");
 
   if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo))
@@ -4205,7 +4202,7 @@ again:
 
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                                "analyze in outer loop: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, init_ref);
 	      dump_printf (MSG_NOTE, "\n");
@@ -4218,7 +4215,7 @@ again:
 
           if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
                                "\touter base_address: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
                                  STMT_VINFO_DR_BASE_ADDRESS (stmt_info));
@@ -4605,7 +4602,7 @@ vect_create_addr_base_for_vector_ref (gimple *stmt,
 
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK, "created ");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "created ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, addr_base);
       dump_printf (MSG_NOTE, "\n");
     }
@@ -4733,20 +4730,19 @@ vect_create_data_ref_ptr (gimple *stmt, tree aggr_type, struct loop *at_loop,
   if (optinfo_enabled_p ())
     {
       tree dr_base_type = TREE_TYPE (DR_BASE_OBJECT (dr));
-      vect_location_writeln (OPT_RECORD_REMARK,
-                       "create %s-pointer variable to type: ",
-		       get_tree_code_name (TREE_CODE (aggr_type)));
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, aggr_type);
+      pending_optinfo po = EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	<< optinfo_printf ("create %s-pointer variable to type: ",
+			   get_tree_code_name (TREE_CODE (aggr_type)))
+	<< slim (aggr_type);
       if (TREE_CODE (dr_base_type) == ARRAY_TYPE)
-        dump_printf (MSG_NOTE, "  vectorizing an array ref: ");
+	po << "  vectorizing an array ref: ";
       else if (TREE_CODE (dr_base_type) == VECTOR_TYPE)
-        dump_printf (MSG_NOTE, "  vectorizing a vector ref: ");
+	po << "  vectorizing a vector ref: ";
       else if (TREE_CODE (dr_base_type) == RECORD_TYPE)
-        dump_printf (MSG_NOTE, "  vectorizing a record based array ref: ");
+	po << "  vectorizing a record based array ref: ";
       else
-        dump_printf (MSG_NOTE, "  vectorizing a pointer ref: ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_BASE_OBJECT (dr));
-      dump_printf (MSG_NOTE, "\n");
+	po << "  vectorizing a pointer ref: ";
+      po << slim (DR_BASE_OBJECT (dr));
     }
 
   /* (1) Create the new aggregate-pointer variable.
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index e73fdb0..1f8576f 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -162,53 +162,6 @@ bool optinfo_enabled_p ()
   return dump_enabled_p () || optimization_record_enabled_p ();
 }
 
-void vect_location_writeln (enum opt_record_kind kind,
-			    const char *fmt, ...)
-{
-  va_list ap;
-  va_start (ap, fmt);
-
-  if (dump_enabled_p ())
-    {
-      dump_flags_t flags = 0;
-      switch (kind)
-	{
-	default:
-	  gcc_unreachable ();
-	case OPT_RECORD_SUCCESS:
-	  gcc_unreachable ();
-	  //flags = ;
-	  break;
-	case OPT_RECORD_FAILURE:
-	  flags = MSG_MISSED_OPTIMIZATION;
-	  break;
-	case OPT_RECORD_REMARK:
-	  flags = MSG_NOTE;
-	  break;
-	}
-
-      dump_printf_loc_va (flags, vect_location, fmt, &ap);
-      dump_printf (flags, "\n");
-    }
-  va_end (ap);
-
-  va_start (ap, fmt);
-
-  if (optimization_record_enabled_p ())
-    {
-#if 0
-      if (vect_location_thing.m_loop != NULL)
-	maybe_record_optimization_va (kind, vect_location_thing.m_loop,
-				      fmt, &ap);
-      else
-#endif
-	maybe_record_optimization_va (kind, vect_location_thing.m_stmt,
-				      fmt, &ap);
-    }
-
-  va_end (ap);
-}
-
 /* FIXME.  */
 
 pending_optinfo
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index fb6f31e..887a874 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -352,7 +352,7 @@ again:
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_FAILURE,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "Build SLP failed: can't analyze def for ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
               dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -388,7 +388,7 @@ again:
 
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 					 "Build SLP failed: some of the stmts"
 					 " are in a pattern, and others are not ");
 		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
@@ -404,7 +404,7 @@ again:
           if (dt == vect_unknown_def_type)
             {
               if (optinfo_enabled_p ())
-                vect_location_writeln (OPT_RECORD_FAILURE,
+                EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				       "Unsupported pattern");
               return -1;
             }
@@ -417,7 +417,7 @@ again:
 
 	    default:
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "unsupported defining stmt:\n");
 	      return -1;
             }
@@ -459,7 +459,7 @@ again:
 		}
 
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "Build SLP failed: different types\n");
 
 	      return 1;
@@ -473,7 +473,7 @@ again:
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				   "Build SLP failed: invalid type of def "
 				   "for variable-length SLP ");
 		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
@@ -500,7 +500,7 @@ again:
 	  /* FORNOW: Not supported.  */
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_FAILURE,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "Build SLP failed: illegal type of def ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
               dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -519,7 +519,7 @@ again:
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_FAILURE,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "Build SLP failed: cannot swap operands of "
 			       "shared stmt ");
 	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -555,7 +555,7 @@ again:
 			   gimple_assign_rhs2_ptr (stmt));
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "swapped operands to match def types in ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
@@ -580,7 +580,7 @@ vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
     {
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_FAILURE,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			   "Build SLP failed: unsupported data-type in ");
 	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -597,7 +597,7 @@ vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
       && (!nunits.is_constant (&const_nunits)
 	  || const_nunits > group_size))
     {
-      vect_location_writeln (OPT_RECORD_FAILURE,
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "Build SLP failed: unrolling required "
 			     "in basic block SLP");
       /* Fatal mismatch.  */
@@ -653,7 +653,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK, "Build SLP for ");
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "Build SLP for ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
 
@@ -662,7 +662,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
         {
           if (optinfo_enabled_p ())
             {
-              vect_location_writeln (OPT_RECORD_FAILURE,
+              EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "Build SLP failed: unvectorizable statement ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }
@@ -676,7 +676,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_FAILURE,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "Build SLP failed: not GIMPLE_ASSIGN nor "
 			       "GIMPLE_CALL ");
 	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -707,7 +707,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE, 
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
 				   "Build SLP failed: unsupported call type ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				    call_stmt, 0);
@@ -747,7 +747,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		  if (!optab)
 		    {
 		      if (optinfo_enabled_p ())
-			vect_location_writeln (OPT_RECORD_FAILURE,
+			EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 					 "Build SLP failed: no optab.\n");
 		      /* Fatal mismatch.  */
 		      matches[0] = false;
@@ -757,7 +757,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		  if (icode == CODE_FOR_nothing)
 		    {
 		      if (optinfo_enabled_p ())
-			vect_location_writeln (OPT_RECORD_FAILURE,
+			EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 					 "Build SLP failed: "
 					 "op not supported by target.\n");
 		      /* Fatal mismatch.  */
@@ -804,11 +804,11 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE, 
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
 				   "Build SLP failed: different operation "
 				   "in stmt ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				   "original stmt ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				    first_stmt, 0);
@@ -822,7 +822,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE, 
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
 				   "Build SLP failed: different shift "
 				   "arguments in ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -842,7 +842,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		{
 		  if (optinfo_enabled_p ())
 		    {
-		      vect_location_writeln (OPT_RECORD_FAILURE, 
+		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
 				       "Build SLP failed: different calls in ");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 					stmt, 0);
@@ -895,7 +895,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	      /* Not grouped load.  */
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE, 
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
 				   "Build SLP failed: not grouped load ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}
@@ -915,7 +915,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				   "Build SLP failed: operation");
 		  dump_printf (MSG_MISSED_OPTIMIZATION, " unsupported ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -953,7 +953,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		{
 		  if (optinfo_enabled_p ())
 		    {
-		      vect_location_writeln (OPT_RECORD_FAILURE,
+		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				       "Build SLP failed: different"
 				       " operation");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -982,7 +982,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
       if (!nunits.is_constant (&count))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "Build SLP failed: different operations "
 			     "not allowed with variable-length SLP.\n");
 	  return false;
@@ -1004,12 +1004,12 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		matches[i] = false;
 		if (optinfo_enabled_p ())
 		  {
-		    vect_location_writeln (OPT_RECORD_FAILURE,
+		    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				     "Build SLP failed: different operation "
 				     "in stmt ");
 		    dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				      stmts[i], 0);
-		    vect_location_writeln (OPT_RECORD_FAILURE,
+		    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				     "original stmt ");
 		    dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				      first_stmt, 0);
@@ -1259,7 +1259,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 		    vect_free_slp_tree (grandchild);
 		  SLP_TREE_CHILDREN (child).truncate (0);
 
-		  vect_location_writeln (OPT_RECORD_REMARK,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 				   "Building parent vector operands from "
 				   "scalars instead\n");
 		  oprnd_info->def_stmts = vNULL;
@@ -1289,7 +1289,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 	     scalar version.  */
 	  && !is_pattern_stmt_p (vinfo_for_stmt (stmt)))
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "Building vector operands from scalars\n");
 	  child = vect_create_new_slp_node (oprnd_info->def_stmts);
 	  SLP_TREE_DEF_TYPE (child) = vect_external_def;
@@ -1364,7 +1364,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 	  while (j != group_size);
 
 	  /* Swap mismatched definition stmts.  */
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "Re-trying with swapped operands of stmts ");
 	  for (j = 0; j < group_size; ++j)
 	    if (matches[j] == !swap_not_matching)
@@ -1439,7 +1439,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 			vect_free_slp_tree (grandchild);
 		      SLP_TREE_CHILDREN (child).truncate (0);
 
-		      vect_location_writeln (OPT_RECORD_REMARK,
+		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 				       "Building parent vector operands from "
 				       "scalars instead\n");
 		      oprnd_info->def_stmts = vNULL;
@@ -1659,7 +1659,7 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
 
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK, "Load permutation ");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "Load permutation ");
       FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (slp_instn), i, node)
 	if (node->load_permutation.exists ())
 	  FOR_EACH_VEC_ELT (node->load_permutation, j, next)
@@ -1734,7 +1734,7 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
 	      if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits)
 		  || maxk >= (GROUP_SIZE (group_info) & ~(nunits - 1)))
 		{
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				   "BB vectorization with gaps at the end of "
 				   "a load is not supported\n");
 		  return false;
@@ -2116,7 +2116,7 @@ vect_split_slp_store_group (gimple *first_stmt, unsigned group1_size)
   GROUP_GAP (first_vinfo) += group2_size;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK, "Split group into %d and %d\n",
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "Split group into %d and %d\n",
 		     group1_size, group2_size);
 
   return group2;
@@ -2175,7 +2175,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
     {
       if (optinfo_enabled_p ())
         {
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			   "Build SLP failed: unsupported data-type ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, scalar_type);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -2240,7 +2240,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
 	      || const_max_nunits > group_size)
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "Build SLP failed: store group "
 				 "size not a multiple of the vector size "
 				 "in basic block SLP\n");
@@ -2304,7 +2304,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
             {
               if (optinfo_enabled_p ())
                 {
-                  vect_location_writeln (OPT_RECORD_FAILURE,
+                  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				   "Build SLP failed: unsupported load "
 				   "permutation ");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,
@@ -2338,7 +2338,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
 	  if (i == loads.length ())
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "Built SLP cancelled: can use "
 				 "load/store-lanes\n");
 	      vect_free_slp_instance (new_instance);
@@ -2350,7 +2350,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
 
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "Final SLP tree for instance:\n");
 	  vect_print_slp_tree (MSG_NOTE, vect_location, node);
 	}
@@ -2417,7 +2417,7 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size)
   gimple *first_element;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK, "=== vect_analyze_slp ===\n");
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "=== vect_analyze_slp ===\n");
 
   /* Find SLP sequences starting from groups of grouped stores.  */
   FOR_EACH_VEC_ELT (vinfo->grouped_stores, i, first_element)
@@ -2471,7 +2471,7 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   int decided_to_slp = 0;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK, "=== vect_make_slp_decision ==="
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "=== vect_make_slp_decision ==="
                      "\n");
 
   FOR_EACH_VEC_ELT (slp_instances, i, instance)
@@ -2494,7 +2494,7 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
 
   if (decided_to_slp && optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK,
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		       "Decided to SLP %d instances. Unrolling factor ",
 		       decided_to_slp);
       dump_dec (MSG_NOTE, unrolling_factor);
@@ -2556,7 +2556,7 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype)
 	      {
 		if (optinfo_enabled_p ())
 		  {
-		    vect_location_writeln (OPT_RECORD_REMARK, "use of SLP "
+		    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "use of SLP "
 				     "def in non-SLP stmt: ");
 		    dump_gimple_stmt (MSG_NOTE, TDF_SLIM, use_stmt, 0);
 		  }
@@ -2570,7 +2570,7 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype)
     {
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK, "marking hybrid: ");
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "marking hybrid: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
       STMT_SLP_TYPE (stmt_vinfo) = hybrid;
@@ -2601,7 +2601,7 @@ vect_detect_hybrid_slp_1 (tree *tp, int *, void *data)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK, "marking hybrid: ");
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "marking hybrid: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
 	    }
 	  STMT_SLP_TYPE (vinfo_for_stmt (def_stmt)) = hybrid;
@@ -2639,7 +2639,7 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
   slp_instance instance;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK, "=== vect_detect_hybrid_slp ==="
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "=== vect_detect_hybrid_slp ==="
                      "\n");
 
   /* First walk all pattern stmt in the loop and mark defs of uses as
@@ -2765,7 +2765,7 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
       tree scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "get vectype for scalar type:  ");
 	  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
 	  dump_printf (MSG_NOTE, "\n");
@@ -2776,7 +2776,7 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_FAILURE,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "not SLPed: unsupported data-type ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				 scalar_type);
@@ -2787,7 +2787,7 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
 
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK, "vectype:  ");
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "vectype:  ");
 	  dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
 	  dump_printf (MSG_NOTE, "\n");
 	}
@@ -2848,7 +2848,7 @@ vect_slp_analyze_operations (vec_info *vinfo)
   int i;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		     "=== vect_slp_analyze_operations ===\n");
 
   for (i = 0; vinfo->slp_instances.iterate (i, &instance); )
@@ -2857,7 +2857,7 @@ vect_slp_analyze_operations (vec_info *vinfo)
 					     SLP_INSTANCE_TREE (instance),
 					     instance))
         {
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "removing SLP instance operations starting from: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
 			    SLP_TREE_SCALAR_STMTS
@@ -2870,7 +2870,7 @@ vect_slp_analyze_operations (vec_info *vinfo)
     }
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		     "=== vect_analyze_slp_cost ===\n");
 
   /* Compute the costs of the SLP instances.  */
@@ -2997,7 +2997,7 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
 
   if (optinfo_enabled_p ())
     {
-      vect_location_writeln (OPT_RECORD_REMARK, "Cost model analysis: \n");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "Cost model analysis: \n");
       dump_printf (MSG_NOTE, "  Vector inside of basic block cost: %d\n",
 		   vec_inside_cost);
       dump_printf (MSG_NOTE, "  Vector prologue cost: %d\n", vec_prologue_cost);
@@ -3037,7 +3037,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (n_stmts > PARAM_VALUE (PARAM_SLP_MAX_INSNS_IN_BB))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not vectorized: too many instructions in "
 			 "basic block.\n");
       free_data_refs (datarefs);
@@ -3055,7 +3055,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (!vect_analyze_data_refs (bb_vinfo, &min_vf))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not vectorized: unhandled data-ref in basic "
 			 "block");
 
@@ -3066,7 +3066,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (BB_VINFO_DATAREFS (bb_vinfo).length () < 2)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not vectorized: not enough data-refs in "
 			 "basic block");
 
@@ -3077,7 +3077,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (!vect_analyze_data_ref_accesses (bb_vinfo))
     {
      if (optinfo_enabled_p ())
-       vect_location_writeln (OPT_RECORD_FAILURE,
+       EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			"not vectorized: unhandled data access in "
 			"basic block");
 
@@ -3091,7 +3091,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (bb_vinfo->grouped_stores.is_empty ())
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not vectorized: no grouped stores in "
 			 "basic block.\n");
 
@@ -3110,9 +3110,9 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
     {
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_FAILURE,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			   "Failed to SLP the basic block.\n");
-	  vect_location_writeln (OPT_RECORD_FAILURE, 
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
 			   "not vectorized: failed to find SLP opportunities "
 			   "in basic block.\n");
 	}
@@ -3130,7 +3130,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
       if (! vect_slp_analyze_and_verify_instance_alignment (instance)
 	  || ! vect_slp_analyze_instance_dependence (instance))
 	{
-	  vect_location_writeln (OPT_RECORD_REMARK,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			   "removing SLP instance operations starting from: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
 			    SLP_TREE_SCALAR_STMTS
@@ -3156,7 +3156,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (!vect_slp_analyze_operations (bb_vinfo))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not vectorized: bad operation in basic block.\n");
 
       delete bb_vinfo;
@@ -3168,7 +3168,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
       && !vect_bb_vectorization_profitable_p (bb_vinfo))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not vectorized: vectorization is not "
 			 "profitable.\n");
 
@@ -3177,7 +3177,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
     }
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK,
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 		     "Basic block will be vectorized using SLP\n");
 
   return bb_vinfo;
@@ -3196,7 +3196,7 @@ vect_slp_bb (basic_block bb)
   auto_vector_sizes vector_sizes;
 
   if (optinfo_enabled_p ())
-    vect_location_writeln (OPT_RECORD_REMARK, "===vect_slp_analyze_bb===");
+    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "===vect_slp_analyze_bb===");
 
   /* Autodetect first vector size we try.  */
   current_vector_size = 0;
@@ -3249,12 +3249,12 @@ vect_slp_bb (basic_block bb)
 	  && dbg_cnt (vect_slp))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_REMARK, "SLPing BB part\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "SLPing BB part\n");
 
 	  vect_schedule_slp (bb_vinfo);
 
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_REMARK,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			     "basic block part vectorized\n");
 
 	  vectorized = true;
@@ -3293,7 +3293,7 @@ vect_slp_bb (basic_block bb)
 	  current_vector_size = vector_sizes[next_size++];
 	  if (optinfo_enabled_p ())
 	    {
-	      vect_location_writeln (OPT_RECORD_REMARK,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
 			       "***** Re-trying analysis with "
 			       "vector size ");
 	      dump_dec (MSG_NOTE, current_vector_size);
@@ -3958,7 +3958,7 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
 	      if (optinfo_enabled_p ())
 		{
 		  // FIXME: would be better to use "stmt" for location here:
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 					 "permutation requires at "
 					 "least three vectors ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -4261,8 +4261,8 @@ vect_schedule_slp (vec_info *vinfo)
       is_store = vect_schedule_slp_instance (SLP_INSTANCE_TREE (instance),
                                              instance, bst_map);
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_REMARK,
-                         "vectorizing stmts using SLP.\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) 
+	  << "vectorizing stmts using SLP";
     }
   delete bst_map;
 
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 26709f5..f8782f5 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -266,8 +266,8 @@ is_simple_and_all_uses_invariant (gimple *stmt, loop_vec_info loop_vinfo)
       if (!vect_is_simple_use (op, loop_vinfo, &def_stmt, &dt))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-			     "use not simple.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "use not simple");
 	  return false;
 	}
 
@@ -468,7 +468,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
   if (!vect_is_simple_use (use, loop_vinfo, &def_stmt, &dt))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "not vectorized: unsupported use in stmt.\n");
       return false;
     }
@@ -709,7 +709,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
 		&& relevant != vect_used_only_live)
 	      {
 		if (optinfo_enabled_p ())
-		  vect_location_writeln (OPT_RECORD_FAILURE,
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				   "unsupported use of reduction.\n");
 		return false;
 	      }
@@ -721,7 +721,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
 		&& relevant != vect_used_in_outer)
               {
                 if (optinfo_enabled_p ())
-                  vect_location_writeln (OPT_RECORD_FAILURE,
+                  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                                    "unsupported use of nested cycle.\n");
 
                 return false;
@@ -734,7 +734,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
 		&& relevant != vect_used_only_live)
               {
                 if (optinfo_enabled_p ())
-                  vect_location_writeln (OPT_RECORD_FAILURE,
+                  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                                    "unsupported use of double reduction.\n");
 
                 return false;
@@ -1018,7 +1018,7 @@ vect_get_store_cost (struct data_reference *dr, int ncopies,
         *inside_cost = VECT_MAX_COST;
 
         if (optinfo_enabled_p ())
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "vect_model_store_cost: unsupported access.\n");
         break;
       }
@@ -1211,7 +1211,7 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
         *inside_cost = VECT_MAX_COST;
 
         if (optinfo_enabled_p ())
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "vect_model_load_cost: unsupported access.\n");
         break;
       }
@@ -1750,7 +1750,7 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
 	  : !vect_store_lanes_supported (vectype, group_size, true))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "can't use a fully-masked loop because the"
 			     " target doesn't have an appropriate masked"
 			     " load/store-lanes instruction.\n");
@@ -1774,7 +1774,7 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
 						   gs_info->scale))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "can't use a fully-masked loop because the"
 			     " target doesn't have an appropriate masked"
 			     " gather load or scatter store instruction.\n");
@@ -1792,7 +1792,7 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
       /* Element X of the data must come from iteration i * VF + X of the
 	 scalar loop.  We need more work to support other mappings.  */
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "can't use a fully-masked loop because an access"
 			 " isn't contiguous.\n");
       LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
@@ -1806,7 +1806,7 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
       || !can_vec_mask_load_store_p (vecmode, mask_mode, is_load))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "can't use a fully-masked loop because the target"
 			 " doesn't have the appropriate masked load or"
 			 " store.\n");
@@ -2101,7 +2101,7 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
 	  overrun_p = loop_vinfo && gap != 0;
 	  if (overrun_p && vls_type != VLS_LOAD)
 	    {
-	      vect_location_writeln (OPT_RECORD_FAILURE,
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			       "Grouped store with gaps requires"
 			       " non-consecutive accesses\n");
 	      return false;
@@ -2117,7 +2117,7 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
 	  if (overrun_p && !can_overrun_p)
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "Peeling for outer loop is not supported\n");
 	      return false;
 	    }
@@ -2203,8 +2203,8 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
 	  if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt))
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
-				 "use not simple.\n");
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				       "use not simple");
 	      return false;
 	    }
 	  next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
@@ -2215,7 +2215,7 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
     {
       gcc_assert (can_overrun_p);
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "Data access with gaps requires scalar "
 			 "epilogue loop\n");
       LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true;
@@ -2240,7 +2240,7 @@ get_negative_load_store_type (gimple *stmt, tree vectype,
   if (ncopies > 1)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "multiple types with negative step.\n");
       return VMAT_ELEMENTWISE;
     }
@@ -2250,7 +2250,7 @@ get_negative_load_store_type (gimple *stmt, tree vectype,
       && alignment_support_scheme != dr_unaligned_supported)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "negative step but alignment required.\n");
       return VMAT_ELEMENTWISE;
     }
@@ -2267,7 +2267,7 @@ get_negative_load_store_type (gimple *stmt, tree vectype,
   if (!perm_mask_for_reverse (vectype))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "negative step and reversing not supported.\n");
       return VMAT_ELEMENTWISE;
     }
@@ -2306,7 +2306,7 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
 				    &gs_info->offset_vectype))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "%s index use not simple.\n",
 			     vls_type == VLS_LOAD ? "gather" : "scatter");
 	  return false;
@@ -2348,7 +2348,7 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
       && !nunits.is_constant ())
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "Not using elementwise accesses due to variable "
 			 "vectorization factor.\n");
       return false;
@@ -2364,7 +2364,7 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
 	   && !pow2p_hwi (GROUP_SIZE (stmt_info))))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not falling back to elementwise accesses\n");
       return false;
     }
@@ -2384,7 +2384,7 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
   if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask)))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "mask argument is not a boolean.\n");
       return false;
     }
@@ -2392,7 +2392,7 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
   if (TREE_CODE (mask) != SSA_NAME)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "mask argument is not an SSA name.\n");
       return false;
     }
@@ -2405,8 +2405,8 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
 			   &mask_vectype))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-			 "mask use not simple.\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "mask use not simple");
       return false;
     }
 
@@ -2417,7 +2417,7 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
   if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "could not find an appropriate vector mask type.\n");
       return false;
     }
@@ -2427,7 +2427,7 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
     {
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_FAILURE,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			   "vector mask type ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, mask_vectype);
 	  dump_printf (MSG_MISSED_OPTIMIZATION,
@@ -2457,8 +2457,8 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
   if (CONSTANT_CLASS_P (rhs) && native_encode_expr (rhs, NULL, 64) == 0)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-			 "cannot encode constant as a byte sequence.\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "cannot encode constant as a byte sequence");
       return false;
     }
 
@@ -2470,8 +2470,8 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
 			   &rhs_vectype))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-			 "use not simple.\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "use not simple");
       return false;
     }
 
@@ -2479,8 +2479,8 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
   if (rhs_vectype && !useless_type_conversion_p (vectype, rhs_vectype))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-			 "incompatible vector types.\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "incompatible vector types");
       return false;
     }
 
@@ -3066,8 +3066,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	  && !types_compatible_p (rhs_type, TREE_TYPE (op)))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-                             "argument types differ.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "argument types differ");
 	  return false;
 	}
       if (!rhs_type)
@@ -3076,8 +3076,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt[i], &opvectype))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-                             "use not simple.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "use not simple");
 	  return false;
 	}
 
@@ -3087,8 +3087,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	       && opvectype != vectype_in)
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-                             "argument vector types differ.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "argument vector types differ");
 	  return false;
 	}
     }
@@ -3102,7 +3102,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     {
       if (optinfo_enabled_p ())
         {
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "no vectype for scalar type ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -3127,7 +3127,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   if (gimple_vuse (stmt))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "function reads from or writes to memory.\n");
       return false;
     }
@@ -3185,7 +3185,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       else
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "function is not vectorizable.\n");
 	  return false;
 	}
@@ -3667,8 +3667,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
 	  || thisarginfo.dt == vect_uninitialized_def)
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-			     "use not simple.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "use not simple");
 	  return false;
 	}
 
@@ -3742,7 +3742,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&vf))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not considering SIMD clones; not yet supported"
 			 " for variable-width vectors.\n");
       return NULL;
@@ -4525,9 +4525,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 	      && !type_has_mode_precision_p (rhs_type))))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-                         "type conversion to/from bit-precision unsupported."
-                         "\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "type conversion to/from bit-precision unsupported");
       return false;
     }
 
@@ -4535,8 +4534,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype_in))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
-                         "use not simple.\n");
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "use not simple");
       return false;
     }
   if (op_type == binary_op)
@@ -4555,8 +4554,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!ok)
 	{
           if (optinfo_enabled_p ())
-            vect_location_writeln (OPT_RECORD_FAILURE,
-                             "use not simple.\n");
+            EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "use not simple");
 	  return false;
 	}
     }
@@ -4571,7 +4570,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_FAILURE,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "no vectype for scalar type ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -4585,7 +4584,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (optinfo_enabled_p ())
 	{
-	  vect_location_writeln (OPT_RECORD_FAILURE,
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "can't convert between boolean and non "
 			   "boolean vectors");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
@@ -4638,7 +4637,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
       /* FALLTHRU */
     unsupported:
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "conversion not supported by target.\n");
       return false;
 
@@ -5109,8 +5108,8 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt[0], &vectype_in))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
-                         "use not simple.\n");
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "use not simple");
       return false;
     }
 
@@ -5141,7 +5140,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
 	  || !VECTOR_BOOLEAN_TYPE_P (vectype_in)))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "type conversion to/from bit-precision "
                          "unsupported.\n");
       return false;
@@ -5308,7 +5307,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!type_has_mode_precision_p (TREE_TYPE (scalar_dest)))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "bit-precision shifts not supported.\n");
       return false;
     }
@@ -5317,8 +5316,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
-                         "use not simple.\n");
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "use not simple");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -5330,7 +5329,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vectype)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "no vectype for scalar type\n");
       return false;
     }
@@ -5344,8 +5343,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1], &op1_vectype))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
-                         "use not simple.\n");
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "use not simple");
       return false;
     }
 
@@ -5396,7 +5395,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   else
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "operand mode requires invariant argument.\n");
       return false;
     }
@@ -5415,7 +5414,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
 	  || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                              "unusable type for last operand in"
                              " vector/vector shift/rotate.\n");
 	  return false;
@@ -5460,7 +5459,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
 			 != TYPE_MODE (TREE_TYPE (op1)))
 		    {
                       if (optinfo_enabled_p ())
-                        vect_location_writeln (OPT_RECORD_FAILURE,
+                        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                                          "unusable type for last operand in"
                                          " vector/vector shift/rotate.\n");
 		      return false;
@@ -5480,7 +5479,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!optab)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "no optab.\n");
       return false;
     }
@@ -5489,7 +5488,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (icode == CODE_FOR_nothing)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "op not supported by target.\n");
       /* Check only during analysis.  */
       if (maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD)
@@ -5507,7 +5506,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
       && !vect_worthwhile_without_simd_p (vinfo, code))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "not worthwhile without SIMD support.\n");
       return false;
     }
@@ -5678,7 +5677,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (op_type != unary_op && op_type != binary_op && op_type != ternary_op)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "num. args = %d (not unary/binary/ternary op).\n",
                          op_type);
       return false;
@@ -5697,7 +5696,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       && code != BIT_AND_EXPR)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "bit-precision arithmetic not supported.\n");
       return false;
     }
@@ -5706,8 +5705,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
-                         "use not simple.\n");
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+			       "use not simple");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -5724,7 +5723,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
 	  if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (scalar_dest)))
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "not supported operation on bool value.\n");
 	      return false;
 	    }
@@ -5739,7 +5738,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (optinfo_enabled_p ())
         {
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "no vectype for scalar type ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
                              TREE_TYPE (op0));
@@ -5760,8 +5759,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1]))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-                             "use not simple.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "use not simple");
 	  return false;
 	}
     }
@@ -5771,8 +5770,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!vect_is_simple_use (op2, vinfo, &def_stmt, &dt[2]))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
-                             "use not simple.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
+				   "use not simple");
 	  return false;
 	}
     }
@@ -5803,7 +5802,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!optab)
 	{
           if (optinfo_enabled_p ())
-            vect_location_writeln (OPT_RECORD_FAILURE,
+            EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                              "no optab.\n");
 	  return false;
 	}
@@ -5814,7 +5813,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!target_support_p)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "op not supported by target.\n");
       /* Check only during analysis.  */
       if (maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD)
@@ -5831,7 +5830,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       && !vect_worthwhile_without_simd_p (vinfo, code))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "not worthwhile without SIMD support.\n");
       return false;
     }
@@ -6129,7 +6128,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       if (slp_node != NULL)
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "SLP of masked stores not supported.\n");
 	  return false;
 	}
@@ -6175,7 +6174,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   if (loop && nested_in_vect_loop_p (loop, stmt) && ncopies > 1)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "multiple types in nested loop.\n");
       return false;
     }
@@ -6207,7 +6206,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	       && (memory_access_type != VMAT_GATHER_SCATTER || gs_info.decl))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "unsupported access type for masked store.\n");
 	  return false;
 	}
@@ -7292,7 +7291,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       if (slp_node != NULL)
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "SLP of masked loads not supported.\n");
 	  return false;
 	}
@@ -7336,7 +7335,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   if (nested_in_vect_loop && ncopies > 1)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "multiple types in nested loop.\n");
       return false;
     }
@@ -7349,7 +7348,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 		   STMT_VINFO_MIN_NEG_DIST (stmt_info)))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "cannot perform implicit CSE when unrolling "
 			 "with negative dependence distance\n");
       return false;
@@ -7363,7 +7362,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "Aligned load, but unsupported type.\n");
       return false;
     }
@@ -7390,7 +7389,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 		       STMT_VINFO_MIN_NEG_DIST (stmt_info)))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "cannot perform implicit CSE when performing "
 			     "group loads with negative dependence distance\n");
 	  return false;
@@ -7405,7 +7404,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 				 (STMT_VINFO_GROUP_SAME_DR_STMT (stmt_info)))))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "conflicting SLP types for CSEd load\n");
 	  return false;
 	}
@@ -7436,7 +7435,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	  if (TREE_CODE (masktype) == INTEGER_TYPE)
 	    {
 	      if (optinfo_enabled_p ())
-		vect_location_writeln (OPT_RECORD_FAILURE,
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 				 "masked gather with integer mask not"
 				 " supported.");
 	      return false;
@@ -7446,7 +7445,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	       && memory_access_type != VMAT_GATHER_SCATTER)
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "unsupported access type for masked load.\n");
 	  return false;
 	}
@@ -8567,7 +8566,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
       if (STMT_VINFO_LIVE_P (stmt_info))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			     "value used after loop.\n");
 	  return false;
 	}
@@ -8969,7 +8968,7 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
   if (STMT_VINFO_LIVE_P (stmt_info))
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "value used after loop.\n");
       return false;
     }
@@ -9234,7 +9233,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
   if (gimple_has_volatile_ops (stmt))
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "not vectorized: stmt has volatile operands\n");
 
       return false;
@@ -9404,7 +9403,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
     {
       if (optinfo_enabled_p ())
         {
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "not vectorized: relevant stmt not ");
           dump_printf (MSG_MISSED_OPTIMIZATION, "supported: ");
           dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -9423,7 +9422,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
     {
       if (optinfo_enabled_p ())
         {
-          vect_location_writeln (OPT_RECORD_FAILURE,
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                            "not vectorized: live stmt not supported: ");
           dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }
@@ -9541,7 +9540,7 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!STMT_VINFO_LIVE_P (stmt_info))
 	{
 	  if (optinfo_enabled_p ())
-	    vect_location_writeln (OPT_RECORD_FAILURE,
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                              "stmt not supported.\n");
 	  gcc_unreachable ();
 	}
@@ -9930,7 +9929,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
   if (TREE_CODE (operand) != SSA_NAME)
     {
       if (optinfo_enabled_p ())
-	vect_location_writeln (OPT_RECORD_FAILURE,
+	EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
 			 "not ssa-name.\n");
       return false;
     }
@@ -9994,7 +9993,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
   if (*dt == vect_unknown_def_type)
     {
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "Unsupported pattern.\n");
       return false;
     }
@@ -10007,7 +10006,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
       break;
     default:
       if (optinfo_enabled_p ())
-        vect_location_writeln (OPT_RECORD_FAILURE,
+        EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
                          "unsupported defining stmt:\n");
       return false;
     }
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index c19fc4a..8d8c5a6 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -1389,10 +1389,6 @@ extern source_location vect_location;
    FIXME: or merge it all together into this class.  */
 extern optinfo_location vect_location_thing;
 
-extern void vect_location_writeln (enum opt_record_kind kind,
-				   const char *fmt, ...)
-  ATTRIBUTE_PRINTF_2;
-
 extern pending_optinfo
 emit_optinfo_at_vect_location (const location &impl_location,
 			       enum opt_record_kind kind);
-- 
1.8.5.3

