From f6e26d34e5ee92c8ddf2c92c4eee0950492ceb02 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 15 May 2018 13:39:01 -0400
Subject: [PATCH 46/67] More cleanups

---
 gcc/tree-vect-data-refs.c |  46 +++++++------
 gcc/tree-vect-slp.c       | 164 +++++++++++++++++++++-------------------------
 gcc/tree-vect-stmts.c     |  13 ++--
 3 files changed, 101 insertions(+), 122 deletions(-)

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index f40ce9c..89f66bc 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -2426,13 +2426,11 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
-	                       "Step ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, step);
-	      dump_printf (MSG_NOTE,
-			   " is not a multiple of the element size for ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr));
-	      dump_printf (MSG_NOTE, "\n");
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+		<< "Step "
+		<< slim (step)
+		<< " is not a multiple of the element size for "
+		<< slim (DR_REF (dr));
 	    }
 	  return false;
 	}
@@ -2458,12 +2456,11 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	  GROUP_GAP (stmt_info) = groupsize - 1;
 	  if (optinfo_enabled_p ())
 	    {
-	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf (
-	                       "Detected single element interleaving ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr));
-	      dump_printf (MSG_NOTE, " step ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, step);
-	      dump_printf (MSG_NOTE, "\n");
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+		<< "Detected single element interleaving "
+		<< slim (DR_REF (dr))
+		<< " step "
+		<< slim (step);
 	    }
 
 	  return true;
@@ -2483,7 +2480,8 @@ vect_analyze_group_access_1 (struct data_reference *dr)
           return true;
         }
 
-      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK) << optinfo_printf ( "using strided accesses\n");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_REMARK)
+	<< "using strided accesses";
       STMT_VINFO_STRIDED_P (stmt_info) = true;
       return true;
     }
@@ -2512,14 +2510,14 @@ vect_analyze_group_access_1 (struct data_reference *dr)
               if (DR_IS_WRITE (data_ref))
                 {
                   if (optinfo_enabled_p ())
-                    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << (
-                                     "Two store stmts share the same dr.\n");
+                    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		      << "Two store stmts share the same dr";
                   return false;
                 }
 
 	      if (optinfo_enabled_p ())
-		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << (
-				 "Two or more load stmts share the same dr.\n");
+		EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		  << "Two or more load stmts share the same dr";
 
               /* For load use the same data-ref load.  */
               GROUP_SAME_DR_STMT (vinfo_for_stmt (next)) = prev;
@@ -2546,8 +2544,8 @@ vect_analyze_group_access_1 (struct data_reference *dr)
 	      if (DR_IS_WRITE (data_ref))
 		{
                   if (optinfo_enabled_p ())
-                    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << (
-                                     "interleaved store with gaps\n");
+                    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		      << "interleaved store with gaps";
 		  return false;
 		}
 
@@ -4228,8 +4226,8 @@ again:
             {
               EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
 		<< ("not vectorized: more than one data ref "
-		    "in stmt: ");
-              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+		    "in stmt: ")
+		<< stmt;
             }
 
           if (is_a <bb_vec_info> (vinfo))
@@ -4256,8 +4254,8 @@ again:
             {
               EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
 		<< ("not vectorized: base object not addressable "
-		    "for stmt: ");
-              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+		    "for stmt: ")
+		<< stmt;
             }
           if (is_a <bb_vec_info> (vinfo))
 	    {
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index ce23d01..c151512 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -580,10 +580,9 @@ vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
     {
       if (optinfo_enabled_p ())
 	{
-	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-			   "Build SLP failed: unsupported data-type in ");
-	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
-	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+	  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	    << "Build SLP failed: unsupported data-type in "
+	    << stmt;
 	}
       /* Fatal mismatch.  */
       return false;
@@ -597,9 +596,9 @@ vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
       && (!nunits.is_constant (&const_nunits)
 	  || const_nunits > group_size))
     {
-      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-			     "Build SLP failed: unrolling required "
-			     "in basic block SLP");
+      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	<< ("Build SLP failed: unrolling required "
+	    "in basic block SLP");
       /* Fatal mismatch.  */
       return false;
     }
@@ -662,9 +661,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
         {
           if (optinfo_enabled_p ())
             {
-              EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-			       "Build SLP failed: unvectorizable statement ");
-              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+              EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		<< "Build SLP failed: unvectorizable statement "
+		<< stmt;
             }
 	  /* Fatal mismatch.  */
 	  matches[0] = false;
@@ -676,10 +675,10 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	{
 	  if (optinfo_enabled_p ())
 	    {
-	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-			       "Build SLP failed: not GIMPLE_ASSIGN nor "
-			       "GIMPLE_CALL ");
-	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+	      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		<< ("Build SLP failed: not GIMPLE_ASSIGN nor "
+		    "GIMPLE_CALL ")
+		<< stmt;
 	    }
 	  /* Fatal mismatch.  */
 	  matches[0] = false;
@@ -707,10 +706,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
-				   "Build SLP failed: unsupported call type ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-				    call_stmt, 0);
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << "Build SLP failed: unsupported call type "
+		    << call_stmt;
 		}
 	      /* Fatal mismatch.  */
 	      matches[0] = false;
@@ -747,8 +745,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		  if (!optab)
 		    {
 		      if (optinfo_enabled_p ())
-			EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-					 "Build SLP failed: no optab.\n");
+			EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+			  << "Build SLP failed: no optab";
 		      /* Fatal mismatch.  */
 		      matches[0] = false;
 		      return false;
@@ -757,9 +755,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		  if (icode == CODE_FOR_nothing)
 		    {
 		      if (optinfo_enabled_p ())
-			EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-					 "Build SLP failed: "
-					 "op not supported by target.\n");
+			EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+			  << ("Build SLP failed: "
+			      "op not supported by target");
 		      /* Fatal mismatch.  */
 		      matches[0] = false;
 		      return false;
@@ -804,14 +802,12 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
-				   "Build SLP failed: different operation "
-				   "in stmt ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				   "original stmt ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-				    first_stmt, 0);
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << ("Build SLP failed: different operation "
+			"in stmt ")
+		    << stmt
+		    << "original stmt "
+		    << first_stmt;
 		}
 	      /* Mismatch.  */
 	      continue;
@@ -822,10 +818,10 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
-				   "Build SLP failed: different shift "
-				   "arguments in ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << ("Build SLP failed: different shift "
+			"arguments in ")
+		    << stmt;
 		}
 	      /* Mismatch.  */
 	      continue;
@@ -842,10 +838,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		{
 		  if (optinfo_enabled_p ())
 		    {
-		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
-				       "Build SLP failed: different calls in ");
-		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-					stmt, 0);
+		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+			<< "Build SLP failed: different calls in "
+			<< stmt;
 		    }
 		  /* Mismatch.  */
 		  continue;
@@ -873,12 +868,10 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
                     {
                       if (optinfo_enabled_p ())
                         {
-                          dump_printf_loc (MSG_MISSED_OPTIMIZATION,
-					   vect_location, 
-					   "Build SLP failed: different "
-					   "interleaving chains in one node ");
-                          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-					    stmt, 0);
+			  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+			    <<  ("Build SLP failed: different "
+				 "interleaving chains in one node ")
+			    << stmt;
                         }
 		      /* Mismatch.  */
 		      continue;
@@ -895,9 +888,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	      /* Not grouped load.  */
 	      if (optinfo_enabled_p ())
 		{
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf ( 
-				   "Build SLP failed: not grouped load ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << "Build SLP failed: not grouped load "
+		    << stmt;
 		}
 
 	      /* FORNOW: Not grouped loads are not supported.  */
@@ -915,10 +908,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	    {
 	      if (optinfo_enabled_p ())
 		{
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				   "Build SLP failed: operation");
-		  dump_printf (MSG_MISSED_OPTIMIZATION, " unsupported ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << "Build SLP failed: operation unsupported "
+		    << stmt;
 		}
 	      /* Fatal mismatch.  */
 	      matches[0] = false;
@@ -953,11 +945,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		{
 		  if (optinfo_enabled_p ())
 		    {
-		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				       "Build SLP failed: different"
-				       " operation");
-		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-					stmt, 0);
+		      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+			<< "Build SLP failed: different operation"
+			<< stmt;
 		    }
 		  /* Mismatch.  */
 		  continue;
@@ -982,9 +972,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
       if (!nunits.is_constant (&count))
 	{
 	  if (optinfo_enabled_p ())
-	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-			     "Build SLP failed: different operations "
-			     "not allowed with variable-length SLP.\n");
+	    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	      << ("Build SLP failed: different operations "
+		  "not allowed with variable-length SLP");
 	  return false;
 	}
       vec_perm_builder sel (count, count, 1);
@@ -1004,15 +994,12 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 		matches[i] = false;
 		if (optinfo_enabled_p ())
 		  {
-		    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				     "Build SLP failed: different operation "
-				     "in stmt ");
-		    dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-				      stmts[i], 0);
-		    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				     "original stmt ");
-		    dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-				      first_stmt, 0);
+		    EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		      << ("Build SLP failed: different operation "
+			  "in stmt ")
+		      << stmts[i]
+		      << "original stmt "
+		      << first_stmt;
 		  }
 	      }
 	  return false;
@@ -1347,12 +1334,10 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 			{
 			  if (optinfo_enabled_p ())
 			    {
-			      dump_printf_loc (MSG_MISSED_OPTIMIZATION,
-					       vect_location,
-					       "Build SLP failed: cannot swap "
-					       "operands of shared stmt ");
-			      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,
-						TDF_SLIM, stmts[j], 0);
+			      EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+				<< ("Build SLP failed: cannot swap "
+				    "operands of shared stmt ")
+				<< stmts[j];
 			    }
 			  goto fail;
 			}
@@ -1734,9 +1719,9 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
 	      if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits)
 		  || maxk >= (GROUP_SIZE (group_info) & ~(nunits - 1)))
 		{
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				   "BB vectorization with gaps at the end of "
-				   "a load is not supported\n");
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << ("BB vectorization with gaps at the end of "
+			"a load is not supported");
 		  return false;
 		}
 
@@ -1746,9 +1731,8 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
 	      if (!vect_transform_slp_perm_load (node, tem, NULL,
 						 1, slp_instn, true, &n_perms))
 		{
-		  dump_printf_loc (MSG_MISSED_OPTIMIZATION,
-				   vect_location,
-				   "unsupported load permutation\n");
+		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << "unsupported load permutation";
 		  return false;
 		}
 	    }
@@ -2304,11 +2288,10 @@ vect_analyze_slp_instance (vec_info *vinfo,
             {
               if (optinfo_enabled_p ())
                 {
-                  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-				   "Build SLP failed: unsupported load "
-				   "permutation ");
-		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,
-					TDF_SLIM, stmt, 0);
+                  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << ("Build SLP failed: unsupported load "
+			"permutation ")
+		    << stmt;
                 }
               vect_free_slp_instance (new_instance);
               return false;
@@ -3949,11 +3932,10 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
 	      if (optinfo_enabled_p ())
 		{
 		  // FIXME: would be better to use "stmt" for location here:
-		  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-					 "permutation requires at "
-					 "least three vectors ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
-				    stmt, 0);
+                  EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+		    << ("permutation requires at "
+			"least three vectors ")
+		    << stmt;
 		}
 	      gcc_assert (analyze_only);
 	      return false;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 00445cd..40c5825 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -9388,10 +9388,9 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
     {
       if (optinfo_enabled_p ())
         {
-          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-                           "not vectorized: relevant stmt not ");
-          dump_printf (MSG_MISSED_OPTIMIZATION, "supported: ");
-          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	    << "not vectorized: relevant stmt not supported: "
+	    << stmt;
         }
 
       return false;
@@ -9407,9 +9406,9 @@ vect_analyze_stmt (gimple *stmt, bool *need_to_vectorize, slp_tree node,
     {
       if (optinfo_enabled_p ())
         {
-          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE) << optinfo_printf (
-                           "not vectorized: live stmt not supported: ");
-          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+          EMIT_OPTINFO_AT_VECT_LOCATION (OPT_RECORD_FAILURE)
+	    << "not vectorized: live stmt not supported: "
+	    << stmt;
         }
 
        return false;
-- 
1.8.5.3

