public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3357] Clean up registering of paths in backwards threader.
@ 2021-09-05  9:48 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-09-05  9:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:cbeeadff4c041c09a6335105d596019b6d583880

commit r12-3357-gcbeeadff4c041c09a6335105d596019b6d583880
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sun Sep 5 09:41:50 2021 +0200

    Clean up registering of paths in backwards threader.
    
    All callers to maybe_register_path() call find_taken_edge() beforehand
    and pass the edge as an argument.  There's no reason to repeat this
    at each call site.
    
    This is a clean-up in preparation for some other enhancements to the
    backwards threader.
    
    Tested on x86-64 Linux.
    
    gcc/ChangeLog:
    
            * tree-ssa-threadbackward.c (back_threader::maybe_register_path):
            Remove argument and call find_taken_edge.
            (back_threader::resolve_phi): Do not calculate taken edge before
            calling maybe_register_path.
            (back_threader::find_paths_to_names): Same.

Diff:
---
 gcc/tree-ssa-threadbackward.c | 44 ++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index 2fa22f8e328..6827d008fb1 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -83,7 +83,7 @@ public:
   bool thread_through_all_blocks (bool may_peel_loop_headers);
 private:
   void find_paths (basic_block bb, tree name);
-  void maybe_register_path (edge taken_edge);
+  edge maybe_register_path ();
   bool find_paths_to_names (basic_block bb, bitmap imports);
   bool resolve_def (tree name, bitmap interesting, vec<tree> &worklist);
   bool resolve_phi (gphi *phi, bitmap imports);
@@ -134,22 +134,31 @@ back_threader::~back_threader ()
 }
 
 // Register the current path for jump threading if it's profitable to
-// do so.  TAKEN_EDGE is the known edge out of the path.
+// do so.
+//
+// Return the known taken edge out of the path, even if the path was
+// not registered, or NULL if the taken edge could not be determined.
 
-void
-back_threader::maybe_register_path (edge taken_edge)
+edge
+back_threader::maybe_register_path ()
 {
-  bool irreducible = false;
-  bool profitable
-    = m_profit.profitable_path_p (m_path, m_name, taken_edge, &irreducible);
+  edge taken_edge = find_taken_edge (m_path);
 
-  if (profitable)
+  if (taken_edge && taken_edge != UNREACHABLE_EDGE)
     {
-      m_registry.register_path (m_path, taken_edge);
+      bool irreducible = false;
+      bool profitable
+	= m_profit.profitable_path_p (m_path, m_name, taken_edge, &irreducible);
+
+      if (profitable)
+	{
+	  m_registry.register_path (m_path, taken_edge);
 
-      if (irreducible)
-	vect_free_loop_info_assumptions (m_path[0]->loop_father);
+	  if (irreducible)
+	    vect_free_loop_info_assumptions (m_path[0]->loop_father);
+	}
     }
+  return taken_edge;
 }
 
 // Return the known taken edge out of a path.  If the path can be
@@ -295,12 +304,9 @@ back_threader::resolve_phi (gphi *phi, bitmap interesting)
       else if (TREE_CODE (arg) == INTEGER_CST)
 	{
 	  m_path.safe_push (e->src);
-	  edge taken_edge = find_taken_edge (m_path);
+	  edge taken_edge = maybe_register_path ();
 	  if (taken_edge && taken_edge != UNREACHABLE_EDGE)
-	    {
-	      maybe_register_path (taken_edge);
-	      done = true;
-	    }
+	    done = true;
 	  m_path.pop ();
 	}
     }
@@ -388,12 +394,8 @@ back_threader::find_paths_to_names (basic_block bb, bitmap interesting)
 	   || bitmap_bit_p (m_ranger.gori ().exports (bb), i))
 	  && m_path.length () > 1)
 	{
-	  edge taken_edge = find_taken_edge (m_path);
-	  if (taken_edge)
+	  if (maybe_register_path ())
 	    {
-	      if (taken_edge != UNREACHABLE_EDGE)
-		maybe_register_path (taken_edge);
-
 	      done = true;
 	      goto leave_bb;
 	    }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-05  9:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-05  9:48 [gcc r12-3357] Clean up registering of paths in backwards threader Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).