public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>, Aldy Hernandez <aldyh@redhat.com>
Subject: [COMMITTED 12/16] Make some integer specific ranges generic Value_Range's.
Date: Sun, 28 Apr 2024 21:05:50 +0200	[thread overview]
Message-ID: <20240428190557.1209586-13-aldyh@redhat.com> (raw)
In-Reply-To: <20240428190557.1209586-1-aldyh@redhat.com>

There are some irange uses that should be Value_Range, because they
can be either integers or pointers.  This will become a problem when
prange comes live.

gcc/ChangeLog:

	* tree-ssa-loop-split.cc (split_at_bb_p): Make int_range a Value_Range.
	* tree-ssa-strlen.cc (get_range): Same.
	* value-query.cc (range_query::get_tree_range):  Handle both
	integers and pointers.
	* vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Make
	r0 and r1 Value_Range's.
---
 gcc/tree-ssa-loop-split.cc | 6 +++---
 gcc/tree-ssa-strlen.cc     | 2 +-
 gcc/value-query.cc         | 4 +---
 gcc/vr-values.cc           | 3 ++-
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc
index a770ea371a2..a6be0cef7b0 100644
--- a/gcc/tree-ssa-loop-split.cc
+++ b/gcc/tree-ssa-loop-split.cc
@@ -144,18 +144,18 @@ split_at_bb_p (class loop *loop, basic_block bb, tree *border, affine_iv *iv,
 	   value range.  */
 	else
 	  {
-	    int_range<2> r;
+	    Value_Range r (TREE_TYPE (op0));
 	    get_global_range_query ()->range_of_expr (r, op0, stmt);
 	    if (!r.varying_p () && !r.undefined_p ()
 		&& TREE_CODE (op1) == INTEGER_CST)
 	      {
 		wide_int val = wi::to_wide (op1);
-		if (known_eq (val, r.lower_bound ()))
+		if (known_eq (val, wi::to_wide (r.lbound ())))
 		  {
 		    code = (code == EQ_EXPR) ? LE_EXPR : GT_EXPR;
 		    break;
 		  }
-		else if (known_eq (val, r.upper_bound ()))
+		else if (known_eq (val, wi::to_wide (r.ubound ())))
 		  {
 		    code = (code == EQ_EXPR) ? GE_EXPR : LT_EXPR;
 		    break;
diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index e09c9cc081f..61c3da22322 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -215,7 +215,7 @@ get_range (tree val, gimple *stmt, wide_int minmax[2],
       rvals = get_range_query (cfun);
     }
 
-  value_range vr;
+  Value_Range vr (TREE_TYPE (val));
   if (!rvals->range_of_expr (vr, val, stmt))
     return NULL_TREE;
 
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index eda71dc89d3..052b7511565 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -156,11 +156,9 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt)
     {
     case INTEGER_CST:
       {
-	irange &i = as_a <irange> (r);
 	if (TREE_OVERFLOW_P (expr))
 	  expr = drop_tree_overflow (expr);
-	wide_int w = wi::to_wide (expr);
-	i.set (TREE_TYPE (expr), w, w);
+	r.set (expr, expr);
 	return true;
       }
 
diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index ff68d40c355..0572bf6c8c7 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -310,7 +310,8 @@ tree
 simplify_using_ranges::fold_cond_with_ops (enum tree_code code,
 					   tree op0, tree op1, gimple *s)
 {
-  int_range_max r0, r1;
+  Value_Range r0 (TREE_TYPE (op0));
+  Value_Range r1 (TREE_TYPE (op1));
   if (!query->range_of_expr (r0, op0, s)
       || !query->range_of_expr (r1, op1, s))
     return NULL_TREE;
-- 
2.44.0


  parent reply	other threads:[~2024-04-28 19:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-28 19:05 [PATCH 00/16] prange supporting patchset Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 01/16] Make vrange an abstract class Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 02/16] Add a virtual vrange destructor Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 03/16] Make some Value_Range's explicitly integer Aldy Hernandez
2024-04-30  7:46   ` Richard Biener
2024-04-30  8:38     ` Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 04/16] Add tree versions of lower and upper bounds to vrange Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 05/16] Move bitmask routines to vrange base class Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 06/16] Remove GTY support for vrange and derived classes Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 07/16] Make fold_cond_with_ops use a boolean type for range_true/range_false Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 08/16] Change range_includes_zero_p argument to a reference Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 09/16] Verify that reading back from vrange_storage doesn't drop bits Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 10/16] Accept a vrange in get_legacy_range Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 11/16] Move get_bitmask_from_range out of irange class Aldy Hernandez
2024-04-28 19:05 ` Aldy Hernandez [this message]
2024-04-28 19:05 ` [COMMITTED 13/16] Accept any vrange in range_includes_zero_p Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 14/16] Move print_irange_* out of vrange_printer class Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 15/16] Remove range_zero and range_nonzero Aldy Hernandez
2024-04-28 19:05 ` [COMMITTED 16/16] Callers of irange_bitmask must normalize value/mask pairs Aldy Hernandez

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=20240428190557.1209586-13-aldyh@redhat.com \
    --to=aldyh@redhat.com \
    --cc=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).