public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 2/5] fend off anti-ranges from value-range-storage
@ 2023-02-28 13:47 Richard Biener
  2023-03-01 10:10 ` Aldy Hernandez
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2023-02-28 13:47 UTC (permalink / raw)
  To: gcc-patches

The following avoids the need to special-case storage requirement
and copying for irange_storage_slot by making sure we canonicalize
such ranges to int_range<2>.

	* tree-ssanames.cc (range_info_set_range): If receiving
	an anti-range recurse with a temporary int_range<2>.
	* value-range-storage.cc (irange_storage_slot::size):
	Assert we're not asking for a VR_ANTI_RANGE.
---
 gcc/tree-ssanames.cc       | 3 +++
 gcc/value-range-storage.cc | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 08aa166ef17..23468958586 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -127,6 +127,9 @@ range_info_get_range (tree name, vrange &r)
 inline bool
 range_info_set_range (tree name, const vrange &r)
 {
+  if (r.kind () == VR_ANTI_RANGE)
+    return range_info_set_range (name, int_range<2> (as_a <irange> (r)));
+
   if (!range_info_p (name) || !range_info_fits_p (name, r))
     {
       if (range_info_p (name))
diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index bf23f6dd476..79ab2921a03 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -182,7 +182,7 @@ irange_storage_slot::get_irange (irange &r, tree type) const
 size_t
 irange_storage_slot::size (const irange &r)
 {
-  gcc_checking_assert (!r.undefined_p ());
+  gcc_checking_assert (!r.undefined_p () && r.kind () != VR_ANTI_RANGE);
 
   unsigned prec = TYPE_PRECISION (r.type ());
   unsigned n = num_wide_ints_needed (r);
-- 
2.35.3


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

* Re: [PATCH 2/5] fend off anti-ranges from value-range-storage
  2023-02-28 13:47 [PATCH 2/5] fend off anti-ranges from value-range-storage Richard Biener
@ 2023-03-01 10:10 ` Aldy Hernandez
  0 siblings, 0 replies; 2+ messages in thread
From: Aldy Hernandez @ 2023-03-01 10:10 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

OK.

Thanks.

On Tue, Feb 28, 2023 at 2:48 PM Richard Biener via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The following avoids the need to special-case storage requirement
> and copying for irange_storage_slot by making sure we canonicalize
> such ranges to int_range<2>.
>
>         * tree-ssanames.cc (range_info_set_range): If receiving
>         an anti-range recurse with a temporary int_range<2>.
>         * value-range-storage.cc (irange_storage_slot::size):
>         Assert we're not asking for a VR_ANTI_RANGE.
> ---
>  gcc/tree-ssanames.cc       | 3 +++
>  gcc/value-range-storage.cc | 2 +-
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
> index 08aa166ef17..23468958586 100644
> --- a/gcc/tree-ssanames.cc
> +++ b/gcc/tree-ssanames.cc
> @@ -127,6 +127,9 @@ range_info_get_range (tree name, vrange &r)
>  inline bool
>  range_info_set_range (tree name, const vrange &r)
>  {
> +  if (r.kind () == VR_ANTI_RANGE)
> +    return range_info_set_range (name, int_range<2> (as_a <irange> (r)));
> +
>    if (!range_info_p (name) || !range_info_fits_p (name, r))
>      {
>        if (range_info_p (name))
> diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
> index bf23f6dd476..79ab2921a03 100644
> --- a/gcc/value-range-storage.cc
> +++ b/gcc/value-range-storage.cc
> @@ -182,7 +182,7 @@ irange_storage_slot::get_irange (irange &r, tree type) const
>  size_t
>  irange_storage_slot::size (const irange &r)
>  {
> -  gcc_checking_assert (!r.undefined_p ());
> +  gcc_checking_assert (!r.undefined_p () && r.kind () != VR_ANTI_RANGE);
>
>    unsigned prec = TYPE_PRECISION (r.type ());
>    unsigned n = num_wide_ints_needed (r);
> --
> 2.35.3
>


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

end of thread, other threads:[~2023-03-01 10:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 13:47 [PATCH 2/5] fend off anti-ranges from value-range-storage Richard Biener
2023-03-01 10:10 ` 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).