diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2022-05-09 13:20:06 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2022-05-13 10:42:52 -0400 |
commit | 1d3d7e88aac0db20a4b59044f9b7cd35e847e8d3 (patch) | |
tree | 931a3a72b17c8f3e164180cee85c5c336c966604 /gcc/value-range.h | |
parent | 98e475a8f58ca3ba6e9bd5c9276efce4236f5d26 (diff) | |
download | gcc-1d3d7e88aac0db20a4b59044f9b7cd35e847e8d3.zip gcc-1d3d7e88aac0db20a4b59044f9b7cd35e847e8d3.tar.gz gcc-1d3d7e88aac0db20a4b59044f9b7cd35e847e8d3.tar.bz2 |
Add a return value to intersect and speed it up.
Return true if the intersection of ranges changed the original value.
Speed up the case when there is no change by calling an efficient
contains routine.
* value-range.cc (irange::legacy_verbose_intersect): Add return value.
(irange::irange_contains_p): New.
(irange::irange_intersect): Add return value.
* value-range.h (class irange): Adjust prototypes.
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r-- | gcc/value-range.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h index 90a395f..4198602 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -72,7 +72,7 @@ public: // In-place operators. void union_ (const irange &); - void intersect (const irange &); + bool intersect (const irange &); void invert (); // Operator overloads. @@ -97,7 +97,7 @@ public: void set (tree); // DEPRECATED bool equal_p (const irange &) const; // DEPRECATED void legacy_verbose_union_ (const class irange *); // DEPRECATED - void legacy_verbose_intersect (const irange *); // DEPRECATED + bool legacy_verbose_intersect (const irange *); // DEPRECATED protected: irange (tree *, unsigned); @@ -108,9 +108,10 @@ protected: // In-place operators. void irange_union (const irange &); - void irange_intersect (const irange &); + bool irange_intersect (const irange &); void irange_set (tree, tree); void irange_set_anti_range (tree, tree); + bool irange_contains_p (const irange &) const; void normalize_kind (); @@ -134,7 +135,7 @@ private: void irange_set_1bit_anti_range (tree, tree); bool varying_compatible_p () const; - void intersect (const wide_int& lb, const wide_int& ub); + bool intersect (const wide_int& lb, const wide_int& ub); unsigned char m_num_ranges; unsigned char m_max_ranges; ENUM_BITFIELD(value_range_kind) m_kind : 8; @@ -553,13 +554,14 @@ irange::union_ (const irange &r) dump_flags = m_flags; } -inline void +inline bool irange::intersect (const irange &r) { dump_flags_t m_flags = dump_flags; dump_flags &= ~TDF_DETAILS; - irange::legacy_verbose_intersect (&r); + bool ret = irange::legacy_verbose_intersect (&r); dump_flags = m_flags; + return ret; } // Set value range VR to a nonzero range of type TYPE. |