From 0592a2e6c5fc01bfaed71edd3988c8fddd22c5e1 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 9 May 2018 15:41:09 -0400
Subject: [PATCH 23/67] FIXME: try porting existing vectorization info to share
 with optimization records

---
 gcc/dumpfile.c              |  29 +-
 gcc/dumpfile.h              |   5 +
 gcc/optimization-records.cc |  81 ++--
 gcc/optimization-records.h  |  13 +
 gcc/tree-vect-data-refs.c   | 458 +++++++++++------------
 gcc/tree-vect-loop.c        | 891 +++++++++++++++++++++++---------------------
 gcc/tree-vect-slp.c         | 287 +++++++-------
 gcc/tree-vect-stmts.c       | 474 +++++++++++------------
 gcc/tree-vectorizer.c       |   4 +
 gcc/tree-vectorizer.h       |  22 ++
 10 files changed, 1202 insertions(+), 1062 deletions(-)

diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 7ae819a..20161f8 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -451,31 +451,36 @@ dump_printf (dump_flags_t dump_kind, const char *format, ...)
     }
 }
 
-/* Similar to dump_printf, except source location is also printed.  */
-
+/* FIXME.  */
 void
-dump_printf_loc (dump_flags_t dump_kind, source_location loc,
-		 const char *format, ...)
+dump_printf_loc_va (dump_flags_t dump_kind, source_location loc,
+		    const char *format, va_list *ap)
 {
   if (dump_file && (dump_kind & pflags))
     {
-      va_list ap;
       dump_loc (dump_kind, dump_file, loc);
-      va_start (ap, format);
-      vfprintf (dump_file, format, ap);
-      va_end (ap);
+      vfprintf (dump_file, format, *ap);
     }
 
   if (alt_dump_file && (dump_kind & alt_flags))
     {
-      va_list ap;
       dump_loc (dump_kind, alt_dump_file, loc);
-      va_start (ap, format);
-      vfprintf (alt_dump_file, format, ap);
-      va_end (ap);
+      vfprintf (alt_dump_file, format, *ap);
     }
 }
 
+/* Similar to dump_printf, except source location is also printed.  */
+
+void
+dump_printf_loc (dump_flags_t dump_kind, source_location loc,
+		 const char *format, ...)
+{
+  va_list ap;
+  va_start (ap, format);
+  dump_printf_loc_va (dump_kind, loc, format, &ap);
+  va_end (ap);
+}
+
 /* Output VALUE in decimal to appropriate dump streams.  */
 
 template<unsigned int N, typename C>
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index cb4e66a..044c3ad 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -165,6 +165,8 @@ extern const char *dump_flag_name (int);
 extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2;
 extern void dump_printf_loc (dump_flags_t, source_location,
                              const char *, ...) ATTRIBUTE_PRINTF_3;
+extern void dump_printf_loc_va (dump_flags_t, source_location,
+				const char *, va_list *) ATTRIBUTE_PRINTF (3, 0);
 extern void dump_function (int phase, tree fn);
 extern void dump_basic_block (int, basic_block, int);
 extern void dump_generic_expr_loc (int, source_location, int, tree);
@@ -199,6 +201,9 @@ dump_enabled_p (void)
   return (dump_file || alt_dump_file);
 }
 
+// FIXME:
+extern bool thing_enabled_p ();
+
 extern void fancy_dump_start ();
 extern void fancy_dump_finish ();
 
diff --git a/gcc/optimization-records.cc b/gcc/optimization-records.cc
index c020f85..dc47549 100644
--- a/gcc/optimization-records.cc
+++ b/gcc/optimization-records.cc
@@ -130,7 +130,15 @@ opt_record_kind_to_string (enum opt_record_kind kind)
 
 /* FIXME.  */
 
-static void
+bool
+optimization_record_enabled_p ()
+{
+  return records != NULL;
+}
+
+/* FIXME.  */
+
+void
 maybe_record_optimization_va (enum opt_record_kind kind,
 			      gimple *stmt,
 			      const char *fmt, va_list *ap)
@@ -139,13 +147,26 @@ maybe_record_optimization_va (enum opt_record_kind kind,
   if (!records)
     return;
 
+  /* Formatted output.  */
+  char *msg;
+  vasprintf (&msg, fmt, *ap);
+
   json::object *obj = new json::object ();
 
   obj->set ("kind", new json::string (opt_record_kind_to_string (kind)));
+  obj->set ("message", new json::string (msg));
 
   if (current_pass)
     obj->set ("pass", new json::string (current_pass->name));
-  location_t loc = gimple_location (stmt);
+
+  location_t loc = UNKNOWN_LOCATION;
+  if (stmt)
+    {
+      loc = gimple_location (stmt);
+      if (stmt->bb->count.initialized_p ())
+	obj->set ("count", profile_count_to_json (stmt->bb->count));
+    }
+
   if (loc != UNKNOWN_LOCATION)
     {
       // TOOD: record the location (just caret for now)
@@ -159,16 +180,42 @@ maybe_record_optimization_va (enum opt_record_kind kind,
       obj->set ("function", new json::string (fnname));
     }
 
-  /* Formatted output.  */
-  char *msg;
-  vasprintf (&msg, fmt, *ap);
-  obj->set ("message", new json::string (msg));
+  records->append (obj);
+
+  // Also send it through the diagnostics subsystem:
+  if (1)
+    {
+      if (current_pass)
+	remark (loc, 0, "%s [pass=%qs]", msg, current_pass->name);
+      else
+	remark (loc, 0, "%s", msg);
+    }
+
   free (msg);
+}
 
-  if (stmt->bb->count.initialized_p ())
-    obj->set ("count", profile_count_to_json (stmt->bb->count));
+/* FIXME.  */
 
-  records->append (obj);
+void
+maybe_record_optimization_va (enum opt_record_kind kind,
+			      struct loop *loop,
+			      const char *fmt, va_list *ap)
+{
+  gimple *stmt = get_loop_exit_condition (loop);
+  if (!stmt)
+    {
+      gimple_stmt_iterator si;
+      for (si = gsi_start_bb (loop->header); !gsi_end_p (si); gsi_next (&si))
+	{
+	  if (LOCATION_LOCUS (gimple_location (stmt)) > BUILTINS_LOCATION)
+	    {
+	      stmt = gsi_stmt (si);
+	      break;
+	    }
+	}
+    }
+
+  maybe_record_optimization_va (kind, stmt, fmt, ap);
 }
 
 /* FIXME.  */
@@ -199,22 +246,8 @@ maybe_record_optimization (enum opt_record_kind kind,
   if (!records)
     return;
 
-  gimple *stmt = get_loop_exit_condition (loop);
-  if (!stmt)
-    {
-      gimple_stmt_iterator si;
-      for (si = gsi_start_bb (loop->header); !gsi_end_p (si); gsi_next (&si))
-	{
-	  if (LOCATION_LOCUS (gimple_location (stmt)) > BUILTINS_LOCATION)
-	    {
-	      stmt = gsi_stmt (si);
-	      break;
-	    }
-	}
-    }
-
   va_list ap;
   va_start (ap, fmt);
-  maybe_record_optimization_va (kind, stmt, fmt, &ap);
+  maybe_record_optimization_va (kind, loop, fmt, &ap);
   va_end (ap);
 }
diff --git a/gcc/optimization-records.h b/gcc/optimization-records.h
index 8513781..b82a17f 100644
--- a/gcc/optimization-records.h
+++ b/gcc/optimization-records.h
@@ -37,6 +37,19 @@ enum opt_record_kind
 
 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_va (enum opt_record_kind kind,
+					  gimple *stmt,
+					  const char *fmt, va_list *ap)
+  ATTRIBUTE_PRINTF (3, 0);
+
+extern void maybe_record_optimization_va (enum opt_record_kind kind,
+					  struct loop *,
+					  const char *fmt, va_list *ap)
+  ATTRIBUTE_PRINTF (3, 0);
+
 // FIXME: param name?  i18n?
 extern void maybe_record_optimization (enum opt_record_kind kind,
 				       gimple *stmt,
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 9aabcc1..ad924d8 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -72,8 +72,8 @@ vect_lanes_optab_supported_p (const char *name, convert_optab optab,
       limit_p = !targetm.array_mode_supported_p (mode, count);
       if (!int_mode_for_size (bits, limit_p).exists (&array_mode))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "no array mode for %s["
 			     HOST_WIDE_INT_PRINT_DEC "]\n",
 			     GET_MODE_NAME (mode), count);
@@ -83,15 +83,15 @@ vect_lanes_optab_supported_p (const char *name, convert_optab optab,
 
   if (convert_optab_handler (optab, array_mode, mode) == CODE_FOR_nothing)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
                          "cannot use %s<%s><%s>\n", name,
                          GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
       return false;
     }
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "can use %s<%s><%s>\n", name, GET_MODE_NAME (array_mode),
                      GET_MODE_NAME (mode));
 
@@ -181,9 +181,9 @@ vect_check_nonzero_value (loop_vec_info loop_vinfo, tree value)
     if (checks[i] == value)
       return;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "need run-time check that ");
+      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");
     }
@@ -338,9 +338,9 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
       if (STMT_VINFO_GATHER_SCATTER_P (stmtinfo_a)
 	  || STMT_VINFO_GATHER_SCATTER_P (stmtinfo_b))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "versioning for alias not supported for: "
 			       "can't determine dependence between ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -353,9 +353,9 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	  return true;
 	}
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "versioning for alias required: "
 			   "can't determine dependence between ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -386,9 +386,9 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
       if (STMT_VINFO_GATHER_SCATTER_P (stmtinfo_a)
 	  || STMT_VINFO_GATHER_SCATTER_P (stmtinfo_b))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "versioning for alias not supported for: "
 			       "bad dist vector for ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -401,9 +401,9 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	  return true;
 	}
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "versioning for alias required: "
                            "bad dist vector for ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, DR_REF (dra));
@@ -426,15 +426,15 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
     {
       int dist = dist_v[loop_depth];
 
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
                          "dependence distance  = %d.\n", dist);
 
       if (dist == 0)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      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 ");
@@ -462,8 +462,8 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	     where loads from the group interleave with the store.  */
 	  if (!vect_preserves_scalar_order_p (DR_STMT (dra), DR_STMT (drb)))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "READ_WRITE dependence in interleaving.\n");
 	      return true;
 	    }
@@ -475,8 +475,8 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 		vect_check_nonzero_value (loop_vinfo, indicator);
 	      else if (integer_zerop (indicator))
 		{
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_FAILURE,
 				 "access also has a zero step\n");
 		  return true;
 		}
@@ -489,8 +489,8 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	  /* If DDR_REVERSED_P the order of the data-refs in DDR was
 	     reversed (to make distance vector positive), and the actual
 	     distance is negative.  */
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 	                     "dependence distance negative.\n");
 	  /* Record a negative dependence distance to later limit the
 	     amount of stmt copying / unrolling we can perform.
@@ -508,8 +508,8 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 	  /* The dependence distance requires reduction of the maximal
 	     vectorization factor.  */
 	  *max_vf = abs (dist);
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 	                     "adjusting maximal vectorization factor to %i\n",
 	                     *max_vf);
 	}
@@ -518,15 +518,15 @@ 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 (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 	                     "dependence distance >= VF.\n");
 	  continue;
 	}
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 	               "not vectorized, possible dependence "
 	               "between data-refs ");
 	  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
@@ -554,8 +554,8 @@ vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo,
   unsigned int i;
   struct data_dependence_relation *ddr;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_analyze_data_ref_dependences ===\n");
 
   LOOP_VINFO_DDRS (loop_vinfo)
@@ -619,9 +619,9 @@ vect_slp_analyze_data_ref_dependence (struct data_dependence_relation *ddr)
   /* Unknown data dependence.  */
   if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
     {
-      if  (dump_enabled_p ())
+      if  (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "can't determine dependence between ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, DR_REF (dra));
 	  dump_printf (MSG_MISSED_OPTIMIZATION,  " and ");
@@ -629,9 +629,9 @@ vect_slp_analyze_data_ref_dependence (struct data_dependence_relation *ddr)
 	  dump_printf (MSG_MISSED_OPTIMIZATION,  "\n");
 	}
     }
-  else if (dump_enabled_p ())
+  else if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "determined dependence between ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
       dump_printf (MSG_NOTE, " and ");
@@ -724,8 +724,8 @@ vect_slp_analyze_node_dependences (slp_instance instance, slp_tree node,
 bool
 vect_slp_analyze_instance_dependence (slp_instance instance)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_slp_analyze_instance_dependence ===\n");
 
   /* The stores of this instance are at the root of the SLP tree.  */
@@ -784,17 +784,17 @@ vect_record_base_alignment (vec_info *vinfo, gimple *stmt,
   if (!existed || entry->base_alignment < drb->base_alignment)
     {
       entry = drb;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  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");
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "  alignment:    %d\n", drb->base_alignment);
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "  misalignment: %d\n", drb->base_misalignment);
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "  based on:     ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
@@ -867,8 +867,8 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
   tree ref = DR_REF (dr);
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "vect_compute_data_ref_alignment:\n");
 
   if (loop_vinfo)
@@ -902,13 +902,13 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
       step_preserves_misalignment_p
 	= (DR_STEP_ALIGNMENT (dr) % vector_alignment) == 0;
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
 	  if (step_preserves_misalignment_p)
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "inner step divides the vector alignment.\n");
 	  else
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "inner step doesn't divide the vector"
 			     " alignment.\n");
 	}
@@ -924,8 +924,8 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
       step_preserves_misalignment_p
 	= multiple_p (DR_STEP_ALIGNMENT (dr) * vf, vector_alignment);
 
-      if (!step_preserves_misalignment_p && dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (!step_preserves_misalignment_p && thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "step doesn't divide the vector alignment.\n");
     }
 
@@ -947,9 +947,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 	 negative when computing the starting misalignment below.  */
       || TREE_CODE (drb->step) != INTEGER_CST)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 	                   "Unknown alignment for access: ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, ref);
 	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -965,9 +965,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 	  || !vect_can_force_dr_alignment_p (base,
 					     vector_alignment * BITS_PER_UNIT))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 	                       "can't force alignment of ref: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
 	      dump_printf (MSG_NOTE, "\n");
@@ -978,9 +978,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
       /* Force the alignment of the decl.
 	 NOTE: This is the only change to the code we make during
 	 the analysis phase, before deciding to vectorize the loop.  */
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_NOTE, vect_location, "force alignment of ");
+          vect_location_writeln (OPT_RECORD_REMARK, "force alignment of ");
           dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
           dump_printf (MSG_NOTE, "\n");
         }
@@ -1004,9 +1004,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
   if (!known_misalignment (misalignment, vector_alignment,
 			   &const_misalignment))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "Non-constant misalignment for access: ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, ref);
 	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -1016,9 +1016,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 
   SET_DR_MISALIGNMENT (dr, const_misalignment);
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      vect_location_writeln (OPT_RECORD_FAILURE,
                        "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
       dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, ref);
       dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -1085,8 +1085,8 @@ vect_update_misalignment_for_peel (struct data_reference *dr,
       return;
     }
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "Setting misalignment " \
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "Setting misalignment " \
 		     "to unknown (-1).\n");
   SET_DR_MISALIGNMENT (dr, DR_MISALIGNMENT_UNKNOWN);
 }
@@ -1103,13 +1103,13 @@ verify_data_ref_alignment (data_reference_p dr)
     = vect_supportable_dr_alignment (dr, false);
   if (!supportable_dr_alignment)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
 	  if (DR_IS_READ (dr))
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "not vectorized: unsupported unaligned load.");
 	  else
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "not vectorized: unsupported unaligned "
 			     "store.");
 
@@ -1120,8 +1120,8 @@ verify_data_ref_alignment (data_reference_p dr)
       return false;
     }
 
-  if (supportable_dr_alignment != dr_aligned && dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (supportable_dr_alignment != dr_aligned && thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "Vectorizing an unaligned access.\n");
 
   return true;
@@ -1216,17 +1216,17 @@ vector_alignment_reachable_p (struct data_reference *dr)
     {
       HOST_WIDE_INT elmsize =
 		int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 	                   "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
 	  dump_printf (MSG_NOTE,
 	               ". misalignment = %d.\n", DR_MISALIGNMENT (dr));
 	}
       if (DR_MISALIGNMENT (dr) % elmsize)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 	                     "data size does not divide the misalignment.\n");
 	  return false;
 	}
@@ -1236,8 +1236,8 @@ vector_alignment_reachable_p (struct data_reference *dr)
     {
       tree type = TREE_TYPE (DR_REF (dr));
       bool is_packed = not_size_aligned (DR_REF (dr));
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 	                 "Unknown misalignment, %snaturally aligned\n",
 			 is_packed ? "not " : "");
       return targetm.vectorize.vector_alignment_reachable (type, is_packed);
@@ -1271,8 +1271,8 @@ vect_get_data_access_cost (struct data_reference *dr,
   else
     vect_get_store_cost (dr, ncopies, inside_cost, body_cost_vec);
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "vect_get_data_access_cost: inside_cost = %d, "
                      "outside_cost = %d.\n", *inside_cost, *outside_cost);
 }
@@ -1662,8 +1662,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
   unsigned int mis, same_align_drs_max = 0;
   hash_table<peel_info_hasher> peeling_htab (1);
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_enhance_data_refs_alignment ===\n");
 
   /* Reset data so we can safely be called multiple times.  */
@@ -1828,8 +1828,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
         {
           if (!aligned_access_p (dr))
             {
-              if (dump_enabled_p ())
-                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              if (thing_enabled_p ())
+                vect_location_writeln (OPT_RECORD_FAILURE,
                                  "vector alignment may not be reachable\n");
               break;
             }
@@ -2022,8 +2022,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
 	  if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
 	    npeel /= GROUP_SIZE (stmt_info);
 
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_NOTE, vect_location,
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_REMARK,
                              "Try peeling by %d\n", npeel);
         }
 
@@ -2057,8 +2057,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
               if (max_peel > max_allowed_peel)
                 {
                   do_peeling = false;
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_NOTE, vect_location,
+                  if (thing_enabled_p ())
+                    vect_location_writeln (OPT_RECORD_REMARK,
                         "Disable peeling, max peels reached: %d\n", max_peel);
                 }
             }
@@ -2107,11 +2107,11 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
             LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo)
 	      = DR_MISALIGNMENT (dr0);
 	  SET_DR_MISALIGNMENT (dr0, 0);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_NOTE, vect_location,
+              vect_location_writeln (OPT_RECORD_REMARK,
                                "Alignment of access forced using peeling.\n");
-              dump_printf_loc (MSG_NOTE, vect_location,
+              vect_location_writeln (OPT_RECORD_REMARK,
                                "Peeling for alignment will be applied.\n");
             }
 
@@ -2232,13 +2232,13 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
           stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
           dr = STMT_VINFO_DATA_REF (stmt_info);
 	  SET_DR_MISALIGNMENT (dr, 0);
-	  if (dump_enabled_p ())
-            dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_REMARK,
                              "Alignment of access forced using versioning.\n");
         }
 
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK,
                          "Versioning for alignment will be applied.\n");
 
       /* Peeling and versioning can't be done together at this time.  */
@@ -2300,9 +2300,9 @@ vect_find_same_alignment_drs (struct data_dependence_relation *ddr)
 
   STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_a).safe_push (drb);
   STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_b).safe_push (dra);
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "accesses have the same alignment: ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
       dump_printf (MSG_NOTE,  " and ");
@@ -2320,8 +2320,8 @@ vect_find_same_alignment_drs (struct data_dependence_relation *ddr)
 bool
 vect_analyze_data_refs_alignment (loop_vec_info vinfo)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_analyze_data_refs_alignment ===\n");
 
   /* Mark groups of data references with same alignment using
@@ -2349,8 +2349,8 @@ vect_analyze_data_refs_alignment (loop_vec_info vinfo)
 	      && !STMT_VINFO_GROUPED_ACCESS (stmt_info))
 	    continue;
 
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "not vectorized: can't calculate alignment "
 			     "for data ref.\n");
 
@@ -2383,8 +2383,8 @@ vect_slp_analyze_and_verify_node_alignment (slp_tree node)
 	  && ! vect_compute_data_ref_alignment (first_dr))
       || ! verify_data_ref_alignment (dr))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: bad data alignment in basic "
 			 "block.\n");
       return false;
@@ -2401,8 +2401,8 @@ vect_slp_analyze_and_verify_node_alignment (slp_tree node)
 bool
 vect_slp_analyze_and_verify_instance_alignment (slp_instance instance)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_slp_analyze_and_verify_instance_alignment ===\n");
 
   slp_tree node;
@@ -2455,9 +2455,9 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	 simply not include that gap.  */
       if ((dr_step % type_size) != 0)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 	                       "Step ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, step);
 	      dump_printf (MSG_NOTE,
@@ -2487,9 +2487,9 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	  GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = stmt;
 	  GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
 	  GROUP_GAP (stmt_info) = groupsize - 1;
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 	                       "Detected single element interleaving ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr));
 	      dump_printf (MSG_NOTE, " step ");
@@ -2500,9 +2500,9 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	  return true;
 	}
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
- 	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ 	  vect_location_writeln (OPT_RECORD_FAILURE,
 	                   "not consecutive access ");
 	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }
@@ -2514,7 +2514,7 @@ vect_analyze_group_access_1 (struct data_reference *dr)
           return true;
         }
 
-      dump_printf_loc (MSG_NOTE, vect_location, "using strided accesses\n");
+      vect_location_writeln (OPT_RECORD_REMARK, "using strided accesses\n");
       STMT_VINFO_STRIDED_P (stmt_info) = true;
       return true;
     }
@@ -2542,14 +2542,14 @@ vect_analyze_group_access_1 (struct data_reference *dr)
             {
               if (DR_IS_WRITE (data_ref))
                 {
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                  if (thing_enabled_p ())
+                    vect_location_writeln (OPT_RECORD_FAILURE,
                                      "Two store stmts share the same dr.\n");
                   return false;
                 }
 
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "Two or more load stmts share the same dr.\n");
 
               /* For load use the same data-ref load.  */
@@ -2576,8 +2576,8 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	      slp_impossible = true;
 	      if (DR_IS_WRITE (data_ref))
 		{
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                  if (thing_enabled_p ())
+                    vect_location_writeln (OPT_RECORD_FAILURE,
                                      "interleaved store with gaps\n");
 		  return false;
 		}
@@ -2604,8 +2604,8 @@ vect_analyze_group_access_1 (struct data_reference *dr)
          inefficient way we have to cap earlier.  See PR78699 for example.  */
       if (groupsize > 4096)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "group is too large\n");
 	  return false;
 	}
@@ -2615,8 +2615,8 @@ vect_analyze_group_access_1 (struct data_reference *dr)
       if (groupsize != count
 	  && !DR_IS_READ (dr))
         {
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "interleaved store with gaps\n");
 	  return false;
 	}
@@ -2628,9 +2628,9 @@ vect_analyze_group_access_1 (struct data_reference *dr)
       GROUP_GAP (vinfo_for_stmt (stmt)) = groupsize - last_accessed_element;
 
       GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "Detected interleaving ");
 	  if (DR_IS_READ (dr))
 	    dump_printf (MSG_NOTE, "load ");
@@ -2640,7 +2640,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)
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "There is a gap of %u elements after the group\n",
 			     GROUP_GAP (vinfo_for_stmt (stmt)));
 	}
@@ -2707,8 +2707,8 @@ vect_analyze_data_ref_access (struct data_reference *dr)
 
   if (loop_vinfo && !step)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 	                 "bad data-ref access in loop\n");
       return false;
     }
@@ -2724,8 +2724,8 @@ vect_analyze_data_ref_access (struct data_reference *dr)
 	 loop-carried dependencies between inner loop iterations.  */
       if (loop->safelen < 2)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "zero step in inner loop of nest\n");
 	  return false;
 	}
@@ -2741,8 +2741,8 @@ vect_analyze_data_ref_access (struct data_reference *dr)
       step = STMT_VINFO_DR_STEP (stmt_info);
       if (integer_zerop (step))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 	                     "zero step in outer loop.\n");
 	  return DR_IS_READ (dr);
 	}
@@ -2764,8 +2764,8 @@ vect_analyze_data_ref_access (struct data_reference *dr)
 
   if (loop && nested_in_vect_loop_p (loop, stmt))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
 	                 "grouped access in outer loop.\n");
       return false;
     }
@@ -2906,8 +2906,8 @@ vect_analyze_data_ref_accesses (vec_info *vinfo)
   vec<data_reference_p> datarefs = vinfo->datarefs;
   struct data_reference *dr;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_analyze_data_ref_accesses ===\n");
 
   if (datarefs.is_empty ())
@@ -3030,9 +3030,9 @@ vect_analyze_data_ref_accesses (vec_info *vinfo)
 		break;
 	    }
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "Detected interleaving ");
 	      if (DR_IS_READ (dra))
 		dump_printf (MSG_NOTE, "load ");
@@ -3060,8 +3060,8 @@ vect_analyze_data_ref_accesses (vec_info *vinfo)
     if (STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) 
         && !vect_analyze_data_ref_access (dr))
       {
-	if (dump_enabled_p ())
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	if (thing_enabled_p ())
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 	                   "not vectorized: complicated access pattern.\n");
 
         if (is_a <bb_vec_info> (vinfo))
@@ -3213,9 +3213,9 @@ dependence_distance_ge_vf (data_dependence_relation *ddr,
 	return false;
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "dependence distance between ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr)));
       dump_printf (MSG_NOTE,  " and ");
@@ -3255,9 +3255,9 @@ vect_check_lower_bound (loop_vec_info loop_vinfo, tree expr, bool unsigned_p,
 	  {
 	    lower_bounds[i].unsigned_p = unsigned_p;
 	    lower_bounds[i].min_value = min_value;
-	    if (dump_enabled_p ())
+	    if (thing_enabled_p ())
 	      {
-		dump_printf_loc (MSG_NOTE, vect_location,
+		vect_location_writeln (OPT_RECORD_REMARK,
 				 "updating run-time check to ");
 		dump_lower_bound (MSG_NOTE, lower_bounds[i]);
 		dump_printf (MSG_NOTE, "\n");
@@ -3267,9 +3267,9 @@ 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 (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "need a run-time check that ");
+      vect_location_writeln (OPT_RECORD_REMARK, "need a run-time check that ");
       dump_lower_bound (MSG_NOTE, lower_bound);
       dump_printf (MSG_NOTE, "\n");
     }
@@ -3353,8 +3353,8 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
   unsigned int i;
   tree length_factor;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "=== vect_prune_runtime_alias_test_list ===\n");
 
   /* Step values are irrelevant for aliasing if the number of vector
@@ -3401,9 +3401,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	  vec_object_pair new_pair (DDR_OBJECT_A (ddr), DDR_OBJECT_B (ddr));
 	  if (!compared_objects.add (new_pair))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location, "checking that ");
+		  vect_location_writeln (OPT_RECORD_REMARK, "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);
@@ -3426,9 +3426,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	  && (vect_preserves_scalar_order_p (stmt_a, stmt_b)
 	      || vectorizable_with_step_bound_p (dr_a, dr_b, &lower_bound)))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "no need for alias check between ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
 	      dump_printf (MSG_NOTE, " and ");
@@ -3449,9 +3449,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	      || vect_small_gap_p (loop_vinfo, dr_b, lower_bound)))
 	{
 	  bool unsigned_p = dr_known_forward_stride_p (dr_a);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location, "no alias between ");
+	      vect_location_writeln (OPT_RECORD_REMARK, "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));
@@ -3525,9 +3525,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 					     segment_length_b,
 					     access_size_a,
 					     access_size_b);
-	  if (res >= 0 && dump_enabled_p ())
+	  if (res >= 0 && thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "can tell at compile time that ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
 	      dump_printf (MSG_NOTE, " and ");
@@ -3543,8 +3543,8 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 
 	  if (res == 1)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_NOTE, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_REMARK,
 				 "not vectorized: compilation time alias.\n");
 	      return false;
 	    }
@@ -3566,13 +3566,13 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
   unsigned int count = (comp_alias_ddrs.length ()
 			+ check_unequal_addrs.length ());
 
-  dump_printf_loc (MSG_NOTE, vect_location,
+  vect_location_writeln (OPT_RECORD_REMARK,
 		   "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))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "number of versioning for alias "
 			 "run-time tests exceeds %d "
 			 "(--param vect-max-version-for-alias-checks)\n",
@@ -3951,8 +3951,8 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf)
   struct data_reference *dr;
   tree scalar_type;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "=== vect_analyze_data_refs ===\n");
 
   if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo))
@@ -3974,8 +3974,8 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf)
 again:
       if (!dr || !DR_REF (dr))
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 	                     "not vectorized: unhandled data-ref\n");
           return false;
         }
@@ -4094,9 +4094,9 @@ again:
 
 	  if (gatherscatter == SG_NONE && !simd_lane_access)
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
                                    "not vectorized: data ref analysis "
                                    "failed ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -4111,8 +4111,8 @@ again:
 
       if (TREE_CODE (DR_BASE_ADDRESS (dr)) == INTEGER_CST)
         {
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_FAILURE,
                              "not vectorized: base addr of dr is a "
                              "constant\n");
 
@@ -4126,9 +4126,9 @@ again:
 
       if (TREE_THIS_VOLATILE (DR_REF (dr)))
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
                                "not vectorized: volatile type ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }
@@ -4141,9 +4141,9 @@ again:
 
       if (stmt_can_throw_internal (stmt))
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
                                "not vectorized: statement can throw an "
                                "exception ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -4160,9 +4160,9 @@ again:
       if (TREE_CODE (DR_REF (dr)) == COMPONENT_REF
 	  && DECL_BIT_FIELD (TREE_OPERAND (DR_REF (dr), 1)))
 	{
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
                                "not vectorized: statement is bitfield "
                                "access ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -4185,7 +4185,7 @@ again:
 	      || (gimple_call_internal_fn (stmt) != IFN_MASK_LOAD
 		  && gimple_call_internal_fn (stmt) != IFN_MASK_STORE)))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
 	      dump_printf_loc (MSG_MISSED_OPTIMIZATION,  vect_location,
 	                       "not vectorized: dr in a call ");
@@ -4219,9 +4219,9 @@ again:
 	  tree init_addr = fold_build_pointer_plus (base, init_offset);
 	  tree init_ref = build_fold_indirect_ref (init_addr);
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
                                "analyze in outer loop: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, init_ref);
 	      dump_printf (MSG_NOTE, "\n");
@@ -4232,9 +4232,9 @@ again:
 	    /* dr_analyze_innermost already explained the failure.  */
 	    return false;
 
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
                                "\touter base_address: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
                                  STMT_VINFO_DR_BASE_ADDRESS (stmt_info));
@@ -4261,9 +4261,9 @@ again:
 
       if (STMT_VINFO_DATA_REF (stmt_info))
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
                                "not vectorized: more than one data ref "
                                "in stmt: ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -4289,9 +4289,9 @@ again:
 	  && VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (dr), 0))
 	  && DECL_NONALIASED (TREE_OPERAND (DR_BASE_ADDRESS (dr), 0)))
 	{
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
                                "not vectorized: base object not addressable "
 			       "for stmt: ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -4312,9 +4312,9 @@ again:
 	= get_vectype_for_scalar_type (scalar_type);
       if (!STMT_VINFO_VECTYPE (stmt_info))
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
                                "not vectorized: no vectype for stmt: ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
               dump_printf (MSG_MISSED_OPTIMIZATION, " scalar_type: ");
@@ -4341,9 +4341,9 @@ again:
         }
       else
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "got vectype for stmt: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
@@ -4366,9 +4366,9 @@ again:
 	    {
 	      STMT_VINFO_DATA_REF (stmt_info) = NULL;
 	      free_data_ref (dr);
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   (gatherscatter == GATHER) ?
 				   "not vectorized: not suitable for gather "
 				   "load " :
@@ -4389,9 +4389,9 @@ again:
 	{
 	  if (nested_in_vect_loop_p (loop, stmt))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+		  vect_location_writeln (OPT_RECORD_FAILURE,
                                    "not vectorized: not suitable for strided "
                                    "load ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -4621,9 +4621,9 @@ vect_create_addr_base_for_vector_ref (gimple *stmt,
 	mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (addr_base));
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "created ");
+      vect_location_writeln (OPT_RECORD_REMARK, "created ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, addr_base);
       dump_printf (MSG_NOTE, "\n");
     }
@@ -4748,10 +4748,10 @@ vect_create_data_ref_ptr (gimple *stmt, tree aggr_type, struct loop *at_loop,
      in LOOP.  */
   base_name = get_name (DR_BASE_ADDRESS (dr));
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       tree dr_base_type = TREE_TYPE (DR_BASE_OBJECT (dr));
-      dump_printf_loc (MSG_NOTE, vect_location,
+      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);
@@ -5078,8 +5078,8 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
      be a power of two.  */
   if (count != 3 && exact_log2 (count) == -1)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "the size of the group of accesses"
 			 " is not a power of 2 or not eqaul to 3\n");
       return false;
@@ -5097,8 +5097,8 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
 	  unsigned int nelt;
 	  if (!GET_MODE_NUNITS (mode).is_constant (&nelt))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "cannot handle groups of 3 stores for"
 				 " variable-length vectors\n");
 	      return false;
@@ -5124,7 +5124,7 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
 	      indices.new_vector (sel, 2, nelt);
 	      if (!can_vec_perm_const_p (mode, indices))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    dump_printf (MSG_MISSED_OPTIMIZATION,
 				 "permutation op not supported by target.\n");
 		  return false;
@@ -5142,7 +5142,7 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
 	      indices.new_vector (sel, 2, nelt);
 	      if (!can_vec_perm_const_p (mode, indices))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    dump_printf (MSG_MISSED_OPTIMIZATION,
 				 "permutation op not supported by target.\n");
 		  return false;
@@ -5176,7 +5176,7 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
 	}
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf (MSG_MISSED_OPTIMIZATION,
 		 "permutaion op not supported by target.\n");
   return false;
@@ -5689,8 +5689,8 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
      see PR65518).  */
   if (single_element_p && maybe_gt (count, TYPE_VECTOR_SUBPARTS (vectype)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "single-element interleaving not supported "
 			 "for not adjacent vector loads\n");
       return false;
@@ -5700,8 +5700,8 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
      be a power of two.  */
   if (count != 3 && exact_log2 (count) == -1)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "the size of the group of accesses"
 			 " is not a power of 2 or not equal to 3\n");
       return false;
@@ -5716,8 +5716,8 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
 	  unsigned int nelt;
 	  if (!GET_MODE_NUNITS (mode).is_constant (&nelt))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "cannot handle groups of 3 loads for"
 				 " variable-length vectors\n");
 	      return false;
@@ -5737,8 +5737,8 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
 	      indices.new_vector (sel, 2, nelt);
 	      if (!can_vec_perm_const_p (mode, indices))
 		{
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_FAILURE,
 				     "shuffle of 3 loads is not supported by"
 				     " target\n");
 		  return false;
@@ -5751,8 +5751,8 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
 	      indices.new_vector (sel, 2, nelt);
 	      if (!can_vec_perm_const_p (mode, indices))
 		{
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_FAILURE,
 				     "shuffle of 3 loads is not supported by"
 				     " target\n");
 		  return false;
@@ -5783,8 +5783,8 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
         }
     }
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_FAILURE,
 		     "extract even/odd not supported by target\n");
   return false;
 }
@@ -6126,8 +6126,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       vec_perm_indices indices (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shuffle of 2 fields structure is not \
 			      supported by target\n");
 	  return false;
@@ -6141,8 +6141,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shuffle of 2 fields structure is not \
 			      supported by target\n");
 	  return false;
@@ -6156,8 +6156,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shift permutation is not supported by target\n");
 	  return false;
 	}
@@ -6172,8 +6172,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "select is not supported by target\n");
 	  return false;
 	}
@@ -6236,8 +6236,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       vec_perm_indices indices (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shuffle of 3 fields structure is not \
 			      supported by target\n");
 	  return false;
@@ -6251,8 +6251,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shift permutation is not supported by target\n");
 	  return false;
 	}
@@ -6265,8 +6265,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shift permutation is not supported by target\n");
 	  return false;
 	}
@@ -6279,8 +6279,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shift permutation is not supported by target\n");
 	  return false;
 	}
@@ -6293,8 +6293,8 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
       indices.new_vector (sel, 2, nelt);
       if (!can_vec_perm_const_p (TYPE_MODE (vectype), indices))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "shift permutation is not supported by target\n");
 	  return false;
 	}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 4ce721ed..55d7aaf 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vector-builder.h"
 #include "vec-perm-indices.h"
 #include "tree-eh.h"
+#include "optimization-records.h"
 
 /* Loop Vectorization Pass.
 
@@ -155,6 +156,56 @@ along with GCC; see the file COPYING3.  If not see
 
 static void vect_estimate_min_profitable_iters (loop_vec_info, int *, int *);
 
+bool thing_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 (vect_location_thing.m_loop != NULL)
+	maybe_record_optimization_va (kind, vect_location_thing.m_loop,
+				      fmt, &ap);
+      else
+	maybe_record_optimization_va (kind, vect_location_thing.m_stmt,
+				      fmt, &ap);
+    }
+
+  va_end (ap);
+}
+
 /* Function vect_determine_vectorization_factor
 
    Determine the vectorization factor (VF).  VF is the number of data elements
@@ -200,9 +251,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
   bool bool_result;
   auto_vec<stmt_vec_info> mask_producers;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_determine_vectorization_factor ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+                     "=== vect_determine_vectorization_factor ===");
 
   for (i = 0; i < nbbs; i++)
     {
@@ -213,9 +264,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	{
 	  phi = si.phi ();
 	  stmt_info = vinfo_for_stmt (phi);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location, "==> examining phi: ");
+	      vect_location_writeln (OPT_RECORD_REMARK, "==> examining phi: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	    }
 
@@ -227,9 +278,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      gcc_assert (!STMT_VINFO_VECTYPE (stmt_info));
               scalar_type = TREE_TYPE (PHI_RESULT (phi));
 
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location,
+		  vect_location_writeln (OPT_RECORD_REMARK,
                                    "get vectype for scalar type:  ");
 		  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
                   dump_printf (MSG_NOTE, "\n");
@@ -238,9 +289,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      vectype = get_vectype_for_scalar_type (scalar_type);
 	      if (!vectype)
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      vect_location_writeln (OPT_RECORD_FAILURE,
                                        "not vectorized: unsupported "
                                        "data-type ");
 		      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -251,16 +302,16 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 		}
 	      STMT_VINFO_VECTYPE (stmt_info) = vectype;
 
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location, "vectype: ");
+		  vect_location_writeln (OPT_RECORD_REMARK, "vectype: ");
 		  dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
                   dump_printf (MSG_NOTE, "\n");
 		}
 
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location, "nunits = ");
+		  vect_location_writeln (OPT_RECORD_REMARK, "nunits = ");
 		  dump_dec (MSG_NOTE, TYPE_VECTOR_SUBPARTS (vectype));
 		  dump_printf (MSG_NOTE, "\n");
 		}
@@ -281,9 +332,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 
           stmt_info = vinfo_for_stmt (stmt);
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
                                "==> examining statement: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	    }
@@ -302,17 +353,17 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
                 {
                   stmt = pattern_stmt;
                   stmt_info = vinfo_for_stmt (pattern_stmt);
-                  if (dump_enabled_p ())
+                  if (thing_enabled_p ())
                     {
-                      dump_printf_loc (MSG_NOTE, vect_location,
+                      vect_location_writeln (OPT_RECORD_REMARK,
                                        "==> examining pattern statement: ");
                       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
                     }
                 }
               else
 	        {
-	          if (dump_enabled_p ())
-	            dump_printf_loc (MSG_NOTE, vect_location, "skip.\n");
+	          if (thing_enabled_p ())
+	            vect_location_writeln (OPT_RECORD_REMARK, "skip.\n");
                   gsi_next (&si);
 	          continue;
                 }
@@ -351,9 +402,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 
 		  if (!gsi_end_p (pattern_def_si))
 		    {
-		      if (dump_enabled_p ())
+		      if (thing_enabled_p ())
 			{
-			  dump_printf_loc (MSG_NOTE, vect_location,
+			  vect_location_writeln (OPT_RECORD_REMARK,
                                            "==> examining pattern def stmt: ");
 			  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
                                             pattern_def_stmt, 0);
@@ -391,9 +442,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 		    }
 		  continue;
 		}
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-	          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	          vect_location_writeln (OPT_RECORD_FAILURE,
                                    "not vectorized: irregular stmt.");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,  TDF_SLIM, stmt,
                                     0);
@@ -403,9 +454,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 
 	  if (VECTOR_MODE_P (TYPE_MODE (gimple_expr_type (stmt))))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 	        {
-	          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	          vect_location_writeln (OPT_RECORD_FAILURE,
                                    "not vectorized: vector stmt in loop:");
 	          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 	        }
@@ -461,9 +512,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 		    }
 		}
 
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location,
+		  vect_location_writeln (OPT_RECORD_REMARK,
                                    "get vectype for scalar type:  ");
 		  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
                   dump_printf (MSG_NOTE, "\n");
@@ -471,9 +522,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      vectype = get_vectype_for_scalar_type (scalar_type);
 	      if (!vectype)
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      vect_location_writeln (OPT_RECORD_FAILURE,
                                        "not vectorized: unsupported "
                                        "data-type ");
 		      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -486,9 +537,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      if (!bool_result)
 		STMT_VINFO_VECTYPE (stmt_info) = vectype;
 
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location, "vectype: ");
+		  vect_location_writeln (OPT_RECORD_REMARK, "vectype: ");
 		  dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
                   dump_printf (MSG_NOTE, "\n");
 		}
@@ -506,9 +557,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      if (!bool_result)
 		scalar_type = vect_get_smallest_scalar_type (stmt, &dummy,
 							     &dummy);
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location,
+		  vect_location_writeln (OPT_RECORD_REMARK,
 				   "get vectype for scalar type:  ");
 		  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
 		  dump_printf (MSG_NOTE, "\n");
@@ -517,9 +568,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	    }
 	  if (!vf_vectype)
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
                                    "not vectorized: unsupported data-type ");
 		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
                                      scalar_type);
@@ -531,9 +582,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	  if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (vectype)),
 			GET_MODE_SIZE (TYPE_MODE (vf_vectype))))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
                                    "not vectorized: different sized vector "
                                    "types in statement, ");
 		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -546,16 +597,16 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      return false;
 	    }
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location, "vectype: ");
+	      vect_location_writeln (OPT_RECORD_REMARK, "vectype: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, vf_vectype);
               dump_printf (MSG_NOTE, "\n");
 	    }
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location, "nunits = ");
+	      vect_location_writeln (OPT_RECORD_REMARK, "nunits = ");
 	      dump_dec (MSG_NOTE, TYPE_VECTOR_SUBPARTS (vf_vectype));
 	      dump_printf (MSG_NOTE, "\n");
 	    }
@@ -571,18 +622,18 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
     }
 
   /* TODO: Analyze cost. Decide if worth while to vectorize.  */
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "vectorization factor = ");
+      vect_location_writeln (OPT_RECORD_REMARK, "vectorization factor = ");
       dump_dec (MSG_NOTE, vectorization_factor);
       dump_printf (MSG_NOTE, "\n");
     }
 
   if (known_le (vectorization_factor, 1U))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                         "not vectorized: unsupported data-type\n");
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: unsupported data-type");
       return false;
     }
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
@@ -603,9 +654,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 
 	  if (!mask_type)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "not vectorized: unsupported mask\n");
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
+				       "not vectorized: unsupported mask");
 	      return false;
 	    }
 	}
@@ -621,9 +672,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      if (!vect_is_simple_use (rhs, mask_producers[i]->vinfo,
 				       &def_stmt, &dt, &vectype))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      vect_location_writeln (OPT_RECORD_FAILURE,
 				       "not vectorized: can't compute mask type "
 				       "for statement, ");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,  TDF_SLIM, stmt,
@@ -643,9 +694,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      else if (maybe_ne (TYPE_VECTOR_SUBPARTS (mask_type),
 				 TYPE_VECTOR_SUBPARTS (vectype)))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      vect_location_writeln (OPT_RECORD_FAILURE,
 				       "not vectorized: different sized masks "
 				       "types in statement, ");
 		      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -660,9 +711,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	      else if (VECTOR_BOOLEAN_TYPE_P (mask_type)
 		       != VECTOR_BOOLEAN_TYPE_P (vectype))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      vect_location_writeln (OPT_RECORD_FAILURE,
 				       "not vectorized: mixed mask and "
 				       "nonmask vector types in statement, ");
 		      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -690,9 +741,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	 if-conversion.  */
       if (!mask_type)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "not vectorized: can't compute mask type "
 			       "for statement, ");
 	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,  TDF_SLIM, stmt,
@@ -735,9 +786,9 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
   step_expr = evolution_part;
   init_expr = unshare_expr (initial_condition_in_loop_num (access_fn, loop_nb));
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "step: ");
+      vect_location_writeln (OPT_RECORD_REMARK, "step: ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, step_expr);
       dump_printf (MSG_NOTE, ",  init: ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, init_expr);
@@ -757,9 +808,9 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
       && (TREE_CODE (step_expr) != REAL_CST
 	  || !flag_associative_math))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                         "step unknown.\n");
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
+			       "step unknown");
       return false;
     }
 
@@ -782,9 +833,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
   gphi_iterator gsi;
   bool double_reduc;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                     "=== vect_analyze_scalar_cycles ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+			   "=== vect_analyze_scalar_cycles ===");
 
   /* First - identify all inductions.  Reduction detection assumes that all the
      inductions have been identified, therefore, this order must not be
@@ -796,9 +847,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
       tree def = PHI_RESULT (phi);
       stmt_vec_info stmt_vinfo = vinfo_for_stmt (phi);
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
+	  vect_location_writeln (OPT_RECORD_REMARK, "Analyze phi: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	}
 
@@ -814,9 +865,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
       if (access_fn)
 	{
 	  STRIP_NOPS (access_fn);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
                                "Access function of PHI: ");
 	      dump_generic_expr (MSG_NOTE, TDF_SLIM, access_fn);
               dump_printf (MSG_NOTE, "\n");
@@ -840,8 +891,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
 		  != NULL_TREE);
       gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) != NULL_TREE);
 
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location, "Detected induction.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK, "Detected induction");
       STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_induction_def;
     }
 
@@ -854,9 +905,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
       stmt_vec_info stmt_vinfo = vinfo_for_stmt (phi);
       gimple *reduc_stmt;
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
+          vect_location_writeln (OPT_RECORD_REMARK, "Analyze phi: ");
           dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
         }
 
@@ -869,9 +920,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
         {
           if (double_reduc)
             {
-              if (dump_enabled_p ())
-                dump_printf_loc (MSG_NOTE, vect_location,
-				 "Detected double reduction.\n");
+              if (thing_enabled_p ())
+                vect_location_writeln (OPT_RECORD_REMARK,
+				       "Detected double reduction");
 
               STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_double_reduction_def;
               STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -881,9 +932,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
             {
               if (loop != LOOP_VINFO_LOOP (loop_vinfo))
                 {
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_NOTE, vect_location,
-				     "Detected vectorizable nested cycle.\n");
+                  if (thing_enabled_p ())
+                    vect_location_writeln (OPT_RECORD_REMARK,
+					   "Detected vectorizable nested cycle");
 
                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_nested_cycle;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -891,9 +942,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
                 }
               else
                 {
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_NOTE, vect_location,
-				     "Detected reduction.\n");
+                  if (thing_enabled_p ())
+                    vect_location_writeln (OPT_RECORD_REMARK,
+					   "Detected reduction");
 
                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_reduction_def;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -907,9 +958,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
             }
         }
       else
-        if (dump_enabled_p ())
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			   "Unknown def-use cycle pattern.\n");
+        if (thing_enabled_p ())
+          vect_location_writeln (OPT_RECORD_FAILURE,
+				 "Unknown def-use cycle pattern");
     }
 }
 
@@ -1029,9 +1080,9 @@ vect_get_loop_niters (struct loop *loop, tree *assumptions,
   *assumptions = boolean_true_node;
   *number_of_iterationsm1 = chrec_dont_know;
   *number_of_iterations = chrec_dont_know;
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== get_loop_niters ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+			   "=== get_loop_niters ===");
 
   if (!exit)
     return cond;
@@ -1470,9 +1521,9 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 			  tree *assumptions, tree *number_of_iterationsm1,
 			  tree *number_of_iterations, gcond **inner_loop_cond)
 {
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_analyze_loop_form ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+			   "=== vect_analyze_loop_form ===");
 
   /* Different restrictions apply when we are considering an inner-most loop,
      vs. an outer (nested) loop.
@@ -1494,17 +1545,17 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 
       if (loop->num_nodes != 2)
         {
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: control flow in loop.\n");
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: control flow in loop");
           return false;
         }
 
       if (empty_block_p (loop->header))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: empty loop.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: empty loop");
 	  return false;
 	}
     }
@@ -1532,17 +1583,17 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 
       if ((loop->inner)->inner || (loop->inner)->next)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: multiple nested loops.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: multiple nested loops");
 	  return false;
 	}
 
       if (loop->num_nodes != 5)
         {
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: control flow in loop.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: control flow in loop");
 	  return false;
         }
 
@@ -1551,9 +1602,9 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 	  || !single_exit (innerloop)
 	  || single_exit (innerloop)->dest != EDGE_PRED (loop->latch, 0)->src)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: unsupported outerloop form.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: unsupported outerloop form");
 	  return false;
 	}
 
@@ -1566,37 +1617,37 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 	     loop.  */
 	  || !integer_onep (inner_assumptions))
 	{
-	  if (dump_enabled_p ())
-            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: Bad inner loop.\n");
+	  if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: bad inner loop");
 	  return false;
 	}
 
       if (!expr_invariant_in_loop_p (loop, inner_niter))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: inner-loop count not"
-                             " invariant.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: inner-loop count not"
+				   " invariant");
 	  return false;
 	}
 
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-			 "Considering outer-loop vectorization.\n");
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK,
+			       "Considering outer-loop vectorization");
     }
 
   if (!single_exit (loop)
       || EDGE_COUNT (loop->header->preds) != 2)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
           if (!single_exit (loop))
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: multiple exits.\n");
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+			     "not vectorized: multiple exits");
           else if (EDGE_COUNT (loop->header->preds) != 2)
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: too many incoming edges.\n");
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: too many incoming edges");
         }
       return false;
     }
@@ -1608,9 +1659,9 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
   if (!empty_block_p (loop->latch)
       || !gimple_seq_empty_p (phi_nodes (loop->latch)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: latch block not empty.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: latch block not empty");
       return false;
     }
 
@@ -1618,9 +1669,9 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
   edge e = single_exit (loop);
   if (e->flags & EDGE_ABNORMAL)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: abnormal loop exit edge.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: abnormal loop exit edge");
       return false;
     }
 
@@ -1628,9 +1679,9 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
 				     number_of_iterationsm1);
   if (!*loop_cond)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: complicated exit condition.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: complicated exit condition");
       return false;
     }
 
@@ -1638,18 +1689,18 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond,
       || !*number_of_iterations
       || chrec_contains_undetermined (*number_of_iterations))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: number of iterations cannot be "
-			 "computed.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: number of iterations cannot be "
+			       "computed");
       return false;
     }
 
   if (integer_zerop (*number_of_iterations))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: number of iterations = 0.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: number of iterations = 0");
       return false;
     }
 
@@ -1689,9 +1740,9 @@ vect_analyze_loop_form (struct loop *loop)
 
   if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_NOTE, vect_location,
+          vect_location_writeln (OPT_RECORD_REMARK,
 			   "Symbolic number of iterations is ");
 	  dump_generic_expr (MSG_NOTE, TDF_DETAILS, number_of_iterations);
           dump_printf (MSG_NOTE, "\n");
@@ -1722,9 +1773,9 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo)
   poly_uint64 vectorization_factor;
   int i;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_update_vf_for_slp ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+			   "=== vect_update_vf_for_slp ===");
 
   vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
   gcc_assert (known_ne (vectorization_factor, 0U));
@@ -1759,14 +1810,14 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo)
 
   if (only_slp_in_loop)
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-		       "Loop contains only SLP stmts\n");
+      vect_location_writeln (OPT_RECORD_REMARK,
+			     "Loop contains only SLP stmts");
       vectorization_factor = LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo);
     }
   else
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-		       "Loop contains SLP and non-SLP stmts\n");
+      vect_location_writeln (OPT_RECORD_REMARK,
+			     "Loop contains SLP and non-SLP stmts");
       /* Both the vectorization factor and unroll factor have the form
 	 current_vector_size * X for some rational X, so they must have
 	 a common multiple.  */
@@ -1776,9 +1827,9 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo)
     }
 
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "Updating vectorization factor to ");
       dump_dec (MSG_NOTE, vectorization_factor);
       dump_printf (MSG_NOTE, ".\n");
@@ -1827,9 +1878,9 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
   bool need_to_vectorize = false;
   bool ok;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "=== vect_analyze_loop_operations ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+			   "=== vect_analyze_loop_operations ===");
 
   for (i = 0; i < nbbs; i++)
     {
@@ -1842,9 +1893,9 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
           ok = true;
 
           stmt_info = vinfo_for_stmt (phi);
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_NOTE, vect_location, "examining phi: ");
+              vect_location_writeln (OPT_RECORD_REMARK, "examining phi: ");
               dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
             }
 	  if (virtual_operand_p (gimple_phi_result (phi)))
@@ -1861,10 +1912,10 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
               if (STMT_VINFO_LIVE_P (stmt_info)
 		  && !vect_active_double_reduction_p (stmt_info))
                 {
-                  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				     "Unsupported loop-closed phi in "
-				     "outer-loop.\n");
+                  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_FAILURE,
+					   "Unsupported loop-closed phi in "
+					   "outer-loop");
                   return false;
                 }
 
@@ -1905,9 +1956,9 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
               && STMT_VINFO_DEF_TYPE (stmt_info) != vect_induction_def)
             {
               /* A scalar-dependence cycle that we don't support.  */
-              if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "not vectorized: scalar dependence cycle.\n");
+              if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
+				       "not vectorized: scalar dependence cycle");
               return false;
             }
 
@@ -1931,9 +1982,9 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
 
           if (!ok)
             {
-              if (dump_enabled_p ())
+              if (thing_enabled_p ())
                 {
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "not vectorized: relevant phi not "
 				   "supported: ");
                   dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, phi, 0);
@@ -1959,13 +2010,13 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
      touching this loop.  */
   if (!need_to_vectorize)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-			 "All the computation can be taken out of the loop.\n");
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: redundant loop. no profit to "
-			 "vectorize.\n");
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK,
+			       "All the computation can be taken out of the loop");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: redundant loop. no profit to "
+			       "vectorize");
       return false;
     }
 
@@ -1996,10 +2047,10 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo)
       if (max_niter != -1
 	  && (unsigned HOST_WIDE_INT) max_niter < assumed_vf)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: iteration count smaller than "
-			     "vectorization factor.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
+				   "not vectorized: iteration count smaller than "
+				   "vectorization factor");
 	  return 0;
 	}
     }
@@ -2010,13 +2061,13 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo)
 
   if (min_profitable_iters < 0)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: vectorization not profitable.\n");
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: vector version will never be "
-			 "profitable.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: vectorization not profitable");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: vector version will never be "
+			       "profitable");
       return -1;
     }
 
@@ -2033,14 +2084,14 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo)
   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
       && LOOP_VINFO_INT_NITERS (loop_vinfo) < th)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: vectorization not profitable.\n");
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-			 "not vectorized: iteration count smaller than user "
-			 "specified loop bound parameter or minimum profitable "
-			 "iterations (whichever is more conservative).\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: vectorization not profitable");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
+			       "not vectorized: iteration count smaller than user "
+			       "specified loop bound parameter or minimum profitable "
+			       "iterations (whichever is more conservative)");
       return 0;
     }
 
@@ -2051,16 +2102,16 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo)
       && ((unsigned HOST_WIDE_INT) estimated_niter
 	  < MAX (th, (unsigned) min_profitable_estimate)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: estimated iteration count too "
-			 "small.\n");
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
-			 "not vectorized: estimated iteration count smaller "
-			 "than specified loop bound parameter or minimum "
-			 "profitable iterations (whichever is more "
-			 "conservative).\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: estimated iteration count too "
+			       "small");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
+			       "not vectorized: estimated iteration count smaller "
+			       "than specified loop bound parameter or minimum "
+			       "profitable iterations (whichever is more "
+			       "conservative)");
       return -1;
     }
 
@@ -2093,11 +2144,11 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
   loop_p loop = LOOP_VINFO_LOOP (loop_vinfo);
   if (!find_loop_nest (loop, &LOOP_VINFO_LOOP_NEST (loop_vinfo)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "not vectorized: loop nest containing two "
-			 "or more consecutive inner loops cannot be "
-			 "vectorized\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "not vectorized: loop nest containing two "
+			       "or more consecutive inner loops cannot be "
+			       "vectorized");
       return false;
     }
 
@@ -2142,11 +2193,11 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
 		      }
 		  }
 	      }
-	    if (dump_enabled_p ())
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			       "not vectorized: loop contains function "
-			       "calls or data references that cannot "
-			       "be analyzed\n");
+	    if (thing_enabled_p ())
+	      vect_location_writeln (OPT_RECORD_FAILURE,
+				     "not vectorized: loop contains function "
+				     "calls or data references that cannot "
+				     "be analyzed");
 	    return false;
 	  }
       }
@@ -2157,9 +2208,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
   ok = vect_analyze_data_refs (loop_vinfo, &min_vf);
   if (!ok)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "bad data references.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "bad data references");
       return false;
     }
 
@@ -2177,9 +2228,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
   ok = vect_analyze_data_ref_accesses (loop_vinfo);
   if (!ok)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "bad data access.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "bad data access");
       return false;
     }
 
@@ -2188,9 +2239,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
   ok = vect_mark_stmts_to_be_vectorized (loop_vinfo);
   if (!ok)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "unexpected pattern.\n");
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
+			       "unexpected pattern");
       return false;
     }
 
@@ -2207,8 +2258,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
       || (max_vf != MAX_VECTORIZATION_FACTOR
 	  && maybe_lt (max_vf, min_vf)))
     {
-      if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "bad data dependence.\n");
       return false;
     }
@@ -2217,16 +2268,16 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
   ok = vect_determine_vectorization_factor (loop_vinfo);
   if (!ok)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "can't determine vectorization factor.\n");
       return false;
     }
   if (max_vf != MAX_VECTORIZATION_FACTOR
       && maybe_lt (max_vf, LOOP_VINFO_VECT_FACTOR (loop_vinfo)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "bad data dependence.\n");
       return false;
     }
@@ -2266,9 +2317,9 @@ start_over:
   poly_uint64 vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
   gcc_assert (known_ne (vectorization_factor, 0U));
 
-  if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) && dump_enabled_p ())
+  if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) && thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "vectorization_factor = ");
       dump_dec (MSG_NOTE, vectorization_factor);
       dump_printf (MSG_NOTE, ", niters = " HOST_WIDE_INT_PRINT_DEC "\n",
@@ -2284,8 +2335,8 @@ start_over:
   ok = vect_analyze_data_refs_alignment (loop_vinfo);
   if (!ok)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "bad data alignment.\n");
       return false;
     }
@@ -2306,8 +2357,8 @@ start_over:
     ok = vect_enhance_data_refs_alignment (loop_vinfo);
     if (!ok)
       {
-	if (dump_enabled_p ())
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	if (thing_enabled_p ())
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "bad data alignment.\n");
         return false;
       }
@@ -2329,8 +2380,8 @@ start_over:
   ok = vect_analyze_loop_operations (loop_vinfo);
   if (!ok)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "bad operation or unsupported loop bound.\n");
       return false;
     }
@@ -2340,13 +2391,13 @@ start_over:
   LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)
     = (LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo)
        && vect_verify_full_masking (loop_vinfo));
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
-	dump_printf_loc (MSG_NOTE, vect_location,
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "using a fully-masked loop.\n");
       else
-	dump_printf_loc (MSG_NOTE, vect_location,
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "not using a fully-masked loop.\n");
     }
 
@@ -2362,8 +2413,8 @@ start_over:
 
       if (known_lt (wi::to_widest (scalar_niters), vf))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "loop has no enough iterations to support"
 			     " peeling for gaps.\n");
 	  return false;
@@ -2376,8 +2427,8 @@ start_over:
     goto again;
   if (!res)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "Loop costings not worthwhile.\n");
       return false;
     }
@@ -2414,15 +2465,15 @@ start_over:
   if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
       || LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location, "epilog loop required\n");
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK, "epilog loop required\n");
       if (!vect_can_advance_ivs_p (loop_vinfo)
 	  || !slpeel_can_duplicate_loop_p (LOOP_VINFO_LOOP (loop_vinfo),
 					   single_exit (LOOP_VINFO_LOOP
 							 (loop_vinfo))))
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "not vectorized: can't create required "
 			     "epilog loop\n");
           goto again;
@@ -2509,8 +2560,8 @@ again:
 	}
     }
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "re-trying with SLP disabled\n");
 
   /* Roll back state appropriately.  No SLP this time.  */
@@ -2587,16 +2638,16 @@ vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo)
   targetm.vectorize.autovectorize_vector_sizes (&vector_sizes);
   unsigned int next_size = 0;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "===== analyze_loop_nest =====\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
+			   "===== analyze_loop_nest =====");
 
   if (loop_outer (loop)
       && loop_vec_info_for_loop (loop_outer (loop))
       && LOOP_VINFO_VECTORIZABLE_P (loop_vec_info_for_loop (loop_outer (loop))))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "outer-loop already vectorized.\n");
       return NULL;
     }
@@ -2608,8 +2659,8 @@ vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo)
       loop_vinfo = vect_analyze_loop_form (loop);
       if (!loop_vinfo)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "bad loop form.\n");
 	  return NULL;
 	}
@@ -2642,9 +2693,9 @@ vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo)
 
       /* Try the next biggest vector size.  */
       current_vector_size = vector_sizes[next_size++];
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "***** Re-trying analysis with "
 			   "vector size ");
 	  dump_dec (MSG_NOTE, current_vector_size);
@@ -2945,9 +2996,9 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple *phi,
                                   == vect_internal_def
                       && !is_loop_header_bb_p (gimple_bb (def_stmt)))))
   	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location, "swapping oprnds: ");
+		  vect_location_writeln (OPT_RECORD_REMARK, "swapping oprnds: ");
 		  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, next_stmt, 0);
 		}
 
@@ -3201,8 +3252,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 
       if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "intermediate value used outside loop.\n");
 
           return NULL;
@@ -3211,8 +3262,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       nloop_uses++;
       if (nloop_uses > 1)
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "reduction value used in loop.\n");
           return NULL;
         }
@@ -3224,9 +3275,9 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
   tree loop_arg = PHI_ARG_DEF_FROM_EDGE (phi, latch_e);
   if (TREE_CODE (loop_arg) != SSA_NAME)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "reduction: not ssa_name: ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, loop_arg);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -3247,9 +3298,9 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
     }
   else
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "reduction: unhandled reduction operation: ");
 	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, def_stmt, 0);
 	}
@@ -3273,8 +3324,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 	lcphis.safe_push (as_a <gphi *> (use_stmt));
       if (nloop_uses > 1)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "reduction used in loop.\n");
 	  return NULL;
 	}
@@ -3289,8 +3340,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       if (gimple_phi_num_args (def_stmt) != 1
           || TREE_CODE (op1) != SSA_NAME)
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported phi node definition.\n");
 
           return NULL;
@@ -3304,7 +3355,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
           && is_gimple_assign (def1)
 	  && flow_bb_inside_loop_p (loop->inner, gimple_bb (phi_use_stmt)))
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             report_vect_op (MSG_NOTE, def_stmt,
 			    "detected double reduction: ");
 
@@ -3358,7 +3409,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
         }
       if (op3 == phi_name || op4 == phi_name)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
 			    "reduction: condition depends on previous"
 			    " iteration: ");
@@ -3370,7 +3421,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
     }
   else if (!commutative_tree_code (code) || !associative_tree_code (code))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
 			"reduction: not commutative/associative: ");
       return NULL;
@@ -3382,7 +3433,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
     }
   else
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
 			"reduction: not handled operation: ");
       return NULL;
@@ -3390,7 +3441,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 
   if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
 			"reduction: both uses not ssa_names: ");
 
@@ -3407,9 +3458,9 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       || (op4 && TREE_CODE (op4) == SSA_NAME
           && !types_compatible_p (type, TREE_TYPE (op4))))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_NOTE, vect_location,
+          vect_location_writeln (OPT_RECORD_REMARK,
 			   "reduction: multiple types: operation type: ");
           dump_generic_expr (MSG_NOTE, TDF_SLIM, type);
           dump_printf (MSG_NOTE, ", operands types: ");
@@ -3463,7 +3514,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
   if (code != COND_EXPR
       && ((!def1 || gimple_nop_p (def1)) && (!def2 || gimple_nop_p (def2))))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	report_vect_op (MSG_NOTE, def_stmt, "reduction: no defs for operands: ");
       return NULL;
     }
@@ -3486,7 +3537,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
                           == vect_internal_def
  	              && !is_loop_header_bb_p (gimple_bb (def1)))))))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	report_vect_op (MSG_NOTE, def_stmt, "detected reduction: ");
       return def_stmt;
     }
@@ -3531,7 +3582,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 		}
 	      else
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    report_vect_op (MSG_NOTE, def_stmt,
 				    "detected reduction: cannot swap operands "
 				    "for cond_expr");
@@ -3542,7 +3593,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 	    swap_ssa_operands (def_stmt, gimple_assign_rhs1_ptr (def_stmt),
 			       gimple_assign_rhs2_ptr (def_stmt));
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    report_vect_op (MSG_NOTE, def_stmt,
 			    "detected reduction: need to swap operands: ");
 
@@ -3551,7 +3602,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
         }
       else
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             report_vect_op (MSG_NOTE, def_stmt, "detected reduction: ");
         }
 
@@ -3564,7 +3615,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       && orig_code != MINUS_EXPR
       && vect_is_slp_reduction (loop_info, phi, def_stmt))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         report_vect_op (MSG_NOTE, def_stmt,
 			"reduction: detected reduction chain: ");
 
@@ -3586,7 +3637,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 			    code))
     return def_stmt;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
 		      "reduction: unknown pattern: ");
@@ -3634,8 +3685,8 @@ vect_get_known_peeling_cost (loop_vec_info loop_vinfo, int peel_iters_prologue,
   if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
       *peel_iters_epilogue = assumed_vf / 2;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK,
 			 "cost model: epilogue peel iters set to vf/2 "
 			 "because loop iterations are unknown .\n");
 
@@ -3720,7 +3771,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
   /* Cost model disabled.  */
   if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo)))
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "cost model disabled.\n");
+      vect_location_writeln (OPT_RECORD_REMARK, "cost model disabled.\n");
       *ret_min_profitable_niters = 0;
       *ret_min_profitable_estimate = 0;
       return;
@@ -3980,9 +4031,9 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
 
   vec_outside_cost = (int)(vec_prologue_cost + vec_epilogue_cost);
   
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "Cost model analysis: \n");
+      vect_location_writeln (OPT_RECORD_REMARK, "Cost model analysis: \n");
       dump_printf (MSG_NOTE, "  Vector inside of loop cost: %d\n",
                    vec_inside_cost);
       dump_printf (MSG_NOTE, "  Vector prologue cost: %d\n",
@@ -4038,8 +4089,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
 	warning_at (vect_location, OPT_Wopenmp_simd, "vectorization "
 		    "did not happen for a simd loop");
 
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
 			 "cost model: the vector iteration cost = %d "
 			 "divided by the scalar iteration cost = %d "
 			 "is greater or equal to the vectorization factor = %d"
@@ -4059,8 +4110,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
     /* We want the vectorized loop to execute at least once.  */
     min_profitable_iters = assumed_vf + peel_iters_prologue;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "  Runtime profitability threshold = %d\n",
                      min_profitable_iters);
 
@@ -4085,8 +4136,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
 				   - vec_inside_cost);
     }
   min_profitable_estimate = MAX (min_profitable_estimate, min_profitable_iters);
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "  Static estimate profitability threshold = %d\n",
 		     min_profitable_estimate);
 
@@ -4307,7 +4358,7 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, internal_fn reduc_fn,
 	}
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf (MSG_NOTE, 
                  "vect_model_reduction_cost: inside_cost = %d, "
                  "prologue_cost = %d, epilogue_cost = %d .\n", inside_cost,
@@ -4337,8 +4388,8 @@ vect_model_induction_cost (stmt_vec_info stmt_info, int ncopies)
   prologue_cost = add_stmt_cost (target_cost_data, 2, scalar_to_vec,
 				 stmt_info, 0, vect_prologue);
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
                      "vect_model_induction_cost: inside_cost = %d, "
                      "prologue_cost = %d .\n", inside_cost, prologue_cost);
 }
@@ -4930,9 +4981,9 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
           add_phi_arg (as_a <gphi *> (phi), def, loop_latch_edge (loop),
 		       UNKNOWN_LOCATION);
 
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_NOTE, vect_location,
+              vect_location_writeln (OPT_RECORD_REMARK,
 			       "transform reduction: created def-use cycle: ");
               dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
               dump_gimple_stmt (MSG_NOTE, TDF_SLIM, SSA_NAME_DEF_STMT (def), 0);
@@ -5419,8 +5470,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
       /* Case 1:  Create:
          v_out2 = reduc_expr <v_out1>  */
 
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK,
 			 "Reduce using direct vector reduction.\n");
 
       vec_elem_type = TREE_TYPE (TREE_TYPE (new_phi_result));
@@ -5690,8 +5741,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
 
           tree rhs;
 
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_NOTE, vect_location,
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_REMARK,
 			     "Reduce using vector shifts\n");
 
 	  mode1 = TYPE_MODE (vectype1);
@@ -5719,8 +5770,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
 	  /* 2.4  Extract the final scalar result.  Create:
 	     s_out3 = extract_field <v_out2, bitpos>  */
 
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "extract scalar result\n");
 
 	  rhs = build3 (BIT_FIELD_REF, scalar_type, new_temp,
@@ -5743,8 +5794,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
                  Create:  s = op <s, s'>  // For non SLP cases
                }  */
 
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_NOTE, vect_location,
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_REMARK,
 			     "Reduce using scalar code.\n");
 
 	  int vec_size_in_bits = tree_to_uhwi (TYPE_SIZE (vectype1));
@@ -6066,9 +6117,9 @@ vect_finalize_reduction:
                                UNKNOWN_LOCATION);
                   add_phi_arg (vect_phi, PHI_RESULT (inner_phi),
                                loop_latch_edge (outer_loop), UNKNOWN_LOCATION);
-                  if (dump_enabled_p ())
+                  if (thing_enabled_p ())
                     {
-                      dump_printf_loc (MSG_NOTE, vect_location,
+                      vect_location_writeln (OPT_RECORD_REMARK,
 				       "created double reduction phi node: ");
                       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, vect_phi, 0);
                     }
@@ -6749,8 +6800,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (STMT_VINFO_REDUC_TYPE (stmt_info) == FOLD_LEFT_REDUCTION)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "in-order reduction chain without SLP.\n");
 	  return false;
 	}
@@ -6803,8 +6854,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	 as a reduction operation.  */
       if (reduc_index == -1)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "conditional reduction chains not supported\n");
 	  return false;
 	}
@@ -6828,8 +6879,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       else if (direct_internal_fn_supported_p (IFN_FOLD_EXTRACT_LAST,
 					       vectype_in, OPTIMIZE_FOR_SPEED))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "optimizing condition reduction with"
 			     " FOLD_EXTRACT_LAST.\n");
 	  STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = EXTRACT_LAST_REDUCTION;
@@ -6869,8 +6920,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	    }
 	  if (cond_reduc_val)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_NOTE, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_REMARK,
 				 "condition expression based on "
 				 "integer induction.\n");
 	      STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info)
@@ -6895,8 +6946,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 				    cond_initial_val, cond_reduc_val);
 	      if (e && (integer_onep (e) || integer_zerop (e)))
 		{
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_NOTE, vect_location,
+		  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_REMARK,
 				     "condition expression based on "
 				     "compile time constant.\n");
 		  /* Record reduction code at analysis stage.  */
@@ -6938,8 +6989,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!vec_stmt && !vectorizable_condition (stmt, gsi, NULL,
 						ops[reduc_index], 0, NULL))
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported condition in reduction\n");
 	  return false;
         }
@@ -6953,8 +7004,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	{
 	  /* Shifts and rotates are only supported by vectorizable_shifts,
 	     not vectorizable_reduction.  */
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported shift or rotation.\n");
 	  return false;
 	}
@@ -6963,8 +7014,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       optab = optab_for_tree_code (code, vectype_in, optab_default);
       if (!optab)
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "no optab.\n");
 
           return false;
@@ -6972,14 +7023,14 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 
       if (optab_handler (optab, vec_mode) == CODE_FOR_nothing)
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             dump_printf (MSG_NOTE, "op not supported by target.\n");
 
 	  if (maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD)
 	      || !vect_worthwhile_without_simd_p (loop_vinfo, code))
             return false;
 
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
   	    dump_printf (MSG_NOTE, "proceeding using word mode.\n");
         }
 
@@ -6987,8 +7038,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!VECTOR_MODE_P (TYPE_MODE (vectype_in))
 	  && !vect_worthwhile_without_simd_p (loop_vinfo, code))
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "not worthwhile without SIMD support.\n");
 
           return false;
@@ -7093,8 +7144,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	      && !direct_internal_fn_supported_p (reduc_fn, vectype_out,
 						  OPTIMIZE_FOR_SPEED))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "reduc op not supported by target.\n");
 
 	      reduc_fn = IFN_LAST;
@@ -7104,8 +7155,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	{
 	  if (!nested_cycle || double_reduc)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "no reduc code for scalar code.\n");
 
 	      return false;
@@ -7129,8 +7180,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       && reduc_fn == IFN_LAST
       && !nunits_out.is_constant ())
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "missing target support for reduction on"
 			 " variable-length vectors.\n");
       return false;
@@ -7139,8 +7190,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
   if ((double_reduc || reduction_type != TREE_CODE_REDUCTION)
       && ncopies > 1)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "multiple types in double reduction or condition "
 			 "reduction.\n");
       return false;
@@ -7169,8 +7220,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 		 l += a[j];
 
 	 which is a reassociation of the original operation.  */
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "in-order double reduction not supported.\n");
 
       return false;
@@ -7182,8 +7233,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       /* We cannot use in-order reductions in this case because there is
 	 an implicit reassociation of the operations involved.  */
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "in-order unchained SLP reductions not supported.\n");
       return false;
     }
@@ -7197,8 +7248,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       && !direct_internal_fn_supported_p (IFN_VEC_SHL_INSERT,
 					  vectype_out, OPTIMIZE_FOR_SPEED))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "reduction on variable-length vectors requires"
 			 " target support for a vector-shift-and-insert"
 			 " operation.\n");
@@ -7220,8 +7271,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!neutral_op
 	  && !can_duplicate_and_interleave_p (group_size, elt_mode))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported form of SLP reduction for"
 			     " variable-length vectors: cannot build"
 			     " initial vector.\n");
@@ -7232,8 +7283,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	 up the the initial vector does too.  */
       if (!multiple_p (nunits_out, group_size))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported form of SLP reduction for"
 			     " variable-length vectors: the vector size"
 			     " is not a multiple of the number of results.\n");
@@ -7253,8 +7304,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
         ops[1] = fold_convert (TREE_TYPE (ops[0]), ops[1]);
       else
         {
-          if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "invalid types in dot-prod\n");
 
           return false;
@@ -7267,8 +7318,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 
       if (! max_loop_iterations (loop, &ni))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "loop count not known, cannot create cond "
 			     "reduction.\n");
 	  return false;
@@ -7282,8 +7333,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       tree max_index = TYPE_MAX_VALUE (cr_index_scalar_type);
       if (wi::geu_p (ni, wi::to_widest (max_index)))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "loop size is greater than data size.\n");
 	  return false;
 	}
@@ -7340,8 +7391,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	  || code == WIDEN_SUM_EXPR
 	  || code == SAD_EXPR))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "multi def-use cycle not possible for lane-reducing "
 			 "reduction operation\n");
       return false;
@@ -7366,16 +7417,16 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 		  || !direct_internal_fn_supported_p (cond_fn, vectype_in,
 						      OPTIMIZE_FOR_SPEED)))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "can't use a fully-masked loop because no"
 				 " conditional operation is available.\n");
 	      LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
 	    }
 	  else if (reduc_index == -1)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "can't use a fully-masked loop for chained"
 				 " reductions.\n");
 	      LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
@@ -7384,9 +7435,9 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 	    vect_record_loop_mask (loop_vinfo, masks, ncopies * vec_num,
 				   vectype_in);
 	}
-      if (dump_enabled_p ()
+      if (thing_enabled_p ()
 	  && reduction_type == FOLD_LEFT_REDUCTION)
-	dump_printf_loc (MSG_NOTE, vect_location,
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "using an in-order (fold-left) reduction.\n");
       STMT_VINFO_TYPE (stmt_info) = reduc_vec_info_type;
       return true;
@@ -7394,8 +7445,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
 
   /* Transform.  */
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "transform reduction.\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "transform reduction.\n");
 
   /* FORNOW: Multiple types are not supported for condition.  */
   if (code == COND_EXPR)
@@ -7689,8 +7740,8 @@ vectorizable_induction (gimple *phi,
 
       if (ncopies > 1)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "multiple types in nested loop.\n");
 	  return false;
 	}
@@ -7720,8 +7771,8 @@ vectorizable_induction (gimple *phi,
 	  if (!(STMT_VINFO_RELEVANT_P (exit_phi_vinfo)
 		&& !STMT_VINFO_LIVE_P (exit_phi_vinfo)))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "inner-loop induction only used outside "
 				 "of the outer vectorized loop.\n");
 	      return false;
@@ -7738,8 +7789,8 @@ vectorizable_induction (gimple *phi,
   if (slp_node && !nunits.is_constant ())
     {
       /* The current SLP code creates the initial value element-by-element.  */
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "SLP induction not supported for variable-length"
 			 " vectors.\n");
       return false;
@@ -7748,8 +7799,8 @@ vectorizable_induction (gimple *phi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = induc_vec_info_type;
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_REMARK,
                          "=== vectorizable_induction ===\n");
       vect_model_induction_cost (stmt_info, ncopies);
       return true;
@@ -7762,8 +7813,8 @@ vectorizable_induction (gimple *phi,
      evolution S, for a vector of 4 units, we want to compute:
      [X, X + S, X + 2*S, X + 3*S].  */
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "transform induction phi.\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "transform induction phi.\n");
 
   latch_e = loop_latch_edge (iv_loop);
   loop_arg = PHI_ARG_DEF_FROM_EDGE (phi, latch_e);
@@ -8154,9 +8205,9 @@ vectorizable_induction (gimple *phi,
 		      && !STMT_VINFO_LIVE_P (stmt_vinfo));
 
 	  STMT_VINFO_VEC_STMT (stmt_vinfo) = new_stmt;
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "vector of inductions after inner-loop:");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, new_stmt, 0);
 	    }
@@ -8164,9 +8215,9 @@ vectorizable_induction (gimple *phi,
     }
 
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "transform induction: created def-use cycle: ");
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, induction_phi, 0);
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
@@ -8215,8 +8266,8 @@ vectorizable_live_operation (gimple *stmt,
   if (!STMT_VINFO_RELEVANT_P (stmt_info))
     {
       gcc_assert (is_simple_and_all_uses_invariant (stmt, loop_vinfo));
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "statement is simple and uses invariant.  Leaving in "
 			 "place.\n");
       return true;
@@ -8243,8 +8294,8 @@ vectorizable_live_operation (gimple *stmt,
 	 that vector we need.  */
       if (!can_div_trunc_p (pos, nunits, &vec_entry, &vec_index))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "Cannot determine which vector holds the"
 			     " final result.\n");
 	  return false;
@@ -8259,8 +8310,8 @@ vectorizable_live_operation (gimple *stmt,
 	  if (!direct_internal_fn_supported_p (IFN_EXTRACT_LAST, vectype,
 					       OPTIMIZE_FOR_SPEED))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "can't use a fully-masked loop because "
 				 "the target doesn't support extract last "
 				 "reduction.\n");
@@ -8268,16 +8319,16 @@ vectorizable_live_operation (gimple *stmt,
 	    }
 	  else if (slp_node)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "can't use a fully-masked loop because an "
 				 "SLP statement is live after the loop.\n");
 	      LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
 	    }
 	  else if (ncopies > 1)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "can't use a fully-masked loop because"
 				 " ncopies is greater than 1.\n");
 	      LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
@@ -8424,8 +8475,8 @@ vect_loop_kill_debug_uses (struct loop *loop, gimple *stmt)
 	    {
 	      if (gimple_debug_bind_p (ustmt))
 		{
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_NOTE, vect_location,
+		  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_REMARK,
                                      "killing debug use\n");
 
 		  gimple_debug_bind_reset_value (ustmt);
@@ -8625,8 +8676,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   bool check_profitability = false;
   unsigned int th;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vec_transform_loop ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "=== vec_transform_loop ===\n");
 
   /* Use the more conservative vectorization threshold.  If the number
      of iterations is constant assume the cost check has been performed
@@ -8637,8 +8688,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   if (th >= vect_vf_for_cost (loop_vinfo)
       && !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "Profitability threshold is %d loop iterations.\n",
                          th);
       check_profitability = true;
@@ -8650,7 +8701,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   if (! single_pred_p (e->dest))
     {
       split_loop_exit_edge (e);
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf (MSG_NOTE, "split exit edge\n");
     }
 
@@ -8684,7 +8735,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
       if (! single_pred_p (e->dest))
 	{
 	  split_loop_exit_edge (e);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    dump_printf (MSG_NOTE, "split exit edge of scalar loop\n");
 	}
     }
@@ -8739,9 +8790,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	   gsi_next (&si))
         {
 	  gphi *phi = si.phi ();
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
                                "------>vectorizing phi: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	    }
@@ -8759,16 +8810,16 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	  if (STMT_VINFO_VECTYPE (stmt_info)
 	      && (maybe_ne
 		  (TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info)), vf))
-	      && dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location, "multiple-types.\n");
+	      && thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK, "multiple-types.\n");
 
 	  if ((STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def
 	       || STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
 	       || STMT_VINFO_DEF_TYPE (stmt_info) == vect_nested_cycle)
 	      && ! PURE_SLP_STMT (stmt_info))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_NOTE, vect_location, "transform phi.\n");
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_REMARK, "transform phi.\n");
 	      vect_transform_stmt (phi, NULL, NULL, NULL, NULL);
 	    }
 	}
@@ -8794,9 +8845,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		}
 	    }
 
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "------>vectorizing statement: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	    }
@@ -8866,9 +8917,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 
 		  if (!gsi_end_p (pattern_def_si))
 		    {
-		      if (dump_enabled_p ())
+		      if (thing_enabled_p ())
 			{
-			  dump_printf_loc (MSG_NOTE, vect_location,
+			  vect_location_writeln (OPT_RECORD_REMARK,
 					   "==> vectorizing pattern def "
 					   "stmt: ");
 			  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
@@ -8894,10 +8945,10 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		= TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info));
 	      if (!STMT_SLP_TYPE (stmt_info)
 		  && maybe_ne (nunits, vf)
-		  && dump_enabled_p ())
+		  && thing_enabled_p ())
 		  /* For SLP VF is set according to unrolling factor, and not
 		     to vector size, hence for SLP this print is not valid.  */
-		dump_printf_loc (MSG_NOTE, vect_location, "multiple-types.\n");
+		vect_location_writeln (OPT_RECORD_REMARK, "multiple-types.\n");
 	    }
 
 	  /* SLP. Schedule all the SLP instances when the first SLP stmt is
@@ -8908,8 +8959,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		{
 		  slp_scheduled = true;
 
-		  if (dump_enabled_p ())
-		    dump_printf_loc (MSG_NOTE, vect_location,
+		  if (thing_enabled_p ())
+		    vect_location_writeln (OPT_RECORD_REMARK,
 				     "=== scheduling SLP instances ===\n");
 
 		  vect_schedule_slp (loop_vinfo);
@@ -8928,8 +8979,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	    }
 
 	  /* -------- vectorize statement ------------ */
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location, "transform statement.\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK, "transform statement.\n");
 
 	  grouped_store = false;
 	  is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL, NULL);
@@ -9040,20 +9091,20 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	 : wi::udiv_floor (loop->nb_iterations_estimate + bias_for_assumed,
 			   assumed_vf) - 1);
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       if (!LOOP_VINFO_EPILOGUE_P (loop_vinfo))
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "LOOP VECTORIZED\n");
 	  if (loop->inner)
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "OUTER LOOP VECTORIZED\n");
 	  dump_printf (MSG_NOTE, "\n");
 	}
       else
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "LOOP EPILOGUE VECTORIZED (VS=");
 	  dump_dec (MSG_NOTE, current_vector_size);
 	  dump_printf (MSG_NOTE, ")\n");
@@ -9159,6 +9210,8 @@ optimize_mask_stores (struct loop *loop)
   auto_vec<gimple *> worklist;
 
   vect_location = find_loop_location (loop);
+  vect_location_thing = loop;
+
   /* Pick up all masked stores in loop if any.  */
   for (i = 0; i < nbbs; i++)
     {
@@ -9210,8 +9263,8 @@ optimize_mask_stores (struct loop *loop)
       make_single_succ_edge (store_bb, join_bb, EDGE_FALLTHRU);
       if (dom_info_available_p (CDI_DOMINATORS))
 	set_immediate_dominator (CDI_DOMINATORS, store_bb, bb);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
 			 "Create new block %d to sink mask stores.",
 			 store_bb->index);
       /* Create vector comparison with boolean result.  */
@@ -9249,9 +9302,9 @@ optimize_mask_stores (struct loop *loop)
 	  gsi_move_before (&gsi_from, &gsi_to);
 	  /* Setup GSI_TO to the non-empty block start.  */
 	  gsi_to = gsi_start_bb (store_bb);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "Move stmt to created bb\n");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, last, 0);
 	    }
@@ -9317,9 +9370,9 @@ optimize_mask_stores (struct loop *loop)
 		break;
 
 	      /* Can move STMT1 to STORE_BB.  */
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_NOTE, vect_location,
+		  vect_location_writeln (OPT_RECORD_REMARK,
 				   "Move stmt to created bb\n");
 		  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt1, 0);
 		}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 73aa227..99a8104 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "vec-perm-indices.h"
 #include "gimple-fold.h"
 #include "internal-fn.h"
+#include "optimization-records.h"
 
 
 /* Recursively free the memory allocated for the SLP tree rooted at NODE.  */
@@ -349,9 +350,9 @@ again:
 
       if (!vect_is_simple_use (oprnd, vinfo, &def_stmt, &dt))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "Build SLP failed: can't analyze def for ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
               dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -385,11 +386,11 @@ again:
 		  goto again;
 		}
 
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				   "Build SLP failed: some of the stmts"
-				   " are in a pattern, and others are not ");
+		  vect_location_writeln (OPT_RECORD_FAILURE,
+					 "Build SLP failed: some of the stmts"
+					 " are in a pattern, and others are not ");
 		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
                   dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
 		}
@@ -402,9 +403,9 @@ again:
 
           if (dt == vect_unknown_def_type)
             {
-              if (dump_enabled_p ())
-                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "Unsupported pattern.\n");
+              if (thing_enabled_p ())
+                vect_location_writeln (OPT_RECORD_FAILURE,
+				       "Unsupported pattern");
               return -1;
             }
 
@@ -415,8 +416,8 @@ again:
 	      break;
 
 	    default:
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "unsupported defining stmt:\n");
 	      return -1;
             }
@@ -457,8 +458,8 @@ again:
 		  goto again;
 		}
 
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "Build SLP failed: different types\n");
 
 	      return 1;
@@ -470,9 +471,9 @@ again:
 		  || !can_duplicate_and_interleave_p (stmts.length (),
 						      TYPE_MODE (type))))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "Build SLP failed: invalid type of def "
 				   "for variable-length SLP ");
 		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
@@ -497,9 +498,9 @@ again:
 
 	default:
 	  /* FORNOW: Not supported.  */
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "Build SLP failed: illegal type of def ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
               dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -516,9 +517,9 @@ again:
          we've committed to the operand order and can't swap it.  */
       if (STMT_VINFO_NUM_SLP_USES (vinfo_for_stmt (stmt)) != 0)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "Build SLP failed: cannot swap operands of "
 			       "shared stmt ");
 	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -552,9 +553,9 @@ again:
       else
 	swap_ssa_operands (stmt, gimple_assign_rhs1_ptr (stmt),
 			   gimple_assign_rhs2_ptr (stmt));
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "swapped operands to match def types in ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
@@ -577,9 +578,9 @@ vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
 {
   if (!vectype)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "Build SLP failed: unsupported data-type in ");
 	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -596,9 +597,9 @@ vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
       && (!nunits.is_constant (&const_nunits)
 	  || const_nunits > group_size))
     {
-      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-		       "Build SLP failed: unrolling required "
-		       "in basic block SLP\n");
+      vect_location_writeln (OPT_RECORD_FAILURE,
+			     "Build SLP failed: unrolling required "
+			     "in basic block SLP");
       /* Fatal mismatch.  */
       return false;
     }
@@ -650,18 +651,18 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
       swap[i] = 0;
       matches[i] = false;
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location, "Build SLP for ");
+	  vect_location_writeln (OPT_RECORD_REMARK, "Build SLP for ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
 
       /* Fail to vectorize statements marked as unvectorizable.  */
       if (!STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (stmt)))
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
-              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+              vect_location_writeln (OPT_RECORD_FAILURE,
 			       "Build SLP failed: unvectorizable statement ");
               dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }
@@ -673,9 +674,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
       lhs = gimple_get_lhs (stmt);
       if (lhs == NULL_TREE)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "Build SLP failed: not GIMPLE_ASSIGN nor "
 			       "GIMPLE_CALL ");
 	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -704,9 +705,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	      || !gimple_call_nothrow_p (call_stmt)
 	      || gimple_call_chain (call_stmt))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+		  vect_location_writeln (OPT_RECORD_FAILURE, 
 				   "Build SLP failed: unsupported call type ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				    call_stmt, 0);
@@ -745,8 +746,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 
 		  if (!optab)
 		    {
-		      if (dump_enabled_p ())
-			dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      if (thing_enabled_p ())
+			vect_location_writeln (OPT_RECORD_FAILURE,
 					 "Build SLP failed: no optab.\n");
 		      /* Fatal mismatch.  */
 		      matches[0] = false;
@@ -755,8 +756,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		  icode = (int) optab_handler (optab, vec_mode);
 		  if (icode == CODE_FOR_nothing)
 		    {
-		      if (dump_enabled_p ())
-			dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      if (thing_enabled_p ())
+			vect_location_writeln (OPT_RECORD_FAILURE,
 					 "Build SLP failed: "
 					 "op not supported by target.\n");
 		      /* Fatal mismatch.  */
@@ -801,13 +802,13 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
                        || first_stmt_code == COMPONENT_REF
                        || first_stmt_code == MEM_REF)))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+		  vect_location_writeln (OPT_RECORD_FAILURE, 
 				   "Build SLP failed: different operation "
 				   "in stmt ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "original stmt ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				    first_stmt, 0);
@@ -819,9 +820,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	  if (need_same_oprnds
 	      && !operand_equal_p (first_op1, gimple_assign_rhs2 (stmt), 0))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+		  vect_location_writeln (OPT_RECORD_FAILURE, 
 				   "Build SLP failed: different shift "
 				   "arguments in ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -839,9 +840,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		  || gimple_call_fntype (first_stmt)
 		     != gimple_call_fntype (stmt))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+		      vect_location_writeln (OPT_RECORD_FAILURE, 
 				       "Build SLP failed: different calls in ");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 					stmt, 0);
@@ -870,7 +871,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
                      chains in the same node.  */
                   if (prev_first_load != first_load)
                     {
-                      if (dump_enabled_p ())
+                      if (thing_enabled_p ())
                         {
                           dump_printf_loc (MSG_MISSED_OPTIMIZATION,
 					   vect_location, 
@@ -892,9 +893,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	  if (TREE_CODE_CLASS (rhs_code) == tcc_reference)
 	    {
 	      /* Not grouped load.  */
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+		  vect_location_writeln (OPT_RECORD_FAILURE, 
 				   "Build SLP failed: not grouped load ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}
@@ -912,9 +913,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	      && TREE_CODE_CLASS (rhs_code) != tcc_comparison
 	      && rhs_code != CALL_EXPR)
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "Build SLP failed: operation");
 		  dump_printf (MSG_MISSED_OPTIMIZATION, " unsupported ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -950,9 +951,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		swap[i] = 2;
 	      else
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		      vect_location_writeln (OPT_RECORD_FAILURE,
 				       "Build SLP failed: different"
 				       " operation");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
@@ -980,8 +981,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
       unsigned HOST_WIDE_INT count;
       if (!nunits.is_constant (&count))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "Build SLP failed: different operations "
 			     "not allowed with variable-length SLP.\n");
 	  return false;
@@ -1001,14 +1002,14 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    if (gimple_assign_rhs_code (stmts[i]) == alt_stmt_code)
 	      {
 		matches[i] = false;
-		if (dump_enabled_p ())
+		if (thing_enabled_p ())
 		  {
-		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		    vect_location_writeln (OPT_RECORD_FAILURE,
 				     "Build SLP failed: different operation "
 				     "in stmt ");
 		    dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				      stmts[i], 0);
-		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		    vect_location_writeln (OPT_RECORD_FAILURE,
 				     "original stmt ");
 		    dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				      first_stmt, 0);
@@ -1258,7 +1259,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 		    vect_free_slp_tree (grandchild);
 		  SLP_TREE_CHILDREN (child).truncate (0);
 
-		  dump_printf_loc (MSG_NOTE, vect_location,
+		  vect_location_writeln (OPT_RECORD_REMARK,
 				   "Building parent vector operands from "
 				   "scalars instead\n");
 		  oprnd_info->def_stmts = vNULL;
@@ -1288,7 +1289,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 	     scalar version.  */
 	  && !is_pattern_stmt_p (vinfo_for_stmt (stmt)))
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "Building vector operands from scalars\n");
 	  child = vect_create_new_slp_node (oprnd_info->def_stmts);
 	  SLP_TREE_DEF_TYPE (child) = vect_external_def;
@@ -1344,7 +1345,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 		    {
 		      if (!swap_not_matching)
 			{
-			  if (dump_enabled_p ())
+			  if (thing_enabled_p ())
 			    {
 			      dump_printf_loc (MSG_MISSED_OPTIMIZATION,
 					       vect_location,
@@ -1363,7 +1364,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 	  while (j != group_size);
 
 	  /* Swap mismatched definition stmts.  */
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "Re-trying with swapped operands of stmts ");
 	  for (j = 0; j < group_size; ++j)
 	    if (matches[j] == !swap_not_matching)
@@ -1438,7 +1439,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 			vect_free_slp_tree (grandchild);
 		      SLP_TREE_CHILDREN (child).truncate (0);
 
-		      dump_printf_loc (MSG_NOTE, vect_location,
+		      vect_location_writeln (OPT_RECORD_REMARK,
 				       "Building parent vector operands from "
 				       "scalars instead\n");
 		      oprnd_info->def_stmts = vNULL;
@@ -1656,9 +1657,9 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
   slp_tree node;
   gimple *stmt, *load, *next_load;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "Load permutation ");
+      vect_location_writeln (OPT_RECORD_REMARK, "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)
@@ -1733,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)))
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "BB vectorization with gaps at the end of "
 				   "a load is not supported\n");
 		  return false;
@@ -2114,8 +2115,8 @@ vect_split_slp_store_group (gimple *first_stmt, unsigned group1_size)
   /* GROUP_GAP of the first group now has to skip over the second group too.  */
   GROUP_GAP (first_vinfo) += group2_size;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "Split group into %d and %d\n",
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "Split group into %d and %d\n",
 		     group1_size, group2_size);
 
   return group2;
@@ -2172,9 +2173,9 @@ vect_analyze_slp_instance (vec_info *vinfo,
 
   if (!vectype)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          vect_location_writeln (OPT_RECORD_FAILURE,
 			   "Build SLP failed: unsupported data-type ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, scalar_type);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -2238,8 +2239,8 @@ vect_analyze_slp_instance (vec_info *vinfo,
 	  if (!max_nunits.is_constant (&const_max_nunits)
 	      || const_max_nunits > group_size)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "Build SLP failed: store group "
 				 "size not a multiple of the vector size "
 				 "in basic block SLP\n");
@@ -2301,9 +2302,9 @@ vect_analyze_slp_instance (vec_info *vinfo,
         {
           if (!vect_supported_load_permutation_p (new_instance))
             {
-              if (dump_enabled_p ())
+              if (thing_enabled_p ())
                 {
-                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "Build SLP failed: unsupported load "
 				   "permutation ");
 		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,
@@ -2336,8 +2337,8 @@ vect_analyze_slp_instance (vec_info *vinfo,
 	    }
 	  if (i == loads.length ())
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "Built SLP cancelled: can use "
 				 "load/store-lanes\n");
 	      vect_free_slp_instance (new_instance);
@@ -2347,9 +2348,9 @@ vect_analyze_slp_instance (vec_info *vinfo,
 
       vinfo->slp_instances.safe_push (new_instance);
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "Final SLP tree for instance:\n");
 	  vect_print_slp_tree (MSG_NOTE, vect_location, node);
 	}
@@ -2415,8 +2416,8 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size)
   unsigned int i;
   gimple *first_element;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_analyze_slp ===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "=== vect_analyze_slp ===\n");
 
   /* Find SLP sequences starting from groups of grouped stores.  */
   FOR_EACH_VEC_ELT (vinfo->grouped_stores, i, first_element)
@@ -2469,8 +2470,8 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   slp_instance instance;
   int decided_to_slp = 0;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_make_slp_decision ==="
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "=== vect_make_slp_decision ==="
                      "\n");
 
   FOR_EACH_VEC_ELT (slp_instances, i, instance)
@@ -2491,9 +2492,9 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
 
   LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo) = unrolling_factor;
 
-  if (decided_to_slp && dump_enabled_p ())
+  if (decided_to_slp && thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      vect_location_writeln (OPT_RECORD_REMARK,
 		       "Decided to SLP %d instances. Unrolling factor ",
 		       decided_to_slp);
       dump_dec (MSG_NOTE, unrolling_factor);
@@ -2553,9 +2554,9 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype)
 		&& !(gimple_code (use_stmt) == GIMPLE_PHI
 		     && STMT_VINFO_DEF_TYPE (use_vinfo) == vect_reduction_def))
 	      {
-		if (dump_enabled_p ())
+		if (thing_enabled_p ())
 		  {
-		    dump_printf_loc (MSG_NOTE, vect_location, "use of SLP "
+		    vect_location_writeln (OPT_RECORD_REMARK, "use of SLP "
 				     "def in non-SLP stmt: ");
 		    dump_gimple_stmt (MSG_NOTE, TDF_SLIM, use_stmt, 0);
 		  }
@@ -2567,9 +2568,9 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype)
   if (stype == hybrid
       && !HYBRID_SLP_STMT (stmt_vinfo))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location, "marking hybrid: ");
+	  vect_location_writeln (OPT_RECORD_REMARK, "marking hybrid: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}
       STMT_SLP_TYPE (stmt_vinfo) = hybrid;
@@ -2598,9 +2599,9 @@ vect_detect_hybrid_slp_1 (tree *tp, int *, void *data)
       if (flow_bb_inside_loop_p (loopp, gimple_bb (def_stmt))
 	  && PURE_SLP_STMT (vinfo_for_stmt (def_stmt)))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location, "marking hybrid: ");
+	      vect_location_writeln (OPT_RECORD_REMARK, "marking hybrid: ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
 	    }
 	  STMT_SLP_TYPE (vinfo_for_stmt (def_stmt)) = hybrid;
@@ -2637,8 +2638,8 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
   vec<slp_instance> slp_instances = LOOP_VINFO_SLP_INSTANCES (loop_vinfo);
   slp_instance instance;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_detect_hybrid_slp ==="
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "=== vect_detect_hybrid_slp ==="
                      "\n");
 
   /* First walk all pattern stmt in the loop and mark defs of uses as
@@ -2762,9 +2763,9 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
       gcc_assert (PURE_SLP_STMT (stmt_info));
 
       tree scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "get vectype for scalar type:  ");
 	  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
 	  dump_printf (MSG_NOTE, "\n");
@@ -2773,9 +2774,9 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
       tree vectype = get_vectype_for_scalar_type (scalar_type);
       if (!vectype)
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "not SLPed: unsupported data-type ");
 	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				 scalar_type);
@@ -2784,9 +2785,9 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
 	  return false;
 	}
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location, "vectype:  ");
+	  vect_location_writeln (OPT_RECORD_REMARK, "vectype:  ");
 	  dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
 	  dump_printf (MSG_NOTE, "\n");
 	}
@@ -2846,8 +2847,8 @@ vect_slp_analyze_operations (vec_info *vinfo)
   slp_instance instance;
   int i;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "=== vect_slp_analyze_operations ===\n");
 
   for (i = 0; vinfo->slp_instances.iterate (i, &instance); )
@@ -2856,7 +2857,7 @@ vect_slp_analyze_operations (vec_info *vinfo)
 					     SLP_INSTANCE_TREE (instance),
 					     instance))
         {
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "removing SLP instance operations starting from: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
 			    SLP_TREE_SCALAR_STMTS
@@ -2868,8 +2869,8 @@ vect_slp_analyze_operations (vec_info *vinfo)
 	i++;
     }
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "=== vect_analyze_slp_cost ===\n");
 
   /* Compute the costs of the SLP instances.  */
@@ -2994,9 +2995,9 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
 
   vec_outside_cost = vec_prologue_cost + vec_epilogue_cost;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "Cost model analysis: \n");
+      vect_location_writeln (OPT_RECORD_REMARK, "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);
@@ -3035,8 +3036,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
 
   if (n_stmts > PARAM_VALUE (PARAM_SLP_MAX_INSNS_IN_BB))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: too many instructions in "
 			 "basic block.\n");
       free_data_refs (datarefs);
@@ -3053,8 +3054,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
 
   if (!vect_analyze_data_refs (bb_vinfo, &min_vf))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: unhandled data-ref in basic "
 			 "block.\n");
 
@@ -3064,8 +3065,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
 
   if (BB_VINFO_DATAREFS (bb_vinfo).length () < 2)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: not enough data-refs in "
 			 "basic block.\n");
 
@@ -3075,8 +3076,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
 
   if (!vect_analyze_data_ref_accesses (bb_vinfo))
     {
-     if (dump_enabled_p ())
-       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+     if (thing_enabled_p ())
+       vect_location_writeln (OPT_RECORD_FAILURE,
 			"not vectorized: unhandled data access in "
 			"basic block.\n");
 
@@ -3089,8 +3090,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
      anyway.  */
   if (bb_vinfo->grouped_stores.is_empty ())
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: no grouped stores in "
 			 "basic block.\n");
 
@@ -3107,11 +3108,11 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
      trees.  */
   if (!vect_analyze_slp (bb_vinfo, n_stmts))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "Failed to SLP the basic block.\n");
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+	  vect_location_writeln (OPT_RECORD_FAILURE, 
 			   "not vectorized: failed to find SLP opportunities "
 			   "in basic block.\n");
 	}
@@ -3129,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))
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
+	  vect_location_writeln (OPT_RECORD_REMARK,
 			   "removing SLP instance operations starting from: ");
 	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
 			    SLP_TREE_SCALAR_STMTS
@@ -3154,8 +3155,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
 
   if (!vect_slp_analyze_operations (bb_vinfo))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: bad operation in basic block.\n");
 
       delete bb_vinfo;
@@ -3166,8 +3167,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
   if (!unlimited_cost_model (NULL)
       && !vect_bb_vectorization_profitable_p (bb_vinfo))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not vectorized: vectorization is not "
 			 "profitable.\n");
 
@@ -3175,8 +3176,8 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
       return NULL;
     }
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK,
 		     "Basic block will be vectorized using SLP\n");
 
   return bb_vinfo;
@@ -3194,8 +3195,8 @@ vect_slp_bb (basic_block bb)
   bool any_vectorized = false;
   auto_vector_sizes vector_sizes;
 
-  if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location, "===vect_slp_analyze_bb===\n");
+  if (thing_enabled_p ())
+    vect_location_writeln (OPT_RECORD_REMARK, "===vect_slp_analyze_bb===\n");
 
   /* Autodetect first vector size we try.  */
   current_vector_size = 0;
@@ -3222,7 +3223,10 @@ vect_slp_bb (basic_block bb)
 	  insns++;
 
 	  if (gimple_location (stmt) != UNKNOWN_LOCATION)
-	    vect_location = gimple_location (stmt);
+	    {
+	      vect_location = gimple_location (stmt);
+	      vect_location_thing = stmt;
+	    }
 
 	  if (!find_data_references_in_stmt (NULL, stmt, &datarefs))
 	    break;
@@ -3244,13 +3248,13 @@ vect_slp_bb (basic_block bb)
       if (bb_vinfo
 	  && dbg_cnt (vect_slp))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location, "SLPing BB part\n");
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK, "SLPing BB part\n");
 
 	  vect_schedule_slp (bb_vinfo);
 
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_REMARK,
 			     "basic block part vectorized\n");
 
 	  vectorized = true;
@@ -3287,9 +3291,9 @@ vect_slp_bb (basic_block bb)
 	{
 	  /* Try the next biggest vector size.  */
 	  current_vector_size = vector_sizes[next_size++];
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
-	      dump_printf_loc (MSG_NOTE, vect_location,
+	      vect_location_writeln (OPT_RECORD_REMARK,
 			       "***** Re-trying analysis with "
 			       "vector size ");
 	      dump_dec (MSG_NOTE, current_vector_size);
@@ -3951,11 +3955,12 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
 	    }
 	  else
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				   "permutation requires at "
-				   "least three vectors ");
+		  // FIXME: would be better to use "stmt" for location here:
+		  vect_location_writeln (OPT_RECORD_FAILURE,
+					 "permutation requires at "
+					 "least three vectors ");
 		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
 				    stmt, 0);
 		}
@@ -3973,7 +3978,7 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
 	      indices.new_vector (mask, 2, nunits);
 	      if (!can_vec_perm_const_p (mode, indices))
 		{
-		  if (dump_enabled_p ())
+		  if (thing_enabled_p ())
 		    {
 		      dump_printf_loc (MSG_MISSED_OPTIMIZATION,
 				       vect_location, 
@@ -4093,7 +4098,7 @@ vect_schedule_slp_instance (slp_tree node, slp_instance instance,
   if (!SLP_TREE_VEC_STMTS (node).exists ())
     SLP_TREE_VEC_STMTS (node).create (SLP_TREE_NUMBER_OF_VEC_STMTS (node));
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE,vect_location,
 		       "------>vectorizing SLP node starting from: ");
@@ -4255,8 +4260,8 @@ vect_schedule_slp (vec_info *vinfo)
       /* Schedule the tree of INSTANCE.  */
       is_store = vect_schedule_slp_instance (SLP_INSTANCE_TREE (instance),
                                              instance, bst_map);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_REMARK,
                          "vectorizing stmts using SLP.\n");
     }
   delete bst_map;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 3e73118..606c7dc 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -197,7 +197,7 @@ vect_mark_relevant (vec<gimple *> *worklist, gimple *stmt,
   bool save_live_p = STMT_VINFO_LIVE_P (stmt_info);
   gimple *pattern_stmt;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
 		       "mark relevant %d, live %d: ", relevant, live_p);
@@ -217,7 +217,7 @@ vect_mark_relevant (vec<gimple *> *worklist, gimple *stmt,
 
       pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "last stmt in pattern. don't mark"
 			 " relevant/live.\n");
@@ -235,7 +235,7 @@ vect_mark_relevant (vec<gimple *> *worklist, gimple *stmt,
   if (STMT_VINFO_RELEVANT (stmt_info) == save_relevant
       && STMT_VINFO_LIVE_P (stmt_info) == save_live_p)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "already marked relevant/live.\n");
       return;
@@ -265,8 +265,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 (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "use not simple.\n");
 	  return false;
 	}
@@ -313,7 +313,7 @@ vect_stmt_relevant_p (gimple *stmt, loop_vec_info loop_vinfo,
     if (gimple_vdef (stmt)
 	&& !gimple_clobber_p (stmt))
       {
-	if (dump_enabled_p ())
+	if (thing_enabled_p ())
 	  dump_printf_loc (MSG_NOTE, vect_location,
                            "vec_stmt_relevant_p: stmt has vdefs.\n");
 	*relevant = vect_used_in_scope;
@@ -327,7 +327,7 @@ vect_stmt_relevant_p (gimple *stmt, loop_vec_info loop_vinfo,
 	  basic_block bb = gimple_bb (USE_STMT (use_p));
 	  if (!flow_bb_inside_loop_p (loop, bb))
 	    {
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		dump_printf_loc (MSG_NOTE, vect_location,
                                  "vec_stmt_relevant_p: used out of loop.\n");
 
@@ -347,7 +347,7 @@ vect_stmt_relevant_p (gimple *stmt, loop_vec_info loop_vinfo,
   if (*live_p && *relevant == vect_unused_in_scope
       && !is_simple_and_all_uses_invariant (stmt, loop_vinfo))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "vec_stmt_relevant_p: stmt live but not relevant.\n");
       *relevant = vect_used_only_live;
@@ -467,8 +467,8 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
 
   if (!vect_is_simple_use (use, loop_vinfo, &def_stmt, &dt))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "not vectorized: unsupported use in stmt.\n");
       return false;
     }
@@ -479,7 +479,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
   def_bb = gimple_bb (def_stmt);
   if (!flow_bb_inside_loop_p (loop, def_bb))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location, "def_stmt is out of loop.\n");
       return true;
     }
@@ -497,7 +497,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
       && STMT_VINFO_DEF_TYPE (dstmt_vinfo) == vect_reduction_def
       && bb->loop_father == def_bb->loop_father)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
                          "reduc-stmt defining reduc-phi in the same nest.\n");
       if (STMT_VINFO_IN_PATTERN_P (dstmt_vinfo))
@@ -517,7 +517,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
 		...		  */
   if (flow_loop_nested_p (def_bb->loop_father, bb->loop_father))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
                          "outer-loop def-stmt defining inner-loop stmt.\n");
 
@@ -555,7 +555,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
 		stmt # use (d)		*/
   else if (flow_loop_nested_p (bb->loop_father, def_bb->loop_father))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
                          "inner-loop def-stmt defining outer-loop stmt.\n");
 
@@ -590,7 +590,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
 	   && (PHI_ARG_DEF_FROM_EDGE (stmt, loop_latch_edge (bb->loop_father))
 	       == use))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
                          "induction value on backedge.\n");
       return true;
@@ -633,7 +633,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
   bool live_p;
   enum vect_relevant relevant;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "=== vect_mark_stmts_to_be_vectorized ===\n");
 
@@ -646,7 +646,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
       for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
 	{
 	  phi = gsi_stmt (si);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
 	      dump_printf_loc (MSG_NOTE, vect_location, "init: phi relevant? ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
@@ -658,7 +658,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
       for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
 	{
 	  stmt = gsi_stmt (si);
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    {
 	      dump_printf_loc (MSG_NOTE, vect_location, "init: stmt relevant? ");
 	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
@@ -676,7 +676,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
       ssa_op_iter iter;
 
       stmt = worklist.pop ();
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
           dump_printf_loc (MSG_NOTE, vect_location, "worklist: examine stmt: ");
           dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
@@ -708,8 +708,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
 		&& relevant != vect_used_by_reduction
 		&& relevant != vect_used_only_live)
 	      {
-		if (dump_enabled_p ())
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+		if (thing_enabled_p ())
+		  vect_location_writeln (OPT_RECORD_FAILURE,
 				   "unsupported use of reduction.\n");
 		return false;
 	      }
@@ -720,8 +720,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
 		&& relevant != vect_used_in_outer_by_reduction
 		&& relevant != vect_used_in_outer)
               {
-                if (dump_enabled_p ())
-                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                if (thing_enabled_p ())
+                  vect_location_writeln (OPT_RECORD_FAILURE,
                                    "unsupported use of nested cycle.\n");
 
                 return false;
@@ -733,8 +733,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo)
 		&& relevant != vect_used_by_reduction
 		&& relevant != vect_used_only_live)
               {
-                if (dump_enabled_p ())
-                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                if (thing_enabled_p ())
+                  vect_location_writeln (OPT_RECORD_FAILURE,
                                    "unsupported use of double reduction.\n");
 
                 return false;
@@ -840,7 +840,7 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies,
   inside_cost = record_stmt_cost (body_cost_vec, ncopies, vector_stmt,
 				  stmt_info, 0, vect_body);
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_model_simple_cost: inside_cost = %d, "
                      "prologue_cost = %d .\n", inside_cost, prologue_cost);
@@ -885,7 +885,7 @@ vect_model_promotion_demotion_cost (stmt_vec_info stmt_info,
       prologue_cost += add_stmt_cost (target_cost_data, 1, vector_stmt,
 				      stmt_info, 0, vect_prologue);
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_model_promotion_demotion_cost: inside_cost = %d, "
                      "prologue_cost = %d .\n", inside_cost, prologue_cost);
@@ -939,7 +939,7 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies,
       inside_cost = record_stmt_cost (body_cost_vec, nstmts, vec_perm,
 				      stmt_info, 0, vect_body);
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "vect_model_store_cost: strided group_size = %d .\n",
                          group_size);
@@ -969,7 +969,7 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies,
 				       vec_to_scalar, stmt_info, 0, vect_body);
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_model_store_cost: inside_cost = %d, "
                      "prologue_cost = %d .\n", inside_cost, prologue_cost);
@@ -994,7 +994,7 @@ vect_get_store_cost (struct data_reference *dr, int ncopies,
 					  vector_store, stmt_info, 0,
 					  vect_body);
 
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_store_cost: aligned.\n");
         break;
@@ -1006,7 +1006,7 @@ vect_get_store_cost (struct data_reference *dr, int ncopies,
 	*inside_cost += record_stmt_cost (body_cost_vec, ncopies,
 					  unaligned_store, stmt_info,
 					  DR_MISALIGNMENT (dr), vect_body);
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_store_cost: unaligned supported by "
                            "hardware.\n");
@@ -1017,8 +1017,8 @@ vect_get_store_cost (struct data_reference *dr, int ncopies,
       {
         *inside_cost = VECT_MAX_COST;
 
-        if (dump_enabled_p ())
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+        if (thing_enabled_p ())
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "vect_model_store_cost: unsupported access.\n");
         break;
       }
@@ -1075,7 +1075,7 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies,
       inside_cost = record_stmt_cost (body_cost_vec, nstmts, vec_perm,
 				      stmt_info, 0, vect_body);
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "vect_model_load_cost: strided group_size = %d .\n",
                          group_size);
@@ -1101,7 +1101,7 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies,
     inside_cost += record_stmt_cost (body_cost_vec, ncopies, vec_construct,
 				     stmt_info, 0, vect_body);
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_model_load_cost: inside_cost = %d, "
                      "prologue_cost = %d .\n", inside_cost, prologue_cost);
@@ -1128,7 +1128,7 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
 	*inside_cost += record_stmt_cost (body_cost_vec, ncopies, vector_load,
 					  stmt_info, 0, vect_body);
 
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_load_cost: aligned.\n");
 
@@ -1141,7 +1141,7 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
 					  unaligned_load, stmt_info,
 					  DR_MISALIGNMENT (dr), vect_body);
 
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_load_cost: unaligned supported by "
                            "hardware.\n");
@@ -1162,7 +1162,7 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
 	  *inside_cost += record_stmt_cost (body_cost_vec, 1, vector_stmt,
 					    stmt_info, 0, vect_body);
 
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_load_cost: explicit realign\n");
 
@@ -1170,7 +1170,7 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
       }
     case dr_explicit_realign_optimized:
       {
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_load_cost: unaligned software "
                            "pipelined.\n");
@@ -1198,7 +1198,7 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
 	*inside_cost += record_stmt_cost (body_cost_vec, ncopies, vec_perm,
 					  stmt_info, 0, vect_body);
 
-        if (dump_enabled_p ())
+        if (thing_enabled_p ())
           dump_printf_loc (MSG_NOTE, vect_location,
                            "vect_model_load_cost: explicit realign optimized"
                            "\n");
@@ -1210,8 +1210,8 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
       {
         *inside_cost = VECT_MAX_COST;
 
-        if (dump_enabled_p ())
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+        if (thing_enabled_p ())
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "vect_model_load_cost: unsupported access.\n");
         break;
       }
@@ -1260,7 +1260,7 @@ vect_init_vector_1 (gimple *stmt, gimple *new_stmt, gimple_stmt_iterator *gsi)
        }
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "created new init_stmt: ");
@@ -1421,7 +1421,7 @@ vect_get_vec_def_for_operand (tree op, gimple *stmt, tree vectype)
   stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_get_vec_def_for_operand: ");
@@ -1431,7 +1431,7 @@ vect_get_vec_def_for_operand (tree op, gimple *stmt, tree vectype)
 
   is_simple_use = vect_is_simple_use (op, loop_vinfo, &def_stmt, &dt);
   gcc_assert (is_simple_use);
-  if (def_stmt && dump_enabled_p ())
+  if (def_stmt && thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "  def_stmt =  ");
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
@@ -1612,7 +1612,7 @@ vect_finish_stmt_generation_1 (gimple *stmt, gimple *vec_stmt)
 
   set_vinfo_for_stmt (vec_stmt, new_stmt_vec_info (vec_stmt, vinfo));
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "add new stmt: ");
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, vec_stmt, 0);
@@ -1749,8 +1749,8 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
 	  ? !vect_load_lanes_supported (vectype, group_size, true)
 	  : !vect_store_lanes_supported (vectype, group_size, true))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "can't use a fully-masked loop because the"
 			     " target doesn't have an appropriate masked"
 			     " load/store-lanes instruction.\n");
@@ -1773,8 +1773,8 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
 						   TYPE_SIGN (offset_type),
 						   gs_info->scale))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "can't use a fully-masked loop because the"
 			     " target doesn't have an appropriate masked"
 			     " gather load or scatter store instruction.\n");
@@ -1791,8 +1791,8 @@ 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 (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "can't use a fully-masked loop because an access"
 			 " isn't contiguous.\n");
       LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
@@ -1805,8 +1805,8 @@ check_load_store_masking (loop_vec_info loop_vinfo, tree vectype,
 	 GET_MODE_SIZE (vecmode)).exists (&mask_mode))
       || !can_vec_mask_load_store_p (vecmode, mask_mode, is_load))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "can't use a fully-masked loop because the target"
 			 " doesn't have the appropriate masked load or"
 			 " store.\n");
@@ -1871,7 +1871,7 @@ vect_truncate_gather_scatter_offset (gimple *stmt, loop_vec_info loop_vinfo,
   if (TREE_CODE (step) != INTEGER_CST)
     {
       /* ??? Perhaps we could use range information here?  */
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "cannot truncate variable step.\n");
       return false;
@@ -1937,7 +1937,7 @@ vect_truncate_gather_scatter_offset (gimple *stmt, loop_vec_info loop_vinfo,
       return true;
     }
 
-  if (overflow_p && dump_enabled_p ())
+  if (overflow_p && thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
 		     "truncating gather/scatter offset to %d bits"
 		     " might change its value.\n", element_bits);
@@ -1978,7 +1978,7 @@ vect_use_strided_gather_scatters_p (gimple *stmt, loop_vec_info loop_vinfo,
       gs_info->offset = fold_convert (offset_type, gs_info->offset);
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
 		     "using gather/scatter for strided/grouped access,"
 		     " scale = %d\n", gs_info->scale);
@@ -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)
 	    {
-	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      vect_location_writeln (OPT_RECORD_FAILURE,
 			       "Grouped store with gaps requires"
 			       " non-consecutive accesses\n");
 	      return false;
@@ -2116,8 +2116,8 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
 	    overrun_p = false;
 	  if (overrun_p && !can_overrun_p)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "Peeling for outer loop is not supported\n");
 	      return false;
 	    }
@@ -2202,8 +2202,8 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
 	  enum vect_def_type dt;
 	  if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "use not simple.\n");
 	      return false;
 	    }
@@ -2214,8 +2214,8 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
   if (overrun_p)
     {
       gcc_assert (can_overrun_p);
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "Data access with gaps requires scalar "
 			 "epilogue loop\n");
       LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true;
@@ -2239,8 +2239,8 @@ get_negative_load_store_type (gimple *stmt, tree vectype,
 
   if (ncopies > 1)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "multiple types with negative step.\n");
       return VMAT_ELEMENTWISE;
     }
@@ -2249,15 +2249,15 @@ get_negative_load_store_type (gimple *stmt, tree vectype,
   if (alignment_support_scheme != dr_aligned
       && alignment_support_scheme != dr_unaligned_supported)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "negative step but alignment required.\n");
       return VMAT_ELEMENTWISE;
     }
 
   if (vls_type == VLS_STORE_INVARIANT)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "negative step with invariant source;"
 			 " no permute needed.\n");
@@ -2266,8 +2266,8 @@ get_negative_load_store_type (gimple *stmt, tree vectype,
 
   if (!perm_mask_for_reverse (vectype))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "negative step and reversing not supported.\n");
       return VMAT_ELEMENTWISE;
     }
@@ -2305,8 +2305,8 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
 				    &gs_info->offset_dt,
 				    &gs_info->offset_vectype))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "%s index use not simple.\n",
 			     vls_type == VLS_LOAD ? "gather" : "scatter");
 	  return false;
@@ -2347,8 +2347,8 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
        || *memory_access_type == VMAT_STRIDED_SLP)
       && !nunits.is_constant ())
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "Not using elementwise accesses due to variable "
 			 "vectorization factor.\n");
       return false;
@@ -2363,8 +2363,8 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
 	   && !GROUP_NEXT_ELEMENT (stmt_info)
 	   && !pow2p_hwi (GROUP_SIZE (stmt_info))))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not falling back to elementwise accesses\n");
       return false;
     }
@@ -2383,16 +2383,16 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
 {
   if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "mask argument is not a boolean.\n");
       return false;
     }
 
   if (TREE_CODE (mask) != SSA_NAME)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "mask argument is not an SSA name.\n");
       return false;
     }
@@ -2404,8 +2404,8 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
   if (!vect_is_simple_use (mask, stmt_info->vinfo, &def_stmt, &mask_dt,
 			   &mask_vectype))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "mask use not simple.\n");
       return false;
     }
@@ -2416,8 +2416,8 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
 
   if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "could not find an appropriate vector mask type.\n");
       return false;
     }
@@ -2425,9 +2425,9 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
   if (maybe_ne (TYPE_VECTOR_SUBPARTS (mask_vectype),
 		TYPE_VECTOR_SUBPARTS (vectype)))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
 			   "vector mask type ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, mask_vectype);
 	  dump_printf (MSG_MISSED_OPTIMIZATION,
@@ -2456,8 +2456,8 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
      native_encode_expr can handle it.  */
   if (CONSTANT_CLASS_P (rhs) && native_encode_expr (rhs, NULL, 64) == 0)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "cannot encode constant as a byte sequence.\n");
       return false;
     }
@@ -2469,8 +2469,8 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
   if (!vect_is_simple_use (rhs, stmt_info->vinfo, &def_stmt, &rhs_dt,
 			   &rhs_vectype))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "use not simple.\n");
       return false;
     }
@@ -2478,8 +2478,8 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
   if (rhs_vectype && !useless_type_conversion_p (vectype, rhs_vectype))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "incompatible vector types.\n");
       return false;
     }
@@ -2886,7 +2886,7 @@ vectorizable_bswap (gimple *stmt, gimple_stmt_iterator *gsi,
   if (! vec_stmt)
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_bswap ==="
                          "\n");
       if (! slp_node)
@@ -3065,8 +3065,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       if (rhs_type
 	  && !types_compatible_p (rhs_type, TREE_TYPE (op)))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "argument types differ.\n");
 	  return false;
 	}
@@ -3075,8 +3075,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 (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "use not simple.\n");
 	  return false;
 	}
@@ -3086,8 +3086,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       else if (opvectype
 	       && opvectype != vectype_in)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "argument vector types differ.\n");
 	  return false;
 	}
@@ -3100,9 +3100,9 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     gcc_assert (vectype_in);
   if (!vectype_in)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "no vectype for scalar type ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -3126,8 +3126,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   /* We only handle functions that do not read or clobber memory.  */
   if (gimple_vuse (stmt))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "function reads from or writes to memory.\n");
       return false;
     }
@@ -3184,8 +3184,8 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 				   vectype_in, dt);
       else
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "function is not vectorizable.\n");
 	  return false;
 	}
@@ -3205,7 +3205,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_call ==="
                          "\n");
       if (!slp_node)
@@ -3221,7 +3221,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 
   /* Transform.  */
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "transform call.\n");
 
   /* Handle def.  */
@@ -3666,8 +3666,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
 			       &thisarginfo.vectype)
 	  || thisarginfo.dt == vect_uninitialized_def)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "use not simple.\n");
 	  return false;
 	}
@@ -3741,8 +3741,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
   unsigned HOST_WIDE_INT vf;
   if (!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&vf))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not considering SIMD clones; not yet supported"
 			 " for variable-width vectors.\n");
       return NULL;
@@ -3884,7 +3884,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
 	    STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (sll);
 	  }
       STMT_VINFO_TYPE (stmt_info) = call_simd_clone_vec_info_type;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "=== vectorizable_simd_clone_call ===\n");
 /*      vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL); */
@@ -3893,7 +3893,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
 
   /* Transform.  */
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "transform call.\n");
 
   /* Handle def.  */
@@ -4524,8 +4524,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 	  || (INTEGRAL_TYPE_P (rhs_type)
 	      && !type_has_mode_precision_p (rhs_type))))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
                          "type conversion to/from bit-precision unsupported."
                          "\n");
       return false;
@@ -4534,8 +4534,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
   /* Check the operands of the operation.  */
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype_in))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
                          "use not simple.\n");
       return false;
     }
@@ -4554,8 +4554,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 
       if (!ok)
 	{
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_FAILURE,
                              "use not simple.\n");
 	  return false;
 	}
@@ -4569,9 +4569,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     gcc_assert (vectype_in);
   if (!vectype_in)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
                            "no vectype for scalar type ");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
@@ -4583,9 +4583,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
   if (VECTOR_BOOLEAN_TYPE_P (vectype_out)
       && !VECTOR_BOOLEAN_TYPE_P (vectype_in))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	{
-	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  vect_location_writeln (OPT_RECORD_FAILURE,
                            "can't convert between boolean and non "
 			   "boolean vectors");
 	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
@@ -4637,8 +4637,8 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 	break;
       /* FALLTHRU */
     unsupported:
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
                          "conversion not supported by target.\n");
       return false;
 
@@ -4737,7 +4737,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 
   if (!vec_stmt)		/* transformation not required.  */
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
                          "=== vectorizable_conversion ===\n");
       if (code == FIX_TRUNC_EXPR || code == FLOAT_EXPR)
@@ -4763,7 +4763,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     }
 
   /* Transform.  */
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "transform conversion. ncopies = %d.\n", ncopies);
 
@@ -5108,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 (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "use not simple.\n");
       return false;
     }
@@ -5140,8 +5140,8 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
       && (!VECTOR_BOOLEAN_TYPE_P (vectype)
 	  || !VECTOR_BOOLEAN_TYPE_P (vectype_in)))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "type conversion to/from bit-precision "
                          "unsupported.\n");
       return false;
@@ -5150,7 +5150,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "=== vectorizable_assignment ===\n");
       if (!slp_node)
@@ -5159,7 +5159,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
     }
 
   /* Transform.  */
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "transform assignment.\n");
 
   /* Handle def.  */
@@ -5307,8 +5307,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   vectype_out = STMT_VINFO_VECTYPE (stmt_info);
   if (!type_has_mode_precision_p (TREE_TYPE (scalar_dest)))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "bit-precision shifts not supported.\n");
       return false;
     }
@@ -5316,8 +5316,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   op0 = gimple_assign_rhs1 (stmt);
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "use not simple.\n");
       return false;
     }
@@ -5329,8 +5329,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
     gcc_assert (vectype);
   if (!vectype)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "no vectype for scalar type\n");
       return false;
     }
@@ -5343,8 +5343,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   op1 = gimple_assign_rhs2 (stmt);
   if (!vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1], &op1_vectype))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "use not simple.\n");
       return false;
     }
@@ -5395,8 +5395,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
     }
   else
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "operand mode requires invariant argument.\n");
       return false;
     }
@@ -5405,7 +5405,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!scalar_shift_arg)
     {
       optab = optab_for_tree_code (code, vectype, optab_vector);
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "vector/vector shift/rotate found.\n");
 
@@ -5414,8 +5414,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
       if (op1_vectype == NULL_TREE
 	  || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "unusable type for last operand in"
                              " vector/vector shift/rotate.\n");
 	  return false;
@@ -5429,7 +5429,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
       if (optab
           && optab_handler (optab, TYPE_MODE (vectype)) != CODE_FOR_nothing)
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             dump_printf_loc (MSG_NOTE, vect_location,
                              "vector/scalar shift/rotate found.\n");
         }
@@ -5442,7 +5442,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
             {
 	      scalar_shift_arg = false;
 
-              if (dump_enabled_p ())
+              if (thing_enabled_p ())
                 dump_printf_loc (MSG_NOTE, vect_location,
                                  "vector/vector shift/rotate found.\n");
 
@@ -5459,8 +5459,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
 		      && TYPE_MODE (TREE_TYPE (vectype))
 			 != TYPE_MODE (TREE_TYPE (op1)))
 		    {
-                      if (dump_enabled_p ())
-                        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                      if (thing_enabled_p ())
+                        vect_location_writeln (OPT_RECORD_FAILURE,
                                          "unusable type for last operand in"
                                          " vector/vector shift/rotate.\n");
 		      return false;
@@ -5479,8 +5479,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   /* Supportable by target?  */
   if (!optab)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "no optab.\n");
       return false;
     }
@@ -5488,15 +5488,15 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   icode = (int) optab_handler (optab, vec_mode);
   if (icode == CODE_FOR_nothing)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "op not supported by target.\n");
       /* Check only during analysis.  */
       if (maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD)
 	  || (!vec_stmt
 	      && !vect_worthwhile_without_simd_p (vinfo, code)))
         return false;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "proceeding using word mode.\n");
     }
@@ -5506,8 +5506,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
       && !VECTOR_MODE_P (TYPE_MODE (vectype))
       && !vect_worthwhile_without_simd_p (vinfo, code))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "not worthwhile without SIMD support.\n");
       return false;
     }
@@ -5515,7 +5515,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = shift_vec_info_type;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "=== vectorizable_shift ===\n");
       if (!slp_node)
@@ -5525,7 +5525,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
 
   /* Transform.  */
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "transform binary/unary operation.\n");
 
@@ -5547,7 +5547,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
               optab_op2_mode = insn_data[icode].operand[2].mode;
               if (!VECTOR_MODE_P (optab_op2_mode))
                 {
-                  if (dump_enabled_p ())
+                  if (thing_enabled_p ())
                     dump_printf_loc (MSG_NOTE, vect_location,
                                      "operand 1 using scalar mode.\n");
                   vec_oprnd1 = op1;
@@ -5677,8 +5677,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   op_type = TREE_CODE_LENGTH (code);
   if (op_type != unary_op && op_type != binary_op && op_type != ternary_op)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "num. args = %d (not unary/binary/ternary op).\n",
                          op_type);
       return false;
@@ -5696,8 +5696,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       && code != BIT_XOR_EXPR
       && code != BIT_AND_EXPR)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "bit-precision arithmetic not supported.\n");
       return false;
     }
@@ -5705,8 +5705,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   op0 = gimple_assign_rhs1 (stmt);
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "use not simple.\n");
       return false;
     }
@@ -5723,8 +5723,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
 	{
 	  if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (scalar_dest)))
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "not supported operation on bool value.\n");
 	      return false;
 	    }
@@ -5737,9 +5737,9 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
     gcc_assert (vectype);
   if (!vectype)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "no vectype for scalar type ");
           dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
                              TREE_TYPE (op0));
@@ -5759,8 +5759,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       op1 = gimple_assign_rhs2 (stmt);
       if (!vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1]))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "use not simple.\n");
 	  return false;
 	}
@@ -5770,8 +5770,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       op2 = gimple_assign_rhs3 (stmt);
       if (!vect_is_simple_use (op2, vinfo, &def_stmt, &dt[2]))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "use not simple.\n");
 	  return false;
 	}
@@ -5802,8 +5802,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       optab = optab_for_tree_code (code, vectype, optab_default);
       if (!optab)
 	{
-          if (dump_enabled_p ())
-            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          if (thing_enabled_p ())
+            vect_location_writeln (OPT_RECORD_FAILURE,
                              "no optab.\n");
 	  return false;
 	}
@@ -5813,14 +5813,14 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
 
   if (!target_support_p)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
                          "op not supported by target.\n");
       /* Check only during analysis.  */
       if (maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD)
 	  || (!vec_stmt && !vect_worthwhile_without_simd_p (vinfo, code)))
         return false;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
                          "proceeding using word mode.\n");
     }
@@ -5830,8 +5830,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       && !vec_stmt
       && !vect_worthwhile_without_simd_p (vinfo, code))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "not worthwhile without SIMD support.\n");
       return false;
     }
@@ -5839,7 +5839,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = op_vec_info_type;
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "=== vectorizable_operation ===\n");
       if (!slp_node)
@@ -5849,7 +5849,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
 
   /* Transform.  */
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "transform binary/unary operation.\n");
 
@@ -6029,7 +6029,7 @@ get_group_alias_ptr_type (gimple *first_stmt)
       if (get_alias_set (DR_REF (first_dr))
 	  != get_alias_set (DR_REF (next_dr)))
 	{
-	  if (dump_enabled_p ())
+	  if (thing_enabled_p ())
 	    dump_printf_loc (MSG_NOTE, vect_location,
 			     "conflicting alias set types.\n");
 	  return ptr_type_node;
@@ -6128,8 +6128,8 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 
       if (slp_node != NULL)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "SLP of masked stores not supported.\n");
 	  return false;
 	}
@@ -6174,8 +6174,8 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   /* FORNOW.  This restriction should be relaxed.  */
   if (loop && nested_in_vect_loop_p (loop, stmt) && ncopies > 1)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "multiple types in nested loop.\n");
       return false;
     }
@@ -6206,8 +6206,8 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       else if (memory_access_type != VMAT_LOAD_STORE_LANES
 	       && (memory_access_type != VMAT_GATHER_SCATTER || gs_info.decl))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported access type for masked store.\n");
 	  return false;
 	}
@@ -6450,7 +6450,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   else
     ref_type = reference_alias_ptr_type (DR_REF (first_dr));
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "transform store. ncopies = %d\n", ncopies);
 
@@ -7291,8 +7291,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 
       if (slp_node != NULL)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "SLP of masked loads not supported.\n");
 	  return false;
 	}
@@ -7335,8 +7335,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   /* FORNOW. This restriction should be relaxed.  */
   if (nested_in_vect_loop && ncopies > 1)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "multiple types in nested loop.\n");
       return false;
     }
@@ -7348,8 +7348,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       && maybe_gt (LOOP_VINFO_VECT_FACTOR (loop_vinfo),
 		   STMT_VINFO_MIN_NEG_DIST (stmt_info)))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "cannot perform implicit CSE when unrolling "
 			 "with negative dependence distance\n");
       return false;
@@ -7362,8 +7362,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     (e.g. - data copies).  */
   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "Aligned load, but unsupported type.\n");
       return false;
     }
@@ -7389,8 +7389,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	  && maybe_gt (LOOP_VINFO_VECT_FACTOR (loop_vinfo),
 		       STMT_VINFO_MIN_NEG_DIST (stmt_info)))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "cannot perform implicit CSE when performing "
 			     "group loads with negative dependence distance\n");
 	  return false;
@@ -7404,8 +7404,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	      != STMT_SLP_TYPE (vinfo_for_stmt
 				 (STMT_VINFO_GROUP_SAME_DR_STMT (stmt_info)))))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "conflicting SLP types for CSEd load\n");
 	  return false;
 	}
@@ -7435,8 +7435,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	    = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (arglist))));
 	  if (TREE_CODE (masktype) == INTEGER_TYPE)
 	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	      if (thing_enabled_p ())
+		vect_location_writeln (OPT_RECORD_FAILURE,
 				 "masked gather with integer mask not"
 				 " supported.");
 	      return false;
@@ -7445,8 +7445,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       else if (memory_access_type != VMAT_LOAD_STORE_LANES
 	       && memory_access_type != VMAT_GATHER_SCATTER)
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "unsupported access type for masked load.\n");
 	  return false;
 	}
@@ -7474,7 +7474,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     gcc_assert (memory_access_type
 		== STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info));
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "transform load. ncopies = %d\n", ncopies);
 
@@ -8304,7 +8304,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 		      && !nested_in_vect_loop
 		      && hoist_defs_of_uses (stmt, loop))
 		    {
-		      if (dump_enabled_p ())
+		      if (thing_enabled_p ())
 			{
 			  dump_printf_loc (MSG_NOTE, vect_location,
 					   "hoisting out of the vectorized "
@@ -8566,8 +8566,8 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
       /* FORNOW: not yet supported.  */
       if (STMT_VINFO_LIVE_P (stmt_info))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
 			     "value used after loop.\n");
 	  return false;
 	}
@@ -8968,8 +8968,8 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
 
   if (STMT_VINFO_LIVE_P (stmt_info))
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "value used after loop.\n");
       return false;
     }
@@ -9225,7 +9225,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
   gimple *pattern_stmt;
   gimple_seq pattern_def_seq;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "==> examining statement: ");
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
@@ -9233,8 +9233,8 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
 
   if (gimple_has_volatile_ops (stmt))
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "not vectorized: stmt has volatile operands\n");
 
       return false;
@@ -9266,7 +9266,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
           /* Analyze PATTERN_STMT instead of the original stmt.  */
           stmt = pattern_stmt;
           stmt_info = vinfo_for_stmt (pattern_stmt);
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             {
               dump_printf_loc (MSG_NOTE, vect_location,
                                "==> examining pattern statement: ");
@@ -9275,7 +9275,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
         }
       else
         {
-          if (dump_enabled_p ())
+          if (thing_enabled_p ())
             dump_printf_loc (MSG_NOTE, vect_location, "irrelevant.\n");
 
           return true;
@@ -9288,7 +9288,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
                || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_stmt))))
     {
       /* Analyze PATTERN_STMT too.  */
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
           dump_printf_loc (MSG_NOTE, vect_location,
                            "==> examining pattern statement: ");
@@ -9313,7 +9313,7 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
 	      || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_def_stmt)))
 	    {
 	      /* Analyze def stmt of STMT if it's a pattern stmt.  */
-	      if (dump_enabled_p ())
+	      if (thing_enabled_p ())
 		{
 		  dump_printf_loc (MSG_NOTE, vect_location,
                                    "==> examining pattern def statement: ");
@@ -9402,9 +9402,9 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
 
   if (!ok)
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "not vectorized: relevant stmt not ");
           dump_printf (MSG_MISSED_OPTIMIZATION, "supported: ");
           dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
@@ -9421,9 +9421,9 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
   if (STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type
       && !can_vectorize_live_stmts (stmt, NULL, node, NULL))
     {
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         {
-          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+          vect_location_writeln (OPT_RECORD_FAILURE,
                            "not vectorized: live stmt not supported: ");
           dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }
@@ -9540,8 +9540,8 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi,
     default:
       if (!STMT_VINFO_LIVE_P (stmt_info))
 	{
-	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+	  if (thing_enabled_p ())
+	    vect_location_writeln (OPT_RECORD_FAILURE,
                              "stmt not supported.\n");
 	  gcc_unreachable ();
 	}
@@ -9569,7 +9569,7 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi,
       tree scalar_dest;
       gimple *exit_phi;
 
-      if (dump_enabled_p ())
+      if (thing_enabled_p ())
         dump_printf_loc (MSG_NOTE, vect_location,
                          "Record the vdef for outer-loop vectorization.\n");
 
@@ -9907,7 +9907,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
   *def_stmt = NULL;
   *dt = vect_unknown_def_type;
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
                        "vect_is_simple_use: operand ");
@@ -9929,8 +9929,8 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
 
   if (TREE_CODE (operand) != SSA_NAME)
     {
-      if (dump_enabled_p ())
-	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+	vect_location_writeln (OPT_RECORD_FAILURE,
 			 "not ssa-name.\n");
       return false;
     }
@@ -9942,7 +9942,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
     }
 
   *def_stmt = SSA_NAME_DEF_STMT (operand);
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "def_stmt: ");
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, *def_stmt, 0);
@@ -9956,7 +9956,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
       *dt = STMT_VINFO_DEF_TYPE (stmt_vinfo);
     }
 
-  if (dump_enabled_p ())
+  if (thing_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "type of def: ");
       switch (*dt)
@@ -9993,8 +9993,8 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
 
   if (*dt == vect_unknown_def_type)
     {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "Unsupported pattern.\n");
       return false;
     }
@@ -10006,8 +10006,8 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
     case GIMPLE_CALL:
       break;
     default:
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+      if (thing_enabled_p ())
+        vect_location_writeln (OPT_RECORD_FAILURE,
                          "unsupported defining stmt:\n");
       return false;
     }
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 8f18fcd..8d6efa7 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -83,6 +83,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Loop or bb location.  */
 source_location vect_location;
+vect_location_thing_t vect_location_thing;
 
 /* Vector mapping GIMPLE stmt to stmt_vec_info. */
 vec<stmt_vec_info> stmt_vec_info_vec;
@@ -656,6 +657,7 @@ vectorize_loops (void)
 	loop_dist_alias_call = vect_loop_dist_alias_call (loop);
        vectorize_epilogue:
 	vect_location = find_loop_location (loop);
+	vect_location_thing = loop;
         if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOCATION
 	    && dump_enabled_p ())
 	  dump_printf (MSG_NOTE, "\nAnalyzing loop at %s:%d\n",
@@ -782,6 +784,7 @@ vectorize_loops (void)
       }
 
   vect_location = UNKNOWN_LOCATION;
+  vect_location_thing = (gimple *)NULL;
 
   statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
   if (dump_enabled_p ()
@@ -1123,6 +1126,7 @@ increase_alignment (void)
   varpool_node *vnode;
 
   vect_location = UNKNOWN_LOCATION;
+  vect_location_thing = (gimple *)NULL;
   type_align_map = new hash_map<tree, unsigned>;
 
   /* Increase the alignment of all global arrays for vectorization.  */
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 7e2b00f..b10cca7 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-data-ref.h"
 #include "tree-hash-traits.h"
 #include "target.h"
+#include "optimization-records.h"
 
 /* Used for naming of new temporaries.  */
 enum vect_var_kind {
@@ -1383,6 +1384,27 @@ vect_get_scalar_dr_size (struct data_reference *dr)
 /* Source location */
 extern source_location vect_location;
 
+/* FIXME: update this whenever vect_location changes.
+   FIXME: or merge it all together into this class.
+   FIXME: need a non-placeholder name.  */
+class vect_location_thing_t
+{
+ public:
+  vect_location_thing_t () : m_stmt (NULL), m_loop (NULL) {}
+  vect_location_thing_t (gimple *stmt) : m_stmt (stmt), m_loop (NULL) {}
+  vect_location_thing_t (struct loop *loop) : m_stmt (NULL), m_loop (loop) {}
+
+  gimple *m_stmt;
+  struct loop *m_loop;
+};
+
+extern vect_location_thing_t vect_location_thing;
+
+extern void vect_location_writeln (enum opt_record_kind kind,
+				   const char *fmt, ...)
+  ATTRIBUTE_PRINTF_2;
+
+
 /*-----------------------------------------------------------------*/
 /* Function prototypes.                                            */
 /*-----------------------------------------------------------------*/
-- 
1.8.5.3

