From 2ed640ba25474c1a39dad74f8ee7c6c4501e01a2 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 17 May 2018 17:21:54 -0400
Subject: [PATCH 73/83] Add optinfo to a few other passes

---
 gcc/tree-ssa-dce.c  |  6 ++++++
 gcc/tree-ssa-dom.c  | 19 +++++++++++++++++++
 gcc/tree-ssa-dse.c  |  9 +++++++++
 gcc/tree-tailcall.c |  6 ++++++
 4 files changed, 40 insertions(+)

diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 7ec3cc1..7824f05 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -68,6 +68,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-chkp.h"
 #include "tree-ssa-propagate.h"
 #include "gimple-fold.h"
+#include "optinfo.h"
 
 static struct stmt_stats
 {
@@ -1761,6 +1762,11 @@ simple_dce_from_worklist (bitmap worklist)
 	  fprintf (dump_file, "Removing dead stmt:");
 	  print_gimple_stmt (dump_file, t, 0);
 	}
+      /* FIXME */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (t)
+	  << "removing dead stmt: " << t;
+
       gimple_stmt_iterator gsi = gsi_for_stmt (t);
       if (gimple_code (t) == GIMPLE_PHI)
 	remove_phi_node (&gsi, true);
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index a6f176c..2147ac6 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vrp.h"
 #include "vr-values.h"
 #include "gimple-ssa-evrp-analyze.h"
+#include "optinfo.h"
 
 /* This file implements optimizations on the dominator tree.  */
 
@@ -1564,6 +1565,13 @@ eliminate_redundant_computations (gimple_stmt_iterator* gsi,
 	  print_generic_expr (dump_file, cached_lhs, dump_flags);
           fprintf (dump_file, "'\n");
 	}
+      /* FIXME */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (stmt)
+	  << "replaced redundant expr "
+	  << stmt
+	  << " with "
+	  << slim (cached_lhs);
 
       opt_stats.num_re++;
 
@@ -1743,6 +1751,17 @@ cprop_operand (gimple *stmt, use_operand_p op_p)
 	  print_generic_expr (dump_file, val, dump_flags);
 	  fprintf (dump_file, "'\n");
 	}
+#if 0
+      /* FIXME */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (stmt)
+	  << "replaced "
+	  << slim (op)
+	  << optinfo_printf (" with %s ",
+			     (TREE_CODE (val) != SSA_NAME
+			      ? "constant" : "variable"))
+	  << slim (val);
+#endif
 
       if (TREE_CODE (val) != SSA_NAME)
 	opt_stats.num_const_prop++;
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 9220fea..8b58518 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-cfgcleanup.h"
 #include "params.h"
 #include "alias.h"
+#include "optinfo.h"
 
 /* This file implements dead store elimination.
 
@@ -696,6 +697,10 @@ delete_dead_call (gimple_stmt_iterator *gsi)
       print_gimple_stmt (dump_file, stmt, 0, dump_flags);
       fprintf (dump_file, "\n");
     }
+  /* FIXME */
+  if (optinfo_enabled_p ())
+    OPTINFO_SUCCESS (stmt)
+      << "deleted dead call: " << stmt;
 
   tree lhs = gimple_call_lhs (stmt);
   if (lhs)
@@ -730,6 +735,10 @@ delete_dead_assignment (gimple_stmt_iterator *gsi)
       print_gimple_stmt (dump_file, stmt, 0, dump_flags);
       fprintf (dump_file, "\n");
     }
+  /* FIXME */
+  if (optinfo_enabled_p ())
+    OPTINFO_SUCCESS (stmt)
+      << "deleted dead store: " << stmt;
 
   /* Then we need to fix the operand of the consuming stmt.  */
   unlink_stmt_vdef (stmt);
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 9ebed9d..2a072aa 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "common/common-target.h"
 #include "ipa-utils.h"
+#include "optinfo.h"
 
 /* The file implements the tail recursion elimination.  It is also used to
    analyze the tail calls in general, passing the results to the rtl level
@@ -861,6 +862,11 @@ eliminate_tail_call (struct tailcall *t)
       print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
       fprintf (dump_file, "\n");
     }
+  /* FIXME.  */
+  if (optinfo_enabled_p ())
+    OPTINFO_SUCCESS (stmt)
+      << "eliminated tail recursion: "
+      << stmt;
 
   gcc_assert (is_gimple_call (stmt));
 
-- 
1.8.5.3

