From 0e0e79d1acf82d1516f3dbc1d7b8a7737ea905bc Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 25 Jul 2018 20:09:28 -0400
Subject: [PATCH 36/68] FIXME: more on rich hints

---
 gcc/optinfo-emit-json.cc   |  6 ++++++
 gcc/tree-vect-hints.cc     | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 gcc/tree-vect-loop-manip.c |  2 ++
 3 files changed, 61 insertions(+)

diff --git a/gcc/optinfo-emit-json.cc b/gcc/optinfo-emit-json.cc
index fab1c5c..b9ee35f 100644
--- a/gcc/optinfo-emit-json.cc
+++ b/gcc/optinfo-emit-json.cc
@@ -106,6 +106,7 @@ optrecord_json_writer::optrecord_json_writer ()
   json::array *passes = new json::array ();
   m_root_tuple->append (passes);
 
+#if 1
   /* Call add_pass_list for all of the pass lists.  */
   {
 #define DEF_PASS_LIST(LIST) \
@@ -113,6 +114,7 @@ optrecord_json_writer::optrecord_json_writer ()
     GCC_PASS_LISTS
 #undef DEF_PASS_LIST
   }
+#endif
 
   json::array *records = new json::array ();
   m_root_tuple->append (records);
@@ -155,6 +157,7 @@ optrecord_json_writer::add_record (const optinfo *optinfo)
 
   add_record (obj);
 
+#if 0
   /* Potentially push the scope.  */
   if (optinfo->get_kind () == OPTINFO_KIND_SCOPE)
     {
@@ -162,6 +165,7 @@ optrecord_json_writer::add_record (const optinfo *optinfo)
       obj->set ("children", children);
       m_scopes.safe_push (children);
     }
+#endif
 }
 
 /* Private methods of optrecord_json_writer.  */
@@ -511,7 +515,9 @@ optimization_records_maybe_record_optinfo (const optinfo *optinfo)
   if (!the_json_writer)
     return;
 
+#if 0
   the_json_writer->add_record (optinfo);
+#endif
 }
 
 /* Handling for the end of a dump scope for the
diff --git a/gcc/tree-vect-hints.cc b/gcc/tree-vect-hints.cc
index ac9f253..af79560 100644
--- a/gcc/tree-vect-hints.cc
+++ b/gcc/tree-vect-hints.cc
@@ -461,12 +461,65 @@ test_make_diagram ()
      "                                   |\n");
 }
 
+/* Experiments with visualization of SIMD operations.  */
+
+static void
+test_simd_visualization ()
+{
+#if 0
+  int num_elements = 4;
+  int size_of_element = 4;
+  const char *type = "int32";
+  grid_layout *grid_vector_type = new grid_layout (num_elements, 3);
+
+  /* The dots represent the byte count.  */
+  pretty_printer pp_size;
+  pp_character (&pp_size, '[');
+  for (int i = 0; i < size_of_element; i++)
+    pp_character (&pp_size, '.');
+  pp_character (&pp_size, ']');
+
+  for (int i = 0; i < num_elements; i++)
+    {
+      grid_vector_type->set_child (i, 0,
+				   new text_element (type));
+      grid_vector_type->set_child (i, 1,
+				   new text_element (pp_formatted_text (&pp_size)));
+      pretty_printer pp;
+      pp_printf (&pp, "a[i + %i]", i);
+      grid_vector_type->set_child (i, 2,
+				   new text_element (pp_formatted_text (&pp)));
+    }
+#if 0
+  for (int i = 0; i < num_elements; i++)
+    {
+      grid_vector_type->set_child (1, i + 1)
+	= new text_element (":");
+      grid_vector_type->set_child (i + 2, i + 1)
+	= new text_element (" ^~~ "); // FIXME length of underline should match that of type
+    }
+#endif
+
+  ASSERT_ELEMENT_PRINT (grid_vector_type, "FIXME");
+  delete grid_vector_type;
+
+#if 0
+          [int] [int] [int] [int]
+  i + 0 :  ^~~
+  i + 1 :        ^~~
+  i + 2 :              ^~~
+  i + 3 :                    ^~~
+#endif
+#endif
+}
+
 /* Run all of the selftests within this file.  */
 
 void
 tree_vect_hints_cc_tests ()
 {
   test_make_diagram ();
+  test_simd_visualization ();
 }
 
 } // namespace selftest
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 01d1850..ca64e7d 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -3010,6 +3010,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
   if (version_align)
     vect_create_cond_for_align_checks (loop_vinfo, &cond_expr,
 				       &cond_expr_stmt_list);
+  // FIXME: "I had to create a run-time check for alignment"
 
   if (version_alias)
     {
@@ -3017,6 +3018,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
       vect_create_cond_for_lower_bounds (loop_vinfo, &cond_expr);
       vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr);
     }
+  // FIXME: "I had to create a run-time check for aliasing"
 
   cond_expr = force_gimple_operand_1 (unshare_expr (cond_expr),
 				      &gimplify_stmt_list,
-- 
1.8.5.3

