From 2e14b35ddae8a5fc9f081766daf855d13533b431 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 16 May 2018 12:02:29 -0400
Subject: [PATCH 56/67] Eliminate most uses of dump_dec

---
 gcc/optinfo.h             | 17 ++++++++++++++---
 gcc/tree-vect-data-refs.c | 26 +++++++++++---------------
 gcc/tree-vect-loop.c      | 37 ++++++++++---------------------------
 gcc/tree-vect-slp.c       | 21 +++++++--------------
 4 files changed, 42 insertions(+), 59 deletions(-)

diff --git a/gcc/optinfo.h b/gcc/optinfo.h
index 47a14ef..a391966 100644
--- a/gcc/optinfo.h
+++ b/gcc/optinfo.h
@@ -282,15 +282,26 @@ class pending_optinfo
   pending_optinfo& operator<< (gimple *);
   pending_optinfo& operator<< (const optinfo_printf &);
 
-#if 0
   /* Compare with dump_dec (MSG_NOTE, ).  */
   template<unsigned int N, typename C>
   pending_optinfo& operator<< (const poly_int<N, C> &val)
   {
-    m_optinfo->m_items.safe_push (new optinfo_item_poly_int (val));
+#if 0
+    STATIC_ASSERT (poly_coeff_traits<C>::signedness >= 0);
+    signop sgn = poly_coeff_traits<C>::signedness ? SIGNED : UNSIGNED;
+
+    /* This must be large enough to hold any printed integer or
+       floating-point value.  */
+    pretty_printer pp;
+    print_dec (val, &pp, sgn);
+    m_optinfo->m_items.safe_push
+      (new optinfo_item_text (xstrdup (pp_formatted_text (&pp)), true));
+#else
+    (void)val; // suppress "unused parameter" warning
+    *this << "FIXME: poly_int";
+#endif
     return *this;
   }
-#endif
 
  private:
   // FIXME: are we allowed this yet?  or do we need a gnu::shared_ptr
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 9e7357d..a855722 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -3404,23 +3404,19 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
 	  bool unsigned_p = dr_known_forward_stride_p (dr_a);
 	  if (optinfo_enabled_p ())
 	    {
-	      OPTINFO_VECT_NOTE << optinfo_printf ( "no alias between ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_a));
-	      dump_printf (MSG_NOTE, " and ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr_b));
-	      dump_printf (MSG_NOTE, " when the step ");
-	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_STEP (dr_a));
-	      dump_printf (MSG_NOTE, " is outside ");
+	      pending_optinfo info = OPTINFO_VECT_NOTE
+		<< optinfo_printf ( "no alias between ")
+		<< slim (DR_REF (dr_a))
+		<< " and "
+		<< slim (DR_REF (dr_b))
+		<< " when the step "
+		<< slim (DR_STEP (dr_a))
+		<< " is outside ";
 	      if (unsigned_p)
-		dump_printf (MSG_NOTE, "[0");
+		info << "[0";
 	      else
-		{
-		  dump_printf (MSG_NOTE, "(");
-		  dump_dec (MSG_NOTE, poly_int64 (-lower_bound));
-		}
-	      dump_printf (MSG_NOTE, ", ");
-	      dump_dec (MSG_NOTE, lower_bound);
-	      dump_printf (MSG_NOTE, ")\n");
+		info << "(" << poly_int64 (-lower_bound);
+	      info << ", " << lower_bound << ")";
 	    }
 	  vect_check_lower_bound (loop_vinfo, DR_STEP (dr_a), unsigned_p,
 				  lower_bound);
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 6cc6af9..279e7e0 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -267,11 +267,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 
 	      if (optinfo_enabled_p ())
 		{
-#if 0
 		  OPTINFO_VECT_NOTE
 		    << "nunits = "
 		    << TYPE_VECTOR_SUBPARTS (vectype);
-#endif
 		}
 
 	      vect_update_max_nunits (&vectorization_factor, vectype);
@@ -550,12 +548,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 
 	  if (optinfo_enabled_p ())
 	    {
-#if 0
 	      OPTINFO_VECT_NOTE
 		<< "nunits = "
-	      dump_dec (MSG_NOTE, TYPE_VECTOR_SUBPARTS (vf_vectype));
-	      dump_printf (MSG_NOTE, "\n");
-#endif
+		<< TYPE_VECTOR_SUBPARTS (vf_vectype);
 	    }
 
 	  vect_update_max_nunits (&vectorization_factor, vf_vectype);
@@ -571,11 +566,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
   /* TODO: Analyze cost. Decide if worth while to vectorize.  */
   if (optinfo_enabled_p ())
     {
-#if 0
       OPTINFO_VECT_NOTE
 	<< "vectorization factor = "
-      dump_dec (MSG_NOTE, vectorization_factor);
-#endif
+	<< vectorization_factor;
     }
 
   if (known_le (vectorization_factor, 1U))
@@ -1753,12 +1746,9 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo)
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
   if (optinfo_enabled_p ())
     {
-#if 0
       OPTINFO_VECT_NOTE
-	<< "Updating vectorization factor to ");
-      dump_dec (MSG_NOTE, vectorization_factor);
-#endif
-      dump_printf (MSG_NOTE, ".\n");
+	<< "Updating vectorization factor to "
+	<< vectorization_factor;
     }
 }
 
@@ -2239,13 +2229,11 @@ start_over:
 
   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) && optinfo_enabled_p ())
     {
-#if 0
       OPTINFO_VECT_NOTE
 	<< "vectorization_factor = "
-      dump_dec (MSG_NOTE, vectorization_factor);
-      dump_printf (MSG_NOTE, ", niters = " HOST_WIDE_INT_PRINT_DEC "\n",
-		   LOOP_VINFO_INT_NITERS (loop_vinfo));
-#endif
+	<< vectorization_factor
+	<< optinfo_printf (", niters = " HOST_WIDE_INT_PRINT_DEC,
+			   LOOP_VINFO_INT_NITERS (loop_vinfo));
     }
 
   HOST_WIDE_INT max_niter
@@ -2615,12 +2603,9 @@ vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo)
       current_vector_size = vector_sizes[next_size++];
       if (optinfo_enabled_p ())
 	{
-#if 0
 	  OPTINFO_VECT_NOTE
-	    << "***** Re-trying analysis with vector size ";
-	  dump_dec (MSG_NOTE, current_vector_size);
-	  dump_printf (MSG_NOTE, "\n");
-#endif
+	    << "***** Re-trying analysis with vector size "
+	    << current_vector_size;
 	}
     }
 }
@@ -9005,12 +8990,10 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	}
       else
 	{
-#if 0
 	  OPTINFO_VECT_NOTE
 	    << "LOOP EPILOGUE VECTORIZED (VS="
-	  dump_dec (MSG_NOTE, current_vector_size);
+	    << current_vector_size
 	    << ")";
-#endif
 	}
     }
 
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 5df159d..5dcd366 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2470,11 +2470,10 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
 
   if (decided_to_slp && optinfo_enabled_p ())
     {
-      OPTINFO_VECT_NOTE << optinfo_printf (
-		       "Decided to SLP %d instances. Unrolling factor ",
-		       decided_to_slp);
-      dump_dec (MSG_NOTE, unrolling_factor);
-      dump_printf (MSG_NOTE, "\n");
+      OPTINFO_VECT_NOTE
+	<< optinfo_printf ("Decided to SLP %d instances. Unrolling factor ",
+			   decided_to_slp)
+	<< unrolling_factor;
     }
 
   return (decided_to_slp > 0);
@@ -3261,10 +3260,8 @@ vect_slp_bb (basic_block bb)
 	  if (optinfo_enabled_p ())
 	    {
 	      OPTINFO_VECT_NOTE
-		<< "***** Re-trying analysis with vector size ";
-	      // FIXME:
-	      dump_dec (MSG_NOTE, current_vector_size);
-	      dump_printf (MSG_NOTE, "\n");
+		<< "***** Re-trying analysis with vector size "
+		<< current_vector_size;
 	    }
 
 	  /* Start over.  */
@@ -3948,11 +3945,7 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
 		      pending_optinfo info = OPTINFO_VECT_FAILURE
 			<< "unsupported vect permute { ";
 		      for (i = 0; i < nunits; ++i)
-			{
-			  // FIXME
-			  dump_dec (MSG_MISSED_OPTIMIZATION, mask[i]);
-			  info << " ";
-			}
+			info << mask[i] << " ";
 		      info << "}";
 		    }
 		  gcc_assert (analyze_only);
-- 
1.8.5.3

