public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] - Add BB option for outgoing_edge_range_p.
@ 2021-12-03 20:39 Andrew MacLeod
  2021-12-06  7:21 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew MacLeod @ 2021-12-03 20:39 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

has_edge_range_p() and may_recompute_p() currently only take an optional 
edge as a parameter.  They only indicate if a range *might* be 
calculated for a name, but they do not do any calculations.

To determine the results, they always consult the exports for the 
edge->src block. the value is true or false for every edge, so its 
really a basic block property.  This patch makes the option available to 
consult directly with the BB, and calls that for the edge version.

Without this, if you want to know if a basic block can affect a range, 
you have to pick an arbitrary outgoing edge and ask with that.. which 
seems a little awkward.

This patch is used by the next one.

Bootstrapped on  x86_64-pc-linux-gnu with no regressions. OK?

Andrew

[-- Attachment #2: 0001-Add-BB-option-for-outgoing_edge_range_p-and-may_reoc.patch --]
[-- Type: text/x-patch, Size: 4922 bytes --]

From cfe5cdcace399a8e615e103022140359790b3c8b Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Fri, 3 Dec 2021 10:51:18 -0500
Subject: [PATCH 1/2] Add BB option for outgoing_edge_range_p and
 may_reocmpute_p.

There are times we only need to know if any edge from a block can calculate
a range.

	* gimple-range-gori.h (class gori_compute):: Add prototypes.
	* gimple-range-gori.cc (gori_compute::has_edge_range_p): Add alternate
	API for basic block.  Call for edge alterantive.
	(gori_compute::may_recompute_p): Ditto.
---
 gcc/gimple-range-gori.cc | 74 +++++++++++++++++++++++++---------------
 gcc/gimple-range-gori.h  |  6 ++--
 2 files changed, 51 insertions(+), 29 deletions(-)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index 0dba34b58c5..6c17267ad37 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -1166,33 +1166,12 @@ gori_compute::compute_operand1_and_operand2_range (irange &r,
   r.intersect (op_range);
   return true;
 }
-// Return TRUE if a range can be calculated or recomputed for NAME on edge E.
-
-bool
-gori_compute::has_edge_range_p (tree name, edge e)
-{
-  // Check if NAME is an export or can be recomputed.
-  if (e)
-    return is_export_p (name, e->src) || may_recompute_p (name, e);
-
-  // If no edge is specified, check if NAME can have a range calculated
-  // on any edge.
-  return is_export_p (name) || may_recompute_p (name);
-}
-
-// Dump what is known to GORI computes to listing file F.
-
-void
-gori_compute::dump (FILE *f)
-{
-  gori_map::dump (f);
-}
 
-// Return TRUE if NAME can be recomputed on edge E.  If any direct dependant
-// is exported on edge E, it may change the computed value of NAME.
+// Return TRUE if NAME can be recomputed on any edge exiting BB.  If any
+// direct dependant is exported, it may also change the computed value of NAME.
 
 bool
-gori_compute::may_recompute_p (tree name, edge e)
+gori_compute::may_recompute_p (tree name, basic_block bb)
 {
   tree dep1 = depend1 (name);
   tree dep2 = depend2 (name);
@@ -1207,13 +1186,47 @@ gori_compute::may_recompute_p (tree name, edge e)
     return false;
 
   // If edge is specified, check if NAME can be recalculated on that edge.
-  if (e)
-    return ((is_export_p (dep1, e->src))
-	    || (dep2 && is_export_p (dep2, e->src)));
+  if (bb)
+    return ((is_export_p (dep1, bb))
+	    || (dep2 && is_export_p (dep2, bb)));
 
   return (is_export_p (dep1)) || (dep2 && is_export_p (dep2));
 }
 
+// Return TRUE if NAME can be recomputed on edge E.  If any direct dependant
+// is exported on edge E, it may change the computed value of NAME.
+
+bool
+gori_compute::may_recompute_p (tree name, edge e)
+{
+  gcc_checking_assert (e);
+  return may_recompute_p (name, e->src);
+}
+
+
+// Return TRUE if a range can be calculated or recomputed for NAME on any
+// edge exiting BB.
+
+bool
+gori_compute::has_edge_range_p (tree name, basic_block bb)
+{
+  // Check if NAME is an export or can be recomputed.
+  if (bb)
+    return is_export_p (name, bb) || may_recompute_p (name, bb);
+
+  // If no block is specified, check for anywhere in the IL.
+  return is_export_p (name) || may_recompute_p (name);
+}
+
+// Return TRUE if a range can be calculated or recomputed for NAME on edge E.
+
+bool
+gori_compute::has_edge_range_p (tree name, edge e)
+{
+  gcc_checking_assert (e);
+  return has_edge_range_p (name, e->src);
+}
+
 // Calculate a range on edge E and return it in R.  Try to evaluate a
 // range for NAME on this edge.  Return FALSE if this is either not a
 // control edge or NAME is not defined by this edge.
@@ -1287,6 +1300,13 @@ gori_compute::outgoing_edge_range_p (irange &r, edge e, tree name,
   return false;
 }
 
+// Dump what is known to GORI computes to listing file F.
+
+void
+gori_compute::dump (FILE *f)
+{
+  gori_map::dump (f);
+}
 
 // ------------------------------------------------------------------------
 //  GORI iterator.  Although we have bitmap iterators, don't expose that it
diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h
index ec0b95145f0..b15497e9f59 100644
--- a/gcc/gimple-range-gori.h
+++ b/gcc/gimple-range-gori.h
@@ -158,10 +158,12 @@ class gori_compute : public gori_map
 public:
   gori_compute (int not_executable_flag = 0);
   bool outgoing_edge_range_p (irange &r, edge e, tree name, range_query &q);
-  bool has_edge_range_p (tree name, edge e = NULL);
+  bool has_edge_range_p (tree name, basic_block bb = NULL);
+  bool has_edge_range_p (tree name, edge e);
   void dump (FILE *f);
 private:
-  bool may_recompute_p (tree name, edge e = NULL);
+  bool may_recompute_p (tree name, edge e);
+  bool may_recompute_p (tree name, basic_block bb = NULL);
   bool compute_operand_range (irange &r, gimple *stmt, const irange &lhs,
 			      tree name, class fur_source &src);
   bool compute_operand_range_switch (irange &r, gswitch *s, const irange &lhs,
-- 
2.17.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] - Add BB option for outgoing_edge_range_p.
  2021-12-03 20:39 [PATCH 1/2] - Add BB option for outgoing_edge_range_p Andrew MacLeod
@ 2021-12-06  7:21 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-12-06  7:21 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: gcc-patches

On Fri, Dec 3, 2021 at 9:41 PM Andrew MacLeod via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> has_edge_range_p() and may_recompute_p() currently only take an optional
> edge as a parameter.  They only indicate if a range *might* be
> calculated for a name, but they do not do any calculations.
>
> To determine the results, they always consult the exports for the
> edge->src block. the value is true or false for every edge, so its
> really a basic block property.  This patch makes the option available to
> consult directly with the BB, and calls that for the edge version.
>
> Without this, if you want to know if a basic block can affect a range,
> you have to pick an arbitrary outgoing edge and ask with that.. which
> seems a little awkward.
>
> This patch is used by the next one.
>
> Bootstrapped on  x86_64-pc-linux-gnu with no regressions. OK?

OK.

>
> Andrew

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-06  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 20:39 [PATCH 1/2] - Add BB option for outgoing_edge_range_p Andrew MacLeod
2021-12-06  7:21 ` Richard Biener

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