[gcc(refs/users/aldyh/heads/threader-refactor)] wip wip

Aldy Hernandez aldyh@gcc.gnu.org
Wed Nov 25 14:50:27 GMT 2020


https://gcc.gnu.org/g:8b46a2353faf463ff735302bac5b91149dd6875f

commit 8b46a2353faf463ff735302bac5b91149dd6875f
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Nov 24 11:15:38 2020 +0100

    wip wip

Diff:
---
 gcc/tree-ssa-dom.c        |  7 +++----
 gcc/tree-ssa-threadedge.c | 18 +++++++++++++++---
 gcc/tree-ssa-threadedge.h |  8 +++++---
 gcc/tree-vrp.c            | 25 +++++++++++--------------
 4 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 54bd5525d2b..718eb3c2aca 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -722,8 +722,7 @@ pass_dominator::execute (function *fun)
     record_edge_info (bb);
 
   /* Recursively walk the dominator tree optimizing statements.  */
-  jump_thread_path_registry registry;
-  jump_threader threader (&registry, const_and_copies, avail_exprs_stack);
+  jump_threader threader (const_and_copies, avail_exprs_stack);
   dom_opt_dom_walker walker (CDI_DOMINATORS,
 			     &threader,
 			     const_and_copies,
@@ -756,7 +755,7 @@ pass_dominator::execute (function *fun)
 	     containing any edge leaving BB.  */
 	  if (found)
 	    FOR_EACH_EDGE (e, ei, bb->succs)
-	      registry.remove_jump_threads_including (e);
+	      threader.remove_jump_threads_including (e);
 	}
     }
 
@@ -780,7 +779,7 @@ pass_dominator::execute (function *fun)
   free_all_edge_infos ();
 
   /* Thread jumps, creating duplicate blocks as needed.  */
-  cfg_altered |= registry.thread_through_all_blocks (may_peel_loop_headers_p);
+  cfg_altered |= threader.thread_through_all_blocks (may_peel_loop_headers_p);
 
   if (cfg_altered)
     free_dominance_info (CDI_DOMINATORS);
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index a2890b984d0..bbb66e03747 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -61,8 +61,7 @@ set_ssa_name_value (tree name, tree value)
   ssa_name_values[SSA_NAME_VERSION (name)] = value;
 }
 
-jump_threader::jump_threader (jump_thread_path_registry *registry,
-			      const_and_copies *copies,
+jump_threader::jump_threader (const_and_copies *copies,
 			      avail_exprs_stack *avails)
 {
   /* Initialize the per SSA_NAME value-handles array.  */
@@ -74,12 +73,25 @@ jump_threader::jump_threader (jump_thread_path_registry *registry,
 
   m_const_and_copies = copies;
   m_avail_exprs_stack = avails;
-  m_registry = registry;
+  m_registry = new jump_thread_path_registry ();
 }
 
 jump_threader::~jump_threader (void)
 {
   ssa_name_values.release ();
+  delete m_registry;
+}
+
+void
+jump_threader::remove_jump_threads_including (edge_def *e)
+{
+  m_registry->remove_jump_threads_including (e);
+}
+
+bool
+jump_threader::thread_through_all_blocks (bool may_peel_loop_headers)
+{
+  return m_registry->thread_through_all_blocks (may_peel_loop_headers);
 }
 
 /* Return TRUE if we may be able to thread an incoming edge into
diff --git a/gcc/tree-ssa-threadedge.h b/gcc/tree-ssa-threadedge.h
index da628a4f51d..636a07b814e 100644
--- a/gcc/tree-ssa-threadedge.h
+++ b/gcc/tree-ssa-threadedge.h
@@ -31,13 +31,15 @@ class evrp_range_analyzer;
 class jump_threader
 {
 public:
-  jump_threader (jump_thread_path_registry *,
-		 const_and_copies *,
-		 avail_exprs_stack *);
+  jump_threader (const_and_copies *, avail_exprs_stack *);
   ~jump_threader ();
   void thread_outgoing_edges (basic_block,
 			      evrp_range_analyzer *,
 			      jump_threader_simplifier &);
+  // ?? Temporary convenience functions that call through the
+  // registry.  This avoids having to expose the registry.
+  void remove_jump_threads_including (edge_def *);
+  bool thread_through_all_blocks (bool may_peel_loop_headers);
 
 private:
   tree simplify_control_stmt_condition (edge, gimple *,
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 3798b27a86a..214aa86d889 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4175,7 +4175,7 @@ vrp_folder::fold_stmt (gimple_stmt_iterator *si)
 class vrp_jump_threader : public dom_walker
 {
 public:
-  vrp_jump_threader (function *, vr_values *, jump_thread_path_registry *);
+  vrp_jump_threader (function *, vr_values *);
   ~vrp_jump_threader ();
 
   void thread_jumps ()
@@ -4183,6 +4183,12 @@ public:
     walk (m_fun->cfg->x_entry_block_ptr);
   }
 
+  void thread_through_all_blocks ()
+  {
+    // FIXME: Put this in the destructor?
+    m_threader->thread_through_all_blocks (false);
+  }
+
 private:
   virtual edge before_dom_children (basic_block);
   virtual void after_dom_children (basic_block);
@@ -4195,9 +4201,7 @@ private:
   jump_threader *m_threader;
 };
 
-vrp_jump_threader::vrp_jump_threader (struct function *fun,
-				      vr_values *v,
-				      jump_thread_path_registry *registry)
+vrp_jump_threader::vrp_jump_threader (struct function *fun, vr_values *v)
   : dom_walker (CDI_DOMINATORS, REACHABLE_BLOCKS)
 {
   /* Ugh.  When substituting values earlier in this pass we can wipe
@@ -4221,9 +4225,7 @@ vrp_jump_threader::vrp_jump_threader (struct function *fun,
   m_avail_exprs = new hash_table<expr_elt_hasher> (1024);
   m_avail_exprs_stack = new avail_exprs_stack (m_avail_exprs);
 
-  m_threader = new jump_threader (registry,
-				  m_const_and_copies,
-				  m_avail_exprs_stack);
+  m_threader = new jump_threader (m_const_and_copies, m_avail_exprs_stack);
 }
 
 vrp_jump_threader::~vrp_jump_threader ()
@@ -4492,8 +4494,7 @@ execute_vrp (struct function *fun, bool warn_array_bounds_p)
 
   /* We must identify jump threading opportunities before we release
      the datastructures built by VRP.  */
-  jump_thread_path_registry registry;
-  vrp_jump_threader threader (fun, &vrp_vr_values, &registry);
+  vrp_jump_threader threader (fun, &vrp_vr_values);
   threader.thread_jumps ();
 
   /* A comparison of an SSA_NAME against a constant where the SSA_NAME
@@ -4532,11 +4533,7 @@ execute_vrp (struct function *fun, bool warn_array_bounds_p)
 
      Note the SSA graph update will occur during the normal TODO
      processing by the pass manager.  */
-  // FIXME: the registry could be put in vrp_jump_threader and have
-  // its destructor call thread_through_all_blocks.  This would cause
-  // thread_through_all_blocks to happen after scev_finalize and
-  // loop_optimizer_finalize below.  Is this ok?
-  registry.thread_through_all_blocks (false);
+  threader.thread_through_all_blocks ();
 
   scev_finalize ();
   loop_optimizer_finalize ();


More information about the Gcc-cvs mailing list