public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH 6/8] Make expr_range_in_bb stmt based rather than block based.
Date: Tue, 25 May 2021 19:31:15 -0400	[thread overview]
Message-ID: <c3392b18-b667-a749-ac25-16d36a4d6c75@redhat.com> (raw)

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

First step in moving gori_compute to range_query is to standardize its 
queries to be stmt based rather than block based. gori_compute works 
from the bottom of the block back towards the top, so it always has a 
stmt available for a range_of_expr query, there is no need to use a 
non-standard entry range query.

No functional changes.

Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed.

Andrew


[-- Attachment #2: 0006-Make-expr_range_in_bb-stmt-based-rather-than-block-b.patch --]
[-- Type: text/x-patch, Size: 6917 bytes --]

From 2bccd9154e127909a4cdff5c19904a6562fcd0ff Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Tue, 25 May 2021 14:49:40 -0400
Subject: [PATCH 6/8] Make expr_range_in_bb stmt based rather than block based.

prerequisite to moving to a range_query model, make it stmt based.

	* gimple-range-gori.cc (gori_compute::expr_range_at_stmt): Rename
	from expr_range_in_bb and adjust.
	(gori_compute::compute_name_range_op): Adjust.
	(gori_compute::optimize_logical_operands): Adjust.
	(gori_compute::compute_logical_operands_in_chain): Adjust.
	(gori_compute::compute_operand1_range): Adjust.
	(gori_compute::compute_operand2_range): Adjust.
	(ori_compute_cache::cache_stmt): Adjust.
	* gimple-range-gori.h (gori_compute): Rename prototype.
---
 gcc/gimple-range-gori.cc | 36 ++++++++++++++++++------------------
 gcc/gimple-range-gori.h  |  2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index 94640adc041..1a4ae45c986 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -582,10 +582,10 @@ gori_compute::ssa_range_in_bb (irange &r, tree name, basic_block)
 }
 
 void
-gori_compute::expr_range_in_bb (irange &r, tree expr, basic_block bb)
+gori_compute::expr_range_at_stmt (irange &r, tree expr, gimple *s)
 {
   if (gimple_range_ssa_p (expr))
-    ssa_range_in_bb (r, expr, bb);
+    ssa_range_in_bb (r, expr, gimple_bb (s));
   else
     get_tree_range (r, expr);
 }
@@ -606,7 +606,7 @@ gori_compute::compute_name_range_op (irange &r, gimple *stmt,
   // Operand 1 is the name being looked for, evaluate it.
   if (op1 == name)
     {
-      expr_range_in_bb (op1_range, op1, gimple_bb (stmt));
+      expr_range_at_stmt (op1_range, op1, stmt);
       if (!op2)
 	{
 	  // The second parameter to a unary operation is the range
@@ -616,7 +616,7 @@ gori_compute::compute_name_range_op (irange &r, gimple *stmt,
 	  return gimple_range_calc_op1 (r, stmt, lhs, op1_range);
 	}
       // If we need the second operand, get a value and evaluate.
-      expr_range_in_bb (op2_range, op2, gimple_bb (stmt));
+      expr_range_at_stmt (op2_range, op2, stmt);
       if (gimple_range_calc_op1 (r, stmt, lhs, op2_range))
 	r.intersect (op1_range);
       else
@@ -626,8 +626,8 @@ gori_compute::compute_name_range_op (irange &r, gimple *stmt,
 
   if (op2 == name)
     {
-      expr_range_in_bb (op1_range, op1, gimple_bb (stmt));
-      expr_range_in_bb (r, op2, gimple_bb (stmt));
+      expr_range_at_stmt (op1_range, op1, stmt);
+      expr_range_at_stmt (r, op2, stmt);
       if (gimple_range_calc_op2 (op2_range, stmt, lhs, op1_range))
         r.intersect (op2_range);
       return true;
@@ -877,7 +877,7 @@ gori_compute::optimize_logical_operands (tf_range &range,
     {
       if (!compute_operand_range (range.false_range, SSA_NAME_DEF_STMT (op),
 				  m_bool_zero, name))
-	expr_range_in_bb (range.false_range, name, gimple_bb (stmt));
+	expr_range_at_stmt (range.false_range, name, stmt);
       range.true_range = range.false_range;
       return true;
     }
@@ -886,7 +886,7 @@ gori_compute::optimize_logical_operands (tf_range &range,
     {
       if (!compute_operand_range (range.true_range, SSA_NAME_DEF_STMT (op),
 				  m_bool_one, name))
-	expr_range_in_bb (range.true_range, name, gimple_bb (stmt));
+	expr_range_at_stmt (range.true_range, name, stmt);
       range.false_range = range.true_range;
       return true;
     }
@@ -905,12 +905,12 @@ gori_compute::compute_logical_operands_in_chain (tf_range &range,
 						 tree op, bool op_in_chain)
 {
   gimple *src_stmt = gimple_range_ssa_p (op) ? SSA_NAME_DEF_STMT (op) : NULL;
-  basic_block bb = gimple_bb (stmt);
-  if (!op_in_chain || (src_stmt != NULL && bb != gimple_bb (src_stmt)))
+  if (!op_in_chain || (src_stmt != NULL
+      && gimple_bb (stmt) != gimple_bb (src_stmt)))
     {
       // If op is not in the def chain, or defined in this block,
       // use its known value on entry to the block.
-      expr_range_in_bb (range.true_range, name, gimple_bb (stmt));
+      expr_range_at_stmt (range.true_range, name, stmt);
       range.false_range = range.true_range;
       return;
     }
@@ -920,9 +920,9 @@ gori_compute::compute_logical_operands_in_chain (tf_range &range,
   // Calculate ranges for true and false on both sides, since the false
   // path is not always a simple inversion of the true side.
   if (!compute_operand_range (range.true_range, src_stmt, m_bool_one, name))
-    expr_range_in_bb (range.true_range, name, bb);
+    expr_range_at_stmt (range.true_range, name, stmt);
   if (!compute_operand_range (range.false_range, src_stmt, m_bool_zero, name))
-    expr_range_in_bb (range.false_range, name, bb);
+    expr_range_at_stmt (range.false_range, name, stmt);
 }
 
 // Given a logical STMT, calculate true and false for each potential
@@ -968,12 +968,12 @@ gori_compute::compute_operand1_range (irange &r, gimple *stmt,
   tree op1 = gimple_range_operand1 (stmt);
   tree op2 = gimple_range_operand2 (stmt);
 
-  expr_range_in_bb (op1_range, op1, gimple_bb (stmt));
+  expr_range_at_stmt (op1_range, op1, stmt);
 
   // Now calcuated the operand and put that result in r.
   if (op2)
     {
-      expr_range_in_bb (op2_range, op2, gimple_bb (stmt));
+      expr_range_at_stmt (op2_range, op2, stmt);
       if (!gimple_range_calc_op1 (r, stmt, lhs, op2_range))
 	return false;
     }
@@ -1015,8 +1015,8 @@ gori_compute::compute_operand2_range (irange &r, gimple *stmt,
   tree op1 = gimple_range_operand1 (stmt);
   tree op2 = gimple_range_operand2 (stmt);
 
-  expr_range_in_bb (op1_range, op1, gimple_bb (stmt));
-  expr_range_in_bb (op2_range, op2, gimple_bb (stmt));
+  expr_range_at_stmt (op1_range, op1, stmt);
+  expr_range_at_stmt (op2_range, op2, stmt);
 
   // Intersect with range for op2 based on lhs and op1.
   if (!gimple_range_calc_op2 (r, stmt, lhs, op1_range))
@@ -1449,7 +1449,7 @@ gori_compute_cache::cache_stmt (gimple *stmt)
     {
       range_operator *handler = range_op_handler (code, TREE_TYPE (lhs));
       int_range_max op2_range;
-      expr_range_in_bb (op2_range, op2, gimple_bb (stmt));
+      expr_range_at_stmt (op2_range, op2, stmt);
       tree type = TREE_TYPE (op1);
       handler->op1_range (r_true_side, type, m_bool_one, op2_range);
       handler->op1_range (r_false_side, type, m_bool_zero, op2_range);
diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h
index 8f44216cfcd..8a85d6a2b79 100644
--- a/gcc/gimple-range-gori.h
+++ b/gcc/gimple-range-gori.h
@@ -161,7 +161,7 @@ protected:
   virtual bool compute_operand_range (irange &r, gimple *stmt,
 				      const irange &lhs, tree name);
 
-  void expr_range_in_bb (irange &r, tree expr, basic_block bb);
+  void expr_range_at_stmt (irange &r, tree expr, gimple *s);
   bool compute_logical_operands (irange &r, gimple *stmt,
 				 const irange &lhs,
 				 tree name);
-- 
2.17.2


                 reply	other threads:[~2021-05-25 23:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3392b18-b667-a749-ac25-16d36a4d6c75@redhat.com \
    --to=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).