From: Aldy Hernandez <aldyh@redhat.com>
To: Richard Biener <rguenther@suse.de>, gcc-patches@gcc.gnu.org
Cc: Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH 4/5] Sanitize irange::num_pairs
Date: Wed, 1 Mar 2023 11:38:13 +0100 [thread overview]
Message-ID: <229ad516-2d85-fa04-4ebf-f14ea0a3b24d@redhat.com> (raw)
In-Reply-To: <20230228134739.E030413440@imap2.suse-dmz.suse.de>
I would prefer not touching this as it was intended, and about to be
removed. However, if we have actual regressions or missed optimizations
because of the current behavior I could be convinced otherwise.
Aldy
On 2/28/23 14:47, Richard Biener via Gcc-patches wrote:
> irange::num_pairs has odd behavior for VR_ANTI_RANGE where it
> claims there are two pairs when there's actually only one. The
> following is now able to get rid of this, also fixing
> irange::legacy_upper_bound which special-cased ~[-INF, up]
> to return +INF instead of properly doing that when up is not +INF.
>
> * value-range.h (irange::num_pairs): Always return
> m_num_ranges.
> * value-range.cc (irange::legacy_lower_bound): Remove
> pair == 1 case.
> (irange::legacy_upper_bound): Likewise. Properly
> special-case ~[low, +INF].
> ---
> gcc/value-range.cc | 6 ++++--
> gcc/value-range.h | 5 +----
> 2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/value-range.cc b/gcc/value-range.cc
> index a535337c47a..143af5601c7 100644
> --- a/gcc/value-range.cc
> +++ b/gcc/value-range.cc
> @@ -1208,7 +1208,8 @@ irange::legacy_lower_bound (unsigned pair) const
> if (m_kind == VR_ANTI_RANGE)
> {
> tree typ = type (), t;
> - if (pair == 1 || vrp_val_is_min (min ()))
> + gcc_checking_assert (pair == 0);
> + if (vrp_val_is_min (min ()))
> t = wide_int_to_tree (typ, wi::to_wide (max ()) + 1);
> else
> t = vrp_val_min (typ);
> @@ -1235,7 +1236,8 @@ irange::legacy_upper_bound (unsigned pair) const
> if (m_kind == VR_ANTI_RANGE)
> {
> tree typ = type (), t;
> - if (pair == 1 || vrp_val_is_min (min ()))
> + gcc_checking_assert (pair == 0);
> + if (!vrp_val_is_max (max ()))
> t = vrp_val_max (typ);
> else
> t = wide_int_to_tree (typ, wi::to_wide (min ()) - 1);
> diff --git a/gcc/value-range.h b/gcc/value-range.h
> index f4ac73b499f..cfb51bad915 100644
> --- a/gcc/value-range.h
> +++ b/gcc/value-range.h
> @@ -614,10 +614,7 @@ vrange::kind () const
> inline unsigned
> irange::num_pairs () const
> {
> - if (m_kind == VR_ANTI_RANGE)
> - return constant_p () ? 2 : 1;
> - else
> - return m_num_ranges;
> + return m_num_ranges;
> }
>
> inline tree
prev parent reply other threads:[~2023-03-01 10:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 13:47 Richard Biener
2023-03-01 10:38 ` 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=229ad516-2d85-fa04-4ebf-f14ea0a3b24d@redhat.com \
--to=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/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).