[COMMITTED] Remove VRP threader.

Message ID 20211107181033.172452-1-aldyh@redhat.com
State Committed
Commit 2be794fae034818a36e097c60adf612f343e24fe
Headers
Series [COMMITTED] Remove VRP threader. |

Commit Message

Aldy Hernandez Nov. 7, 2021, 6:10 p.m. UTC
  Now that things have stabilized, we can remove the old code.

I have left the hybrid threader in tree-ssa-threadedge, even though the
VRP threader was the only user, because we may need it as an interim
step for DOM threading removal.

Tested on x86-64 Linux.

p.s. I tried testing on ppc64le Linux, but it was broken at the time of
testing with:

	/tmp/ccSw6Ajh.s: Assembler messages:
	/tmp/ccSw6Ajh.s:399: Error: unrecognized opcode: `mtvsrws'
	make[3]: *** [printf/quadmath-printf.lo] Error 1

gcc/ChangeLog:

	* tree-pass.h (make_pass_vrp_threader): Remove.
	* tree-ssa-threadbackward.c
	(back_threader_profitability::profitable_path_p): Remove
	ASSERT_EXPR references.
	* tree-ssa-threadedge.c (jt_state::register_equivs_stmt): Same.
	* tree-vrp.c (vrp_folder::simplify_casted_conds): Same.
	(execute_vrp): Same.
	(class hybrid_threader): Remove.
	(hybrid_threader::hybrid_threader): Remove.
	(hybrid_threader::~hybrid_threader): Remove.
	(hybrid_threader::before_dom_children): Remove.
	(hybrid_threader::after_dom_children): Remove.
	(execute_vrp_threader): Remove.
	(class pass_vrp_threader): Remove.
	(make_pass_vrp_threader): Remove.
---
 gcc/tree-pass.h               |   1 -
 gcc/tree-ssa-threadbackward.c |   2 -
 gcc/tree-ssa-threadedge.c     |  12 +--
 gcc/tree-vrp.c                | 137 +---------------------------------
 4 files changed, 5 insertions(+), 147 deletions(-)
  

Patch

diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index e807ad855ef..d494aff1c4c 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -463,7 +463,6 @@  extern gimple_opt_pass *make_pass_copy_prop (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_isolate_erroneous_paths (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_early_vrp (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_vrp (gcc::context *ctxt);
-extern gimple_opt_pass *make_pass_vrp_threader (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_uncprop (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_return_slot (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_reassoc (gcc::context *ctxt);
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index 0085ad01cdc..f9485bf9046 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -710,8 +710,6 @@  back_threader_profitability::profitable_path_p (const vec<basic_block> &m_path,
 		return false;
 	      /* Do not count empty statements and labels.  */
 	      if (gimple_code (stmt) != GIMPLE_NOP
-		  && !(gimple_code (stmt) == GIMPLE_ASSIGN
-		       && gimple_assign_rhs_code (stmt) == ASSERT_EXPR)
 		  && !is_gimple_debug (stmt))
 		n_insns += estimate_num_insns (stmt, &eni_size_weights);
 	    }
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index a63a9764ff8..f693db17064 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -1334,25 +1334,19 @@  jt_state::register_equivs_stmt (gimple *stmt, basic_block bb,
      to expose more context sensitive equivalences which in turn may
      allow us to simplify the condition at the end of the loop.
 
-     Handle simple copy operations as well as implied copies from
-     ASSERT_EXPRs.  */
+     Handle simple copy operations.  */
   tree cached_lhs = NULL;
   if (gimple_assign_single_p (stmt)
       && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
     cached_lhs = gimple_assign_rhs1 (stmt);
-  else if (gimple_assign_single_p (stmt)
-	   && TREE_CODE (gimple_assign_rhs1 (stmt)) == ASSERT_EXPR)
-    cached_lhs = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
   else
     {
-      /* A statement that is not a trivial copy or ASSERT_EXPR.
+      /* A statement that is not a trivial copy.
 	 Try to fold the new expression.  Inserting the
 	 expression into the hash table is unlikely to help.  */
       /* ???  The DOM callback below can be changed to setting
 	 the mprts_hook around the call to thread_across_edge,
-	 avoiding the use substitution.  The VRP hook should be
-	 changed to properly valueize operands itself using
-	 SSA_NAME_VALUE in addition to its own lattice.  */
+	 avoiding the use substitution.  */
       cached_lhs = gimple_fold_stmt_to_constant_1 (stmt,
 						   threadedge_valueize);
       if (NUM_SSA_OPERANDS (stmt, SSA_OP_ALL_USES) != 0
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 5380508a9ec..dd7723629ba 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -43,7 +43,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "tree-scalar-evolution.h"
 #include "tree-ssa-propagate.h"
-#include "tree-ssa-threadedge.h"
 #include "domwalk.h"
 #include "vr-values.h"
 #include "gimple-array-bounds.h"
@@ -3684,9 +3683,7 @@  vrp_asserts::all_imm_uses_in_stmt_or_feed_cond (tree var,
 
    However, by converting the assertion into the implied copy
    operation N_i = N_j, we will then copy-propagate N_j into the uses
-   of N_i and lose the range information.  We may want to hold on to
-   ASSERT_EXPRs a little while longer as the ranges could be used in
-   things like jump threading.
+   of N_i and lose the range information.
 
    The problem with keeping ASSERT_EXPRs around is that passes after
    VRP need to handle them appropriately.
@@ -4121,11 +4118,7 @@  vrp_folder::fold_stmt (gimple_stmt_iterator *si)
 /* A comparison of an SSA_NAME against a constant where the SSA_NAME
    was set by a type conversion can often be rewritten to use the RHS
    of the type conversion.  Do this optimization for all conditionals
-   in FUN.
-
-   However, doing so inhibits jump threading through the comparison.
-   So that transformation is not performed until after jump threading
-   is complete.  */
+   in FUN.  */
 
 void
 vrp_folder::simplify_casted_conds (function *fun)
@@ -4244,9 +4237,6 @@  execute_vrp (struct function *fun, bool warn_array_bounds_p)
 
   free_numbers_of_iterations_estimates (fun);
 
-  /* ASSERT_EXPRs must be removed before finalizing jump threads
-     as finalizing jump threads calls the CFG cleanup code which
-     does not properly handle ASSERT_EXPRs.  */
   assert_engine.remove_range_assertions ();
 
   scev_finalize ();
@@ -4429,126 +4419,3 @@  make_pass_vrp (gcc::context *ctxt)
 {
   return new pass_vrp (ctxt);
 }
-
-// This is the dom walker for the hybrid threader.  The reason this is
-// here, as opposed to the generic threading files, is because the
-// other client would be DOM, and they have their own custom walker.
-
-class hybrid_threader : public dom_walker
-{
-public:
-  hybrid_threader ();
-  ~hybrid_threader ();
-
-  void thread_jumps (function *fun)
-  {
-    walk (fun->cfg->x_entry_block_ptr);
-  }
-  bool thread_through_all_blocks ()
-  {
-    return m_threader->thread_through_all_blocks (false);
-  }
-
-private:
-  edge before_dom_children (basic_block) override;
-  void after_dom_children (basic_block bb) override;
-
-  hybrid_jt_simplifier *m_simplifier;
-  jump_threader *m_threader;
-  jt_state *m_state;
-  gimple_ranger *m_ranger;
-  path_range_query *m_query;
-};
-
-hybrid_threader::hybrid_threader () : dom_walker (CDI_DOMINATORS, REACHABLE_BLOCKS)
-{
-  loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
-  scev_initialize ();
-  calculate_dominance_info (CDI_DOMINATORS);
-  mark_dfs_back_edges ();
-
-  m_ranger = new gimple_ranger;
-  m_query = new path_range_query (*m_ranger, /*resolve=*/true);
-  m_simplifier = new hybrid_jt_simplifier (m_ranger, m_query);
-  m_state = new hybrid_jt_state;
-  m_threader = new jump_threader (m_simplifier, m_state);
-}
-
-hybrid_threader::~hybrid_threader ()
-{
-  delete m_simplifier;
-  delete m_threader;
-  delete m_state;
-  delete m_ranger;
-  delete m_query;
-
-  scev_finalize ();
-  loop_optimizer_finalize ();
-}
-
-edge
-hybrid_threader::before_dom_children (basic_block bb)
-{
-  gimple_stmt_iterator gsi;
-  int_range<2> r;
-
-  for (gsi = gsi_start_nondebug_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-    {
-      gimple *stmt = gsi_stmt (gsi);
-      m_ranger->range_of_stmt (r, stmt);
-    }
-  return NULL;
-}
-
-void
-hybrid_threader::after_dom_children (basic_block bb)
-{
-  m_threader->thread_outgoing_edges (bb);
-}
-
-static unsigned int
-execute_vrp_threader (function *fun)
-{
-  hybrid_threader threader;
-  threader.thread_jumps (fun);
-  if (threader.thread_through_all_blocks ())
-    return (TODO_cleanup_cfg | TODO_update_ssa);
-  return 0;
-}
-
-namespace {
-
-const pass_data pass_data_vrp_threader =
-{
-  GIMPLE_PASS, /* type */
-  "vrp-thread", /* name */
-  OPTGROUP_NONE, /* optinfo_flags */
-  TV_TREE_VRP_THREADER, /* tv_id */
-  PROP_ssa, /* properties_required */
-  0, /* properties_provided */
-  0, /* properties_destroyed */
-  0, /* todo_flags_start */
-  0 /* todo_flags_finish */
-};
-
-class pass_vrp_threader : public gimple_opt_pass
-{
-public:
-  pass_vrp_threader (gcc::context *ctxt)
-    : gimple_opt_pass (pass_data_vrp_threader, ctxt)
-  {}
-
-  /* opt_pass methods: */
-  opt_pass * clone () { return new pass_vrp_threader (m_ctxt); }
-  virtual bool gate (function *) { return flag_tree_vrp != 0; }
-  virtual unsigned int execute (function *fun)
-    { return execute_vrp_threader (fun); }
-};
-
-} // namespace {
-
-gimple_opt_pass *
-make_pass_vrp_threader (gcc::context *ctxt)
-{
-  return new pass_vrp_threader (ctxt);
-}