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>
Subject: [COMMITTED] Misc range temporary fixes.
Date: Fri,  3 Jun 2022 09:32:19 +0200	[thread overview]
Message-ID: <20220603073219.2683070-3-aldyh@redhat.com> (raw)
In-Reply-To: <20220603073219.2683070-1-aldyh@redhat.com>

This fixes a couples places that were using int_range_max, but needed
a generic temporary.  Found while merging the frange work.

Also, copying between range temporaries is actually useful :).

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-cache.cc (ranger_cache::range_from_dom): Use
	Value_Range.
	* gimple-range.cc (gimple_ranger::register_inferred_ranges): Same.
	* value-range.h (Value_Range::Value_Range): Implement copy
	constructor for Value_Range.
---
 gcc/gimple-range-cache.cc | 2 +-
 gcc/gimple-range.cc       | 9 ++++++---
 gcc/value-range.h         | 8 +++++++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 85eed4421f4..f3494363a10 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1372,7 +1372,7 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb,
 	      // each incoming edge now and accumulate the results.
 	      r.set_undefined ();
 	      edge_iterator ei;
-	      int_range_max er;
+	      Value_Range er (TREE_TYPE (name));
 	      FOR_EACH_EDGE (e, ei, prev_bb->preds)
 		{
 		  edge_range (er, e, name, RFD_READ_ONLY);
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 67dafb2a2c0..f3a46555f91 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -461,17 +461,20 @@ gimple_ranger::register_inferred_ranges (gimple *s)
   tree lhs = gimple_get_lhs (s);
   if (lhs)
     {
-      int_range_max tmp;
+      Value_Range tmp (TREE_TYPE (lhs));
       if (range_of_stmt (tmp, s, lhs) && !tmp.varying_p ()
 	  && update_global_range (tmp, lhs) && dump_file)
 	{
-	  value_range vr = tmp;
+	  // ?? This section should be adjusted when non-iranges can
+	  // be exported.  For now, the only way update_global_range
+	  // above can succeed is with an irange so this is safe.
+	  value_range vr = as_a <irange> (tmp);
 	  fprintf (dump_file, "Global Exported: ");
 	  print_generic_expr (dump_file, lhs, TDF_SLIM);
 	  fprintf (dump_file, " = ");
 	  vr.dump (dump_file);
 	  int_range_max same = vr;
-	  if (same != tmp)
+	  if (same != as_a <irange> (tmp))
 	    {
 	      fprintf (dump_file, " ...  irange was : ");
 	      tmp.dump (dump_file);
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 26e41ed2982..dc6f6b0f935 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -314,6 +314,7 @@ public:
   Value_Range ();
   Value_Range (const vrange &r);
   Value_Range (tree type);
+  Value_Range (const Value_Range &);
   void set_type (tree type);
   vrange& operator= (const vrange &);
   bool operator== (const Value_Range &r) const;
@@ -344,7 +345,6 @@ private:
   unsupported_range m_unsupported;
   vrange *m_vrange;
   int_range_max m_irange;
-  DISABLE_COPY_AND_ASSIGN (Value_Range);
 };
 
 inline
@@ -370,6 +370,12 @@ Value_Range::Value_Range (tree type)
   init (type);
 }
 
+inline
+Value_Range::Value_Range (const Value_Range &r)
+{
+  m_vrange = r.m_vrange;
+}
+
 // Initialize object so it is possible to store temporaries of TYPE
 // into it.
 
-- 
2.36.1


      parent reply	other threads:[~2022-06-03  7:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03  7:32 [COMMITTED] Flesh out unsupported_range Aldy Hernandez
2022-06-03  7:32 ` [COMMITTED] Remove unneeded vrange_traits Aldy Hernandez
2022-06-03  7:32 ` Aldy Hernandez [this message]

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=20220603073219.2683070-3-aldyh@redhat.com \
    --to=aldyh@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).