public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] Provide support for copying unsupported ranges.
@ 2023-05-17 14:10 Aldy Hernandez
  2023-05-17 14:10 ` [COMMITTED] Add Value_Range::operator= Aldy Hernandez
  0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2023-05-17 14:10 UTC (permalink / raw)
  To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez

The unsupported_range class is provided for completness sake.  It is a
way to set VARYING/UNDEFINED ranges for unsupported ranges (currently
anything not float, integer, or pointer).  You can't do anything with
them, except set_varying, and set_undefined.  We will trap on any
other operation.

This patch provides a way to copy them, just in case they creep in.
This could happen in IPA under certain circumstances.

gcc/ChangeLog:

	* value-range.cc (vrange::operator=): Add a stub to copy
	unsupported ranges.
	* value-range.h (is_a <unsupported_range>): New.
	(Value_Range::operator=): Support copying unsupported ranges.
---
 gcc/value-range.cc |  5 ++++-
 gcc/value-range.h  | 12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 93c44a68365..45b1e655967 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -203,7 +203,10 @@ vrange::operator= (const vrange &src)
   else if (is_a <frange> (src))
     as_a <frange> (*this) = as_a <frange> (src);
   else
-    gcc_unreachable ();
+    {
+      gcc_checking_assert (is_a <unsupported_range> (src));
+      m_kind = src.m_kind;
+    }
   return *this;
 }
 
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 0da2a42764a..ab982d18402 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -460,6 +460,13 @@ is_a <frange> (vrange &v)
   return v.m_discriminator == VR_FRANGE;
 }
 
+template <>
+inline bool
+is_a <unsupported_range> (vrange &v)
+{
+  return v.m_discriminator == VR_UNKNOWN;
+}
+
 // For resizable ranges, resize the range up to HARD_MAX_RANGES if the
 // NEEDED pairs is greater than the current capacity of the range.
 
@@ -624,6 +631,11 @@ Value_Range::operator= (const vrange &r)
       m_frange = as_a <frange> (r);
       m_vrange = &m_frange;
     }
+  else if (is_a <unsupported_range> (r))
+    {
+      m_unsupported = as_a <unsupported_range> (r);
+      m_vrange = &m_unsupported;
+    }
   else
     gcc_unreachable ();
 
-- 
2.40.0


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

* [COMMITTED] Add Value_Range::operator=.
  2023-05-17 14:10 [COMMITTED] Provide support for copying unsupported ranges Aldy Hernandez
@ 2023-05-17 14:10 ` Aldy Hernandez
  0 siblings, 0 replies; 2+ messages in thread
From: Aldy Hernandez @ 2023-05-17 14:10 UTC (permalink / raw)
  To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez

gcc/ChangeLog:

	* value-range.h (Value_Range::operator=): New.
---
 gcc/value-range.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gcc/value-range.h b/gcc/value-range.h
index ab982d18402..af81d6080da 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -523,6 +523,7 @@ public:
   Value_Range (const Value_Range &);
   void set_type (tree type);
   vrange& operator= (const vrange &);
+  Value_Range& operator= (const Value_Range &);
   bool operator== (const Value_Range &r) const;
   bool operator!= (const Value_Range &r) const;
   operator vrange &();
@@ -642,6 +643,30 @@ Value_Range::operator= (const vrange &r)
   return *m_vrange;
 }
 
+inline Value_Range &
+Value_Range::operator= (const Value_Range &r)
+{
+  if (r.m_vrange == &r.m_irange)
+    {
+      m_irange = r.m_irange;
+      m_vrange = &m_irange;
+    }
+  else if (r.m_vrange == &r.m_frange)
+    {
+      m_frange = r.m_frange;
+      m_vrange = &m_frange;
+    }
+  else if (r.m_vrange == &r.m_unsupported)
+    {
+      m_unsupported = r.m_unsupported;
+      m_vrange = &m_unsupported;
+    }
+  else
+    gcc_unreachable ();
+
+  return *this;
+}
+
 inline bool
 Value_Range::operator== (const Value_Range &r) const
 {
-- 
2.40.0


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

end of thread, other threads:[~2023-05-17 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 14:10 [COMMITTED] Provide support for copying unsupported ranges Aldy Hernandez
2023-05-17 14:10 ` [COMMITTED] Add Value_Range::operator= Aldy Hernandez

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