public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Tame path_range_query::compute_imports
@ 2022-08-11 11:42 Richard Biener
  0 siblings, 0 replies; 22+ messages in thread
From: Richard Biener @ 2022-08-11 11:42 UTC (permalink / raw)
  To: gcc-patches

This avoids going BBs outside of the path when adding def chains
to the set of imports.  It also syncs the code with
range_def_chain::get_def_chain to not miss out on some imports
this function would identify.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

The question still stands on what the path_range_query::compute_ranges
actually needs in its m_imports - at least I don't easily see how
the range-folds will use the path range cache or be path sensitive
at all.

OK?

Thanks,
Richard.

	* gimple-range-path.cc (path_range_query::compute_imports):
	Restrict walking SSA defs to blocks inside the path.  Track
	the same operands as range_def_chain::get_def_chain does.
---
 gcc/gimple-range-path.cc | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 5ae374df3a2..5ff2c733b4e 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -575,18 +575,11 @@ path_range_query::compute_imports (bitmap imports, const vec<basic_block> &path)
     {
       tree name = worklist.pop ();
       gimple *def_stmt = SSA_NAME_DEF_STMT (name);
+      if (SSA_NAME_IS_DEFAULT_DEF (name)
+	  || !path.contains (gimple_bb (def_stmt)))
+	continue;
 
-      if (is_gimple_assign (def_stmt))
-	{
-	  add_to_imports (gimple_assign_rhs1 (def_stmt), imports);
-	  tree rhs = gimple_assign_rhs2 (def_stmt);
-	  if (rhs && add_to_imports (rhs, imports))
-	    worklist.safe_push (rhs);
-	  rhs = gimple_assign_rhs3 (def_stmt);
-	  if (rhs && add_to_imports (rhs, imports))
-	    worklist.safe_push (rhs);
-	}
-      else if (gphi *phi = dyn_cast <gphi *> (def_stmt))
+      if (gphi *phi = dyn_cast <gphi *> (def_stmt))
 	{
 	  for (size_t i = 0; i < gimple_phi_num_args (phi); ++i)
 	    {
@@ -599,6 +592,30 @@ path_range_query::compute_imports (bitmap imports, const vec<basic_block> &path)
 		worklist.safe_push (arg);
 	    }
 	}
+      else if (gassign *ass = dyn_cast <gassign *> (def_stmt))
+	{
+	  tree ssa[3];
+	  if (range_op_handler (ass))
+	    {
+	      ssa[0] = gimple_range_ssa_p (gimple_range_operand1 (ass));
+	      ssa[1] = gimple_range_ssa_p (gimple_range_operand2 (ass));
+	      ssa[2] = NULL_TREE;
+	    }
+	  else if (gimple_assign_rhs_code (ass) == COND_EXPR)
+	    {
+	      ssa[0] = gimple_range_ssa_p (gimple_assign_rhs1 (ass));
+	      ssa[1] = gimple_range_ssa_p (gimple_assign_rhs2 (ass));
+	      ssa[2] = gimple_range_ssa_p (gimple_assign_rhs3 (ass));
+	    }
+	  else
+	    continue;
+	  for (unsigned j = 0; j < 3; ++j)
+	    {
+	      tree rhs = ssa[j];
+	      if (rhs && add_to_imports (rhs, imports))
+		worklist.safe_push (rhs);
+	    }
+	}
     }
   // Exported booleans along the path, may help conditionals.
   if (m_resolve)
-- 
2.35.3

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH] Tame path_range_query::compute_imports
@ 2022-08-11 11:42 Richard Biener
  0 siblings, 0 replies; 22+ messages in thread
From: Richard Biener @ 2022-08-11 11:42 UTC (permalink / raw)
  To: gcc-patches

This avoids going BBs outside of the path when adding def chains
to the set of imports.  It also syncs the code with
range_def_chain::get_def_chain to not miss out on some imports
this function would identify.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

The question still stands on what the path_range_query::compute_ranges
actually needs in its m_imports - at least I don't easily see how
the range-folds will use the path range cache or be path sensitive
at all.

OK?

Thanks,
Richard.

	* gimple-range-path.cc (path_range_query::compute_imports):
	Restrict walking SSA defs to blocks inside the path.  Track
	the same operands as range_def_chain::get_def_chain does.
---
 gcc/gimple-range-path.cc | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 5ae374df3a2..5ff2c733b4e 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -575,18 +575,11 @@ path_range_query::compute_imports (bitmap imports, const vec<basic_block> &path)
     {
       tree name = worklist.pop ();
       gimple *def_stmt = SSA_NAME_DEF_STMT (name);
+      if (SSA_NAME_IS_DEFAULT_DEF (name)
+	  || !path.contains (gimple_bb (def_stmt)))
+	continue;
 
-      if (is_gimple_assign (def_stmt))
-	{
-	  add_to_imports (gimple_assign_rhs1 (def_stmt), imports);
-	  tree rhs = gimple_assign_rhs2 (def_stmt);
-	  if (rhs && add_to_imports (rhs, imports))
-	    worklist.safe_push (rhs);
-	  rhs = gimple_assign_rhs3 (def_stmt);
-	  if (rhs && add_to_imports (rhs, imports))
-	    worklist.safe_push (rhs);
-	}
-      else if (gphi *phi = dyn_cast <gphi *> (def_stmt))
+      if (gphi *phi = dyn_cast <gphi *> (def_stmt))
 	{
 	  for (size_t i = 0; i < gimple_phi_num_args (phi); ++i)
 	    {
@@ -599,6 +592,30 @@ path_range_query::compute_imports (bitmap imports, const vec<basic_block> &path)
 		worklist.safe_push (arg);
 	    }
 	}
+      else if (gassign *ass = dyn_cast <gassign *> (def_stmt))
+	{
+	  tree ssa[3];
+	  if (range_op_handler (ass))
+	    {
+	      ssa[0] = gimple_range_ssa_p (gimple_range_operand1 (ass));
+	      ssa[1] = gimple_range_ssa_p (gimple_range_operand2 (ass));
+	      ssa[2] = NULL_TREE;
+	    }
+	  else if (gimple_assign_rhs_code (ass) == COND_EXPR)
+	    {
+	      ssa[0] = gimple_range_ssa_p (gimple_assign_rhs1 (ass));
+	      ssa[1] = gimple_range_ssa_p (gimple_assign_rhs2 (ass));
+	      ssa[2] = gimple_range_ssa_p (gimple_assign_rhs3 (ass));
+	    }
+	  else
+	    continue;
+	  for (unsigned j = 0; j < 3; ++j)
+	    {
+	      tree rhs = ssa[j];
+	      if (rhs && add_to_imports (rhs, imports))
+		worklist.safe_push (rhs);
+	    }
+	}
     }
   // Exported booleans along the path, may help conditionals.
   if (m_resolve)
-- 
2.35.3

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH] Tame path_range_query::compute_imports
@ 2022-08-11 11:42 Richard Biener
  0 siblings, 0 replies; 22+ messages in thread
From: Richard Biener @ 2022-08-11 11:42 UTC (permalink / raw)
  To: gcc-patches

This avoids going BBs outside of the path when adding def chains
to the set of imports.  It also syncs the code with
range_def_chain::get_def_chain to not miss out on some imports
this function would identify.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

The question still stands on what the path_range_query::compute_ranges
actually needs in its m_imports - at least I don't easily see how
the range-folds will use the path range cache or be path sensitive
at all.

OK?

Thanks,
Richard.

	* gimple-range-path.cc (path_range_query::compute_imports):
	Restrict walking SSA defs to blocks inside the path.  Track
	the same operands as range_def_chain::get_def_chain does.
---
 gcc/gimple-range-path.cc | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 5ae374df3a2..5ff2c733b4e 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -575,18 +575,11 @@ path_range_query::compute_imports (bitmap imports, const vec<basic_block> &path)
     {
       tree name = worklist.pop ();
       gimple *def_stmt = SSA_NAME_DEF_STMT (name);
+      if (SSA_NAME_IS_DEFAULT_DEF (name)
+	  || !path.contains (gimple_bb (def_stmt)))
+	continue;
 
-      if (is_gimple_assign (def_stmt))
-	{
-	  add_to_imports (gimple_assign_rhs1 (def_stmt), imports);
-	  tree rhs = gimple_assign_rhs2 (def_stmt);
-	  if (rhs && add_to_imports (rhs, imports))
-	    worklist.safe_push (rhs);
-	  rhs = gimple_assign_rhs3 (def_stmt);
-	  if (rhs && add_to_imports (rhs, imports))
-	    worklist.safe_push (rhs);
-	}
-      else if (gphi *phi = dyn_cast <gphi *> (def_stmt))
+      if (gphi *phi = dyn_cast <gphi *> (def_stmt))
 	{
 	  for (size_t i = 0; i < gimple_phi_num_args (phi); ++i)
 	    {
@@ -599,6 +592,30 @@ path_range_query::compute_imports (bitmap imports, const vec<basic_block> &path)
 		worklist.safe_push (arg);
 	    }
 	}
+      else if (gassign *ass = dyn_cast <gassign *> (def_stmt))
+	{
+	  tree ssa[3];
+	  if (range_op_handler (ass))
+	    {
+	      ssa[0] = gimple_range_ssa_p (gimple_range_operand1 (ass));
+	      ssa[1] = gimple_range_ssa_p (gimple_range_operand2 (ass));
+	      ssa[2] = NULL_TREE;
+	    }
+	  else if (gimple_assign_rhs_code (ass) == COND_EXPR)
+	    {
+	      ssa[0] = gimple_range_ssa_p (gimple_assign_rhs1 (ass));
+	      ssa[1] = gimple_range_ssa_p (gimple_assign_rhs2 (ass));
+	      ssa[2] = gimple_range_ssa_p (gimple_assign_rhs3 (ass));
+	    }
+	  else
+	    continue;
+	  for (unsigned j = 0; j < 3; ++j)
+	    {
+	      tree rhs = ssa[j];
+	      if (rhs && add_to_imports (rhs, imports))
+		worklist.safe_push (rhs);
+	    }
+	}
     }
   // Exported booleans along the path, may help conditionals.
   if (m_resolve)
-- 
2.35.3

^ permalink raw reply	[flat|nested] 22+ messages in thread
[parent not found: <73820.122081107421800679@us-mta-533.us.mimecast.lan>]

end of thread, other threads:[~2022-08-16 13:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11 11:42 [PATCH] Tame path_range_query::compute_imports Richard Biener
2022-08-11 11:42 Richard Biener
2022-08-11 11:42 Richard Biener
     [not found] <73820.122081107421800679@us-mta-533.us.mimecast.lan>
2022-08-11 13:11 ` Aldy Hernandez
2022-08-11 13:59 ` Andrew MacLeod
2022-08-11 15:11   ` Aldy Hernandez
2022-08-15  9:53     ` Richard Biener
2022-08-16  8:56       ` Aldy Hernandez
2022-08-16  9:28         ` Richard Biener
2022-08-16 10:25       ` Aldy Hernandez
2022-08-16 11:38         ` Richard Biener
2022-08-16 12:17           ` Aldy Hernandez
2022-08-16 12:26             ` Richard Biener
2022-08-16 12:32               ` Aldy Hernandez
2022-08-16 13:47         ` Andrew MacLeod
2022-08-16 13:55           ` Aldy Hernandez
2022-08-16  8:21 ` Aldy Hernandez
2022-08-16  8:32   ` Richard Biener
2022-08-16  9:08     ` Aldy Hernandez
2022-08-16  9:15       ` Aldy Hernandez
2022-08-16  9:28         ` Richard Biener
2022-08-16 13:42           ` Andrew MacLeod

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).