From: Aldy Hernandez <aldyh@redhat.com>
To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com
Subject: Re: Add a constant_range_value_p function (PR 92033)
Date: Mon, 14 Oct 2019 12:53:00 -0000 [thread overview]
Message-ID: <2e70a542-ad95-8468-bbe8-14aa5facd68a@redhat.com> (raw)
In-Reply-To: <mpteezf33vd.fsf@arm.com>
On 10/14/19 8:31 AM, Richard Sandiford wrote:
> Aldy Hernandez <aldyh@redhat.com> writes:
>> On 10/14/19 4:30 AM, Richard Sandiford wrote:
>>> Aldy Hernandez <aldyh@redhat.com> writes:
>>>> On 10/11/19 10:42 AM, Richard Sandiford wrote:
>>>>> The range-tracking code has a pretty hard-coded assumption that
>>>>> is_gimple_min_invariant is equivalent to "INTEGER_CST or invariant
>>>>> ADDR_EXPR". It seems better to add a predicate specifically for
>>>>> that rather than contiually fight cases in which it can't handle
>>>>> other invariants.
>>>>
>>>> I was going to suggest we normalize ranges to numerics completely before
>>>> folding. That is, replacing normalize_addresses() here:
>>>>
>>>> *vr = op->fold_range (expr_type,
>>>> vr0.normalize_addresses (),
>>>> vr1.normalize_addresses ());
>>>>
>>>> ...into normalize_symbolics(). But I suppose getting the gate correct
>>>> is even better. Thanks for taking the care of this extensive and manual
>>>> change.
>>>>
>>>> The patch looks good to me. However, I do wonder if VRP and
>>>> subsidiaries can't handle non-integer invariants, if we shouldn't
>>>> disallow them from the setters as well:
>>>>
>>>> void
>>>> value_range_base::set (tree val)
>>>> {
>>>> gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant
>>>> (val));
>>>> if (TREE_OVERFLOW_P (val))
>>>> val = drop_tree_overflow (val);
>>>> set (VR_RANGE, val, val);
>>>> }
>>>>
>>>> void
>>>> value_range::set (tree val)
>>>> {
>>>> gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant
>>>> (val));
>>>> if (TREE_OVERFLOW_P (val))
>>>> val = drop_tree_overflow (val);
>>>> set (VR_RANGE, val, val, NULL);
>>>> }
>>>>
>>>> This would still allow setting of VARYING and UNDEFINED, but disallow
>>>> poly-ints, etc from a range.
>>>>
>>>> Was this a small oversight, or was there a reason you left those in?
>>>
>>> Yeah, this was intentional. The patch is effectively treating
>>> POLY_INY_CST as symbolic rather than constant. (It's really somewhere
>>> in the middle: it's at least a function invariant, but the invariant
>>> depends on a runtime target property.) So places like here that
>>> can handle both symbolics and constants should be able to handle
>>> POLY_INT_CST wihout problems. We just need to make sure that
>>> POLY_INT_CSTs aren't treated as constants for range tracking,
>>> because they're not "constant enough" there.
>>
>> Hmmm... We don't handle POLY_INT_CST value_range's anywhere, so perhaps
>> it's better to stop their creation at the source and fix the caller, to
>> inhibit their proliferation. AFAICT, the only POLY_INT_CST ranges that
>> would be used are VARYING and UNDEFINED (for the lattice), and that
>> already works.
>>
>> If you don't agree, then at least a comment in ::set() would be nice, to
>> document that we're allowing their creation and why.
>
> I don't think it makes sense to allow SSA_NAME (which is completely
> unconstrained) and not allow POLY_INT_CST. Like I say, POLY_INT_CST
> can be conservatively treated as symbolic.
Oh, I see your change to ::symbolic_p() would effectively treat them as
symbolics.
>
> POLY_INT_CST can produce useful singleton ranges or be a minimum or
> a maximum, even if we don't use them to reduce ranges arithmetically.
In which case, singleton_p() should be adapted to return the singleton.
I don't expect you to do this, unless you want to :). Could you at
least put a comment there, so we don't forget?
I'm feel a bit queasy allowing POLY_INT ranges throughout, when we have
no code that handle them anywhere, but I won't object to your patch.
Thanks for fixing this.
The patch with the comment on singleton is fine with me.
Aldy
next prev parent reply other threads:[~2019-10-14 12:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-11 14:45 Richard Sandiford
2019-10-13 16:22 ` Aldy Hernandez
2019-10-14 8:34 ` Richard Sandiford
2019-10-14 10:01 ` Aldy Hernandez
2019-10-14 12:32 ` Richard Sandiford
2019-10-14 12:53 ` Aldy Hernandez [this message]
2019-10-14 11:44 ` Richard Biener
2019-10-14 12:49 ` Richard Sandiford
2019-10-14 16:41 ` Richard Biener
2019-10-14 18:46 ` Aldy Hernandez
2019-10-15 10:46 ` Richard Sandiford
2019-10-15 11:26 ` Richard Biener
2019-10-17 8:17 ` Christophe Lyon
2019-10-17 8:23 ` Richard Sandiford
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=2e70a542-ad95-8468-bbe8-14aa5facd68a@redhat.com \
--to=aldyh@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.sandiford@arm.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).