[2/5] Use opt-problem.h in try_vectorize_loop_1

Message ID 1531185096-17113-3-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series
  • Higher-level reporting of vectorization problems
Related show

Commit Message

David Malcolm July 10, 2018, 1:11 a.m.
gcc/ChangeLog:
	* tree-vectorizer.c: Include "opt-problem.h".
	(try_vectorize_loop_1): Convert "loop_vinfo" from loop_vec_info to
	opt_loop_vec_info loop_vinfo, and use opt_report to report any
	opt_problem thus captured.  Use opt_report ro report on successful
	loop vectorization.
---
 gcc/tree-vectorizer.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

Patch

diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 8d54fbb..c60d0d9 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -79,6 +79,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "stringpool.h"
 #include "attribs.h"
 #include "gimple-pretty-print.h"
+#include "opt-problem.h"
 
 
 /* Loop or bb location, with hotness information.  */
@@ -705,9 +706,17 @@  try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
 		 LOCATION_FILE (vect_location.get_location_t ()),
 		 LOCATION_LINE (vect_location.get_location_t ()));
 
-  loop_vec_info loop_vinfo = vect_analyze_loop (loop, orig_loop_vinfo, &shared);
+  opt_loop_vec_info loop_vinfo = vect_analyze_loop (loop, orig_loop_vinfo, &shared);
   loop->aux = loop_vinfo;
 
+  if (!loop_vinfo)
+    if (loop_vinfo.get_problem ())
+      {
+	opt_report report;
+	if (report.remark (vect_location, "couldn't vectorize loop"))
+	  loop_vinfo.get_problem ()->report_reason (report);
+      }
+
   if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
     {
       /* Free existing information if loop is analyzed with some
@@ -775,13 +784,26 @@  try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
 
   unsigned HOST_WIDE_INT bytes;
   if (current_vector_size.is_constant (&bytes))
-    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-		     "loop vectorized vectorized using "
+    {
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+		       "loop vectorized vectorized using "
+		       HOST_WIDE_INT_PRINT_UNSIGNED " byte "
+		       "vectors\n", bytes);
+      opt_report report;
+      // FIXME: is this the correct format code?
+      report.remark (vect_location,
+		     "loop vectorized using "
 		     HOST_WIDE_INT_PRINT_UNSIGNED " byte "
-		     "vectors\n", bytes);
+		     "vectors", bytes);
+    }
   else
-    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-		     "loop vectorized using variable length vectors\n");
+    {
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+		       "loop vectorized using variable length vectors\n");
+      opt_report report;
+      report.remark (vect_location,
+		     "loop vectorized using variable length vectors");
+    }
 
   loop_p new_loop = vect_transform_loop (loop_vinfo);
   (*num_vectorized_loops)++;