From bbf8eca7dd64ec932a6f2be7574af0824950741a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 15 May 2018 15:21:35 -0400
Subject: [PATCH 51/67] Handle report_vect_op

---
 gcc/tree-vect-loop.c  | 30 +++++++++++++++---------------
 gcc/tree-vectorizer.h | 11 ++++++++---
 2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 9e9c847..6cc6af9 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2747,10 +2747,10 @@ neutral_op_for_slp_reduction (slp_tree slp_node, tree_code code,
    STMT is printed with a message MSG. */
 
 static void
-report_vect_op (dump_flags_t msg_type, gimple *stmt, const char *msg)
+report_vect_op (enum optinfo_kind kind, gimple *stmt, const char *msg)
 {
-  dump_printf_loc (msg_type, vect_location, "%s", msg);
-  dump_gimple_stmt (msg_type, TDF_SLIM, stmt, 0);
+  OPTINFO_VECT (kind)
+    << msg << stmt;
 }
 
 
@@ -3274,7 +3274,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 	  && flow_bb_inside_loop_p (loop->inner, gimple_bb (phi_use_stmt)))
         {
           if (optinfo_enabled_p ())
-            report_vect_op (MSG_NOTE, def_stmt,
+            report_vect_op (OPTINFO_KIND_NOTE, def_stmt,
 			    "detected double reduction: ");
 
           *double_reduc = true;
@@ -3328,7 +3328,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       if (op3 == phi_name || op4 == phi_name)
 	{
 	  if (optinfo_enabled_p ())
-	    report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+	    report_vect_op (OPTINFO_KIND_FAILURE, def_stmt,
 			    "reduction: condition depends on previous"
 			    " iteration: ");
 	  return NULL;
@@ -3340,7 +3340,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
   else if (!commutative_tree_code (code) || !associative_tree_code (code))
     {
       if (optinfo_enabled_p ())
-	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+	report_vect_op (OPTINFO_KIND_FAILURE, def_stmt,
 			"reduction: not commutative/associative: ");
       return NULL;
     }
@@ -3352,7 +3352,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
   else
     {
       if (optinfo_enabled_p ())
-	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+	report_vect_op (OPTINFO_KIND_FAILURE, def_stmt,
 			"reduction: not handled operation: ");
       return NULL;
     }
@@ -3360,7 +3360,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
   if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
     {
       if (optinfo_enabled_p ())
-	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+	report_vect_op (OPTINFO_KIND_FAILURE, def_stmt,
 			"reduction: both uses not ssa_names: ");
 
       return NULL;
@@ -3423,7 +3423,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       && ((!def1 || gimple_nop_p (def1)) && (!def2 || gimple_nop_p (def2))))
     {
       if (optinfo_enabled_p ())
-	report_vect_op (MSG_NOTE, def_stmt, "reduction: no defs for operands: ");
+	report_vect_op (OPTINFO_KIND_NOTE, def_stmt, "reduction: no defs for operands: ");
       return NULL;
     }
 
@@ -3446,7 +3446,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
  	              && !is_loop_header_bb_p (gimple_bb (def1)))))))
     {
       if (optinfo_enabled_p ())
-	report_vect_op (MSG_NOTE, def_stmt, "detected reduction: ");
+	report_vect_op (OPTINFO_KIND_NOTE, def_stmt, "detected reduction: ");
       return def_stmt;
     }
 
@@ -3491,7 +3491,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 	      else
 		{
 		  if (optinfo_enabled_p ())
-		    report_vect_op (MSG_NOTE, def_stmt,
+		    report_vect_op (OPTINFO_KIND_NOTE, def_stmt,
 				    "detected reduction: cannot swap operands "
 				    "for cond_expr");
 		  return NULL;
@@ -3502,7 +3502,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 			       gimple_assign_rhs2_ptr (def_stmt));
 
 	  if (optinfo_enabled_p ())
-	    report_vect_op (MSG_NOTE, def_stmt,
+	    report_vect_op (OPTINFO_KIND_NOTE, def_stmt,
 			    "detected reduction: need to swap operands: ");
 
 	  if (CONSTANT_CLASS_P (gimple_assign_rhs1 (def_stmt)))
@@ -3511,7 +3511,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       else
         {
           if (optinfo_enabled_p ())
-            report_vect_op (MSG_NOTE, def_stmt, "detected reduction: ");
+            report_vect_op (OPTINFO_KIND_NOTE, def_stmt, "detected reduction: ");
         }
 
       return def_stmt;
@@ -3524,7 +3524,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
       && vect_is_slp_reduction (loop_info, phi, def_stmt))
     {
       if (optinfo_enabled_p ())
-        report_vect_op (MSG_NOTE, def_stmt,
+        report_vect_op (OPTINFO_KIND_NOTE, def_stmt,
 			"reduction: detected reduction chain: ");
 
       return def_stmt;
@@ -3547,7 +3547,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
 
   if (optinfo_enabled_p ())
     {
-      report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+      report_vect_op (OPTINFO_KIND_FAILURE, def_stmt,
 		      "reduction: unknown pattern: ");
     }
 
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index c0db732..3b90f43 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -1393,20 +1393,25 @@ extern pending_optinfo
 emit_optinfo_at_vect_location (const location &impl_location,
 			       enum optinfo_kind kind);
 
+/* Emit optimization information at the vect location.  */
+
+#define OPTINFO_VECT(KIND) \
+  (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, (KIND)))
+
 /* Emit that a successful optimization happened at the vect location.  */
 
 #define OPTINFO_VECT_SUCCESS \
-  (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPTINFO_KIND_SUCCESS))
+  (OPTINFO_VECT (OPTINFO_KIND_SUCCESS))
 
 /* Emit that a failed optimization happened at the vect location.  */
 
 #define OPTINFO_VECT_FAILURE \
-  (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPTINFO_KIND_FAILURE))
+  (OPTINFO_VECT (OPTINFO_KIND_FAILURE))
 
 /* Emit a remark relating to an optimization at the vect location.  */
 
 #define OPTINFO_VECT_NOTE \
-  (emit_optinfo_at_vect_location (OPTINFO_IMPL_LOCATION, OPTINFO_KIND_NOTE))
+  (OPTINFO_VECT (OPTINFO_KIND_NOTE))
 
 /* FIXME.  */
 
-- 
1.8.5.3

