From: Aldy Hernandez <aldyh@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC patches <gcc-patches@gcc.gnu.org>,
Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH] Pass correct type to irange::contains_p() in ipa-cp.cc.
Date: Mon, 24 Apr 2023 13:51:16 +0200 [thread overview]
Message-ID: <9db305b9-62fb-1b07-656a-13d029a7f730@redhat.com> (raw)
In-Reply-To: <CAFiYyc1E_4gQNGtmdtU-Fo_rpXvAytU4=uFzPhdQ8duArB=tvw@mail.gmail.com>
On 4/24/23 10:30, Richard Biener wrote:
> On Mon, Apr 24, 2023 at 9:44 AM Aldy Hernandez via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> There is a call to contains_p() in ipa-cp.cc which passes incompatible
>> types. This currently works because deep in the call chain, the legacy
>> code uses tree_int_cst_lt which performs the operation with
>> widest_int. With the upcoming removal of legacy, contains_p() will be
>> stricter.
>>
>> OK pending tests?
>>
>> gcc/ChangeLog:
>>
>> * ipa-cp.cc (ipa_range_contains_p): New.
>> (decide_whether_version_node): Use it.
>> ---
>> gcc/ipa-cp.cc | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
>> index b3e0f62e400..c8013563796 100644
>> --- a/gcc/ipa-cp.cc
>> +++ b/gcc/ipa-cp.cc
>> @@ -6180,6 +6180,19 @@ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset,
>> return true;
>> }
>>
>> +/* Like irange::contains_p(), but convert VAL to the range of R if
>> + necessary. */
>> +
>> +static inline bool
>> +ipa_range_contains_p (const irange &r, tree val)
>> +{
>> + if (r.undefined_p ())
>> + return false;
>> +
>> + val = fold_convert (r.type (), val);
>
> I think that's wrong, it might truncate 'val'. I think we'd want
>
> if (r.undefined_p () || !int_fits_type_p (val, r.type ()))
> return false;
This won't work for pointers. Is there a suitable version that handles
pointers as well?
>
> but then I wonder whether contains_p should have an overload
> with widest_int or handle "out of bounds" values itself more gracefully?
Only IPA is currently passing incompatible types to contains_p(), so I'd
prefer to keep things stricter until there is an actual need for them.
Thanks.
Aldy
next prev parent reply other threads:[~2023-04-24 11:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 7:43 Aldy Hernandez
2023-04-24 8:30 ` Richard Biener
2023-04-24 11:51 ` Aldy Hernandez [this message]
2023-04-24 12:10 ` Richard Biener
2023-04-24 12:32 ` Aldy Hernandez
2023-04-24 12:35 ` Richard Biener
2023-04-24 17:17 ` Aldy Hernandez
2023-04-25 7:19 ` Richard Biener
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=9db305b9-62fb-1b07-656a-13d029a7f730@redhat.com \
--to=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/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).