From 541f853310668952dcd45afccbb4912624f136fd Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 15 May 2018 14:42:16 -0400
Subject: [PATCH 48/67] More cleanups

---
 gcc/tree-vect-data-refs.c  | 57 ++++++++++++++------------------
 gcc/tree-vect-loop-manip.c | 37 +++++++++------------
 gcc/tree-vect-slp.c        | 81 +++++++++++++++++++++-------------------------
 gcc/tree-vect-stmts.c      | 49 ++++++++++++----------------
 4 files changed, 97 insertions(+), 127 deletions(-)

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 9978de3..40ea93d 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -930,10 +930,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
     {
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_FAILURE << (
-	                   "Unknown alignment for access: ");
-	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, ref);
-	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	  OPTINFO_VECT_FAILURE
+	    << "Unknown alignment for access: "
+	    << slim (ref);
 	}
       return true;
     }
@@ -948,10 +947,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_REMARK << optinfo_printf (
-	                       "can't force alignment of ref: ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
-	      dump_printf (MSG_NOTE, "\n");
+	      OPTINFO_VECT_REMARK
+		<< "can't force alignment of ref: "
+		<< slim (ref);
 	    }
 	  return true;
 	}
@@ -961,9 +959,9 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 	 the analysis phase, before deciding to vectorize the loop.  */
       if (optinfo_enabled_p ())
         {
-          OPTINFO_VECT_REMARK << optinfo_printf ( "force alignment of ");
-          dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
-          dump_printf (MSG_NOTE, "\n");
+          OPTINFO_VECT_REMARK
+	    << "force alignment of "
+	    << slim (ref);
         }
 
       DR_VECT_AUX (dr)->base_decl = base;
@@ -1061,8 +1059,8 @@ vect_update_misalignment_for_peel (struct data_reference *dr,
     }
 
   if (optinfo_enabled_p ())
-    OPTINFO_VECT_REMARK << optinfo_printf ( "Setting misalignment " \
-		     "to unknown (-1).\n");
+    OPTINFO_VECT_REMARK
+      << "Setting misalignment to unknown (-1)";
   SET_DR_MISALIGNMENT (dr, DR_MISALIGNMENT_UNKNOWN);
 }
 
@@ -1080,24 +1078,18 @@ verify_data_ref_alignment (data_reference_p dr)
     {
       if (optinfo_enabled_p ())
 	{
+	  pending_optinfo info = OPTINFO_VECT_FAILURE;
 	  if (DR_IS_READ (dr))
-	    OPTINFO_VECT_FAILURE << (
-			     "not vectorized: unsupported unaligned load.");
+	    info << "not vectorized: unsupported unaligned load";
 	  else
-	    OPTINFO_VECT_FAILURE << (
-			     "not vectorized: unsupported unaligned "
-			     "store.");
-
-	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-			     DR_REF (dr));
-	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	    info << "not vectorized: unsupported unaligned store";
+	  info << slim (DR_REF (dr));
 	}
       return false;
     }
 
   if (supportable_dr_alignment != dr_aligned && optinfo_enabled_p ())
-    OPTINFO_VECT_REMARK << optinfo_printf (
-		     "Vectorizing an unaligned access.\n");
+    OPTINFO_VECT_REMARK << "Vectorizing an unaligned access";
 
   return true;
 }
@@ -1193,16 +1185,15 @@ vector_alignment_reachable_p (struct data_reference *dr)
 		int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_REMARK << optinfo_printf (
-	                   "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
-	  dump_printf (MSG_NOTE,
-	               ". misalignment = %d.\n", DR_MISALIGNMENT (dr));
+	  OPTINFO_VECT_REMARK
+	    << optinfo_printf ("data size =" HOST_WIDE_INT_PRINT_DEC, elmsize)
+	    << optinfo_printf (". misalignment = %d.\n", DR_MISALIGNMENT (dr));
 	}
       if (DR_MISALIGNMENT (dr) % elmsize)
 	{
 	  if (optinfo_enabled_p ())
-	    OPTINFO_VECT_FAILURE << (
-	                     "data size does not divide the misalignment.\n");
+	    OPTINFO_VECT_FAILURE
+	      << ("data size does not divide the misalignment");
 	  return false;
 	}
     }
@@ -1247,9 +1238,9 @@ vect_get_data_access_cost (struct data_reference *dr,
     vect_get_store_cost (dr, ncopies, inside_cost, body_cost_vec);
 
   if (optinfo_enabled_p ())
-    OPTINFO_VECT_REMARK << optinfo_printf (
-                     "vect_get_data_access_cost: inside_cost = %d, "
-                     "outside_cost = %d.\n", *inside_cost, *outside_cost);
+    OPTINFO_VECT_REMARK
+      << optinfo_printf ("vect_get_data_access_cost: inside_cost = %d, "
+			 "outside_cost = %d.\n", *inside_cost, *outside_cost);
 }
 
 
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index afec018..9e86bce 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -1402,8 +1402,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (evolution_part == NULL_TREE)
         {
 	  if (dump_enabled_p ())
-	    dump_printf (MSG_MISSED_OPTIMIZATION,
-			 "No access function or evolution.\n");
+	    OPTINFO_VECT_FAILURE << "No access function or evolution";
 	  return false;
         }
 
@@ -1413,8 +1412,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (!expr_invariant_in_loop_p (loop, evolution_part))
 	{
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "evolution not invariant in loop.\n");
+	    OPTINFO_VECT_FAILURE << "evolution not invariant in loop";
 	  return false;
 	}
 
@@ -1424,8 +1422,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (tree_is_chrec (evolution_part))
 	{
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "evolution is chrec.\n");
+	    OPTINFO_VECT_FAILURE << "evolution is chrec";
 	  return false;
 	}
     }
@@ -1502,17 +1499,16 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo,
       gphi *phi1 = gsi1.phi ();
       if (dump_enabled_p ())
 	{
-	  dump_printf_loc (MSG_NOTE, vect_location,
-			   "vect_update_ivs_after_vectorizer: phi: ");
-	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
+	  OPTINFO_VECT_REMARK
+	    << "vect_update_ivs_after_vectorizer: phi: "
+	    << phi;
 	}
 
       /* Skip reduction and virtual phis.  */
       if (!iv_phi_p (phi))
 	{
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, vect_location,
-			     "reduc or virtual phi. skip.\n");
+	    OPTINFO_VECT_REMARK << "reduc or virtual phi. skip.";
 	  continue;
 	}
 
@@ -1641,8 +1637,8 @@ vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo,
       int npeel = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
 
       if (dump_enabled_p ())
-        dump_printf_loc (MSG_NOTE, vect_location,
-                         "known peeling = %d.\n", npeel);
+        OPTINFO_VECT_REMARK
+	  << optinfo_printf ("known peeling = %d", npeel);
 
       iters = build_int_cst (niters_type, npeel);
       *bound = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
@@ -1673,10 +1669,9 @@ vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo,
 
   if (dump_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-                       "niters for prolog loop: ");
-      dump_generic_expr (MSG_NOTE, TDF_SLIM, iters);
-      dump_printf (MSG_NOTE, "\n");
+      OPTINFO_VECT_REMARK
+	<< "niters for prolog loop: "
+	<< slim (iters);
     }
 
   var = create_tmp_var (niters_type, "prolog_loop_niters");
@@ -1793,7 +1788,7 @@ vect_prepare_for_masked_peels (loop_vec_info loop_vinfo)
 
   if (dump_enabled_p ())
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
+      OPTINFO_VECT_REMARK << optinfo_printf (
 		       "misalignment for fully-masked loop: ");
       dump_generic_expr (MSG_NOTE, TDF_SLIM, misalign_in_elems);
       dump_printf (MSG_NOTE, "\n");
@@ -2931,9 +2926,9 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, tree * cond_expr)
   create_runtime_alias_checks (LOOP_VINFO_LOOP (loop_vinfo),
 			       &comp_alias_ddrs, cond_expr);
   if (dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-		     "created %u versioning for alias checks.\n",
-		     comp_alias_ddrs.length ());
+    OPTINFO_VECT_REMARK
+      << optinfo_printf ("created %u versioning for alias checks",
+			 comp_alias_ddrs.length ());
 }
 
 
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 5b1d61c..59fc283 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -352,10 +352,9 @@ again:
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_FAILURE << optinfo_printf (
-			       "Build SLP failed: can't analyze def for ");
-	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
-              dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	      OPTINFO_VECT_FAILURE
+		<< "Build SLP failed: can't analyze def for "
+		<< slim (oprnd);
 	    }
 
 	  return -1;
@@ -388,11 +387,10 @@ again:
 
 	      if (optinfo_enabled_p ())
 		{
-		  OPTINFO_VECT_FAILURE << optinfo_printf (
-					 "Build SLP failed: some of the stmts"
-					 " are in a pattern, and others are not ");
-		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
-                  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+		  OPTINFO_VECT_FAILURE
+		    << ("Build SLP failed: some of the stmts"
+			" are in a pattern, and others are not ")
+		    << slim (oprnd);
 		}
 
 	      return 1;
@@ -473,11 +471,10 @@ again:
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  OPTINFO_VECT_FAILURE << optinfo_printf (
-				   "Build SLP failed: invalid type of def "
-				   "for variable-length SLP ");
-		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
-		  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+		  OPTINFO_VECT_FAILURE
+		    << ("Build SLP failed: invalid type of def "
+			"for variable-length SLP ")
+		    << slim (oprnd);
 		}
 	      return -1;
 	    }
@@ -500,10 +497,9 @@ again:
 	  /* FORNOW: Not supported.  */
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_FAILURE << optinfo_printf (
-			       "Build SLP failed: illegal type of def ");
-	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
-              dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	      OPTINFO_VECT_FAILURE
+		<< "Build SLP failed: illegal type of def "
+		<< slim (oprnd);
 	    }
 
 	  return -1;
@@ -555,9 +551,9 @@ again:
 			   gimple_assign_rhs2_ptr (stmt));
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_REMARK << optinfo_printf (
-			   "swapped operands to match def types in ");
-	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
+	  OPTINFO_VECT_REMARK
+	    << "swapped operands to match def types in "
+	    << stmt;
 	}
     }
 
@@ -652,8 +648,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_REMARK << optinfo_printf ( "Build SLP for ");
-	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
+	  OPTINFO_VECT_REMARK
+	    << "Build SLP for "
+	    << stmt;
 	}
 
       /* Fail to vectorize statements marked as unvectorizable.  */
@@ -2159,10 +2156,9 @@ vect_analyze_slp_instance (vec_info *vinfo,
     {
       if (optinfo_enabled_p ())
         {
-          OPTINFO_VECT_FAILURE << optinfo_printf (
-			   "Build SLP failed: unsupported data-type ");
-          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, scalar_type);
-          dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+          OPTINFO_VECT_FAILURE
+	    << "Build SLP failed: unsupported data-type "
+	    << slim (scalar_type);
         }
 
       return false;
@@ -2743,10 +2739,9 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
       tree scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_REMARK << optinfo_printf (
-			   "get vectype for scalar type:  ");
-	  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
-	  dump_printf (MSG_NOTE, "\n");
+	  OPTINFO_VECT_REMARK
+	    << "get vectype for scalar type:  "
+	    << slim (scalar_type);
 	}
 
       tree vectype = get_vectype_for_scalar_type (scalar_type);
@@ -2754,20 +2749,18 @@ vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_FAILURE << optinfo_printf (
-			       "not SLPed: unsupported data-type ");
-	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-				 scalar_type);
-	      dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	      OPTINFO_VECT_FAILURE
+		<< "not SLPed: unsupported data-type "
+		<< slim (scalar_type);
 	    }
 	  return false;
 	}
 
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_REMARK << optinfo_printf ( "vectype:  ");
-	  dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
-	  dump_printf (MSG_NOTE, "\n");
+	  OPTINFO_VECT_REMARK
+	    << "vectype:  "
+	    << slim (vectype);
 	}
 
       gimple *sstmt;
@@ -3952,15 +3945,15 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
 		{
 		  if (optinfo_enabled_p ())
 		    {
-		      dump_printf_loc (MSG_MISSED_OPTIMIZATION,
-				       vect_location, 
-				       "unsupported vect permute { ");
+		      pending_optinfo info = OPTINFO_VECT_FAILURE
+			<< "unsupported vect permute { ";
 		      for (i = 0; i < nunits; ++i)
 			{
+			  // FIXME
 			  dump_dec (MSG_MISSED_OPTIMIZATION, mask[i]);
-			  dump_printf (MSG_MISSED_OPTIMIZATION, " ");
+			  info << " ";
 			}
-		      dump_printf (MSG_MISSED_OPTIMIZATION, "}\n");
+		      info << "}";
 		    }
 		  gcc_assert (analyze_only);
 		  return false;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 6558330..b6c7d27 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2425,13 +2425,11 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
     {
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_FAILURE << optinfo_printf (
-			   "vector mask type ");
-	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, mask_vectype);
-	  dump_printf (MSG_MISSED_OPTIMIZATION,
-		       " does not match vector data type ");
-	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, vectype);
-	  dump_printf (MSG_MISSED_OPTIMIZATION, ".\n");
+	  OPTINFO_VECT_FAILURE
+	    << "vector mask type "
+	    << slim (mask_vectype)
+	    << " does not match vector data type "
+	    << slim (vectype);
 	}
       return false;
     }
@@ -3099,10 +3097,9 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     {
       if (optinfo_enabled_p ())
         {
-          OPTINFO_VECT_FAILURE << optinfo_printf (
-                           "no vectype for scalar type ");
-          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
-          dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+          OPTINFO_VECT_FAILURE
+	    << "no vectype for scalar type "
+	    << slim (rhs_type);
         }
 
       return false;
@@ -4527,8 +4524,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype_in))
     {
       if (optinfo_enabled_p ())
-	OPTINFO_VECT_FAILURE << optinfo_printf (
-			       "use not simple");
+	OPTINFO_VECT_FAILURE << "use not simple";
       return false;
     }
   if (op_type == binary_op)
@@ -4547,8 +4543,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
       if (!ok)
 	{
           if (optinfo_enabled_p ())
-            OPTINFO_VECT_FAILURE << optinfo_printf (
-				   "use not simple");
+            OPTINFO_VECT_FAILURE << "use not simple";
 	  return false;
 	}
     }
@@ -4563,10 +4558,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_FAILURE << optinfo_printf (
-                           "no vectype for scalar type ");
-	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
-          dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	  OPTINFO_VECT_FAILURE
+	    << "no vectype for scalar type "
+	    << slim (rhs_type);
 	}
 
       return false;
@@ -4577,11 +4571,10 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (optinfo_enabled_p ())
 	{
-	  OPTINFO_VECT_FAILURE << optinfo_printf (
-                           "can't convert between boolean and non "
-			   "boolean vectors");
-	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
-          dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	  OPTINFO_VECT_FAILURE
+	    << ("can't convert between boolean and non "
+		"boolean vectors")
+	    << slim (rhs_type);
 	}
 
       return false;
@@ -5725,11 +5718,9 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       if (optinfo_enabled_p ())
         {
-          OPTINFO_VECT_FAILURE << optinfo_printf (
-                           "no vectype for scalar type ");
-          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-                             TREE_TYPE (op0));
-          dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+          OPTINFO_VECT_FAILURE
+	    << "no vectype for scalar type "
+	    << slim (TREE_TYPE (op0));
         }
 
       return false;
-- 
1.8.5.3

