public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	Andrew MacLeod <amacleod@redhat.com>, 	Jeff Law <law@redhat.com>
Subject: Re: [range-ops] patch 01/04: types for VR_UNDEFINED and VR_VARYING
Date: Tue, 09 Jul 2019 09:57:00 -0000	[thread overview]
Message-ID: <CAFiYyc26ZcFT8QczAGyLJfW-JVRkBz+ARk8Ae2+UsR=hw6fXsQ@mail.gmail.com> (raw)
In-Reply-To: <d8f02a92-a163-dd3a-0fd9-da0f1ad36d54@redhat.com>

On Tue, Jul 9, 2019 at 9:28 AM Aldy Hernandez <aldyh@redhat.com> wrote:
>
>
>
> On 7/4/19 6:33 AM, Richard Biener wrote:
> > On Wed, Jul 3, 2019 at 2:17 PM Aldy Hernandez <aldyh@redhat.com> wrote:
> >>
> >> On 7/3/19 7:08 AM, Richard Biener wrote:
> >>> On Wed, Jul 3, 2019 at 11:19 AM Aldy Hernandez <aldyh@redhat.com> wrote:
> >
> >> How about we keep VARYING and UNDEFINED typeless until right before we
> >> call into the ranger.  At which point, we have can populate min/max
> >> because we have the tree_code and the type handy.  So right before we
> >> call into the ranger do:
> >>
> >>          if (varying_p ())
> >>            foo->set_varying(TYPE);
> >>
> >> This would avoid the type cache, and keep the ranger happy.
> >
> > you cannot do set_varying on the static const range but instead you'd do
> >
> >    value_range tem (*foo);
> >    if (varying_p ())
> >     tem->set_full_range (TYPE);
> >
> > which I think we already do in some places.  Thus my question _where_
> > you actually need this.
>
> Basically, everywhere.  By having a type for varying/undefined, we don't
> have to special case anything.  Sure, we could for example, special case
> the invert operation for undefined / varying.  And we could special case
> everything dealing with ranges to handle varying and undefined, but why?
>   We could also pass a type argument everywhere, but that's just ugly.
> However, I do understand your objection to the type cache.
>
> How about the attached approach?  Set the type for varying/undefined
> when we know it, while avoiding touching the CONST varying.  Then right
> before calling the ranger, pass down a new varying node with min/max for
> any varyings that were still typeless until that point.
>
> I have taken care of never adding a set_varying() that was not already
> there.  Would this keep the const happy?
>
> Technically we don't need to set varying/undef types for every instance
> in VRP, but we need it at least for the code that will be shared with
> range-ops (extract_range_from_multiplicative_op, union, intersect, etc).
>   I just figured if we have the information, might as well set it for
> consistency.
>
> If you like this approach, I can rebase the other patches that depend on
> this one.

OK, so I went ant checked what you do for class irange which has
a type but no kind member (but constructors with a kind).  It also
uses wide_int members for storage.  For a pure integer constant
range representation this represents somewhat odd choices;  I'd
have elided the m_type member completely here, it seems fully
redundant.  Only range operations need to be carried out in a
specific type (what I was suggesting above).  Even the precision
encoded in the wide_int members is redundant then (I'd have
expected widest_int here and trailing-wide-ints for optimizing
storage).

Then class range_operator looks a bit strange to me (looking
just at the header).  Ugh, so it is all virtual because
you have one instance per tree code.  What an odd choice.
Why didn't you simply go with passing tree_code  (and type!)
to fold_range/op_range?  The API also seems to be oddly
constrained to binary ops.  Anyway, the way you build
the operator table requires an awful lot of global C++ ctor
invocations, sth we generally try to avoid.  But I'm getting
into too many details here.

So - to answer your question above, I'd like you to pass down
a type to operations.  Because that's what is fundamentally
required - a range doesn't have a "type" and the current
value_range_base doesn't fall into the trap of needing one.

Richard.

>
> Aldy

  reply	other threads:[~2019-07-09  9:56 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01  8:52 Aldy Hernandez
2019-07-02 20:17 ` Jeff Law
2019-07-03  9:46   ` Aldy Hernandez
2019-07-03 22:40     ` Jeff Law
2019-07-03  8:28 ` Richard Biener
2019-07-03  9:19   ` Aldy Hernandez
2019-07-03 11:08     ` Richard Biener
2019-07-03 12:23       ` Aldy Hernandez
2019-07-03 12:30         ` Aldy Hernandez
2019-07-04 10:34         ` Richard Biener
2019-07-09  7:49           ` Aldy Hernandez
2019-07-09  9:57             ` Richard Biener [this message]
2019-07-16 19:56               ` Andrew MacLeod
2019-07-22 15:38                 ` Aldy Hernandez
2019-07-23  0:19                 ` Jeff Law
2019-07-23  9:45                   ` Richard Biener
2019-07-24 16:09                     ` Jeff Law
2019-07-24 17:06                       ` Richard Biener
2019-07-24 18:33                         ` Jeff Law
2019-07-24 18:38                           ` Richard Biener
2019-07-26  3:41                             ` Jeff Law
2019-07-26 14:52                               ` Andrew MacLeod
2019-07-30  9:02                                 ` Richard Biener
2019-07-30 15:16                                   ` Andrew MacLeod
2019-07-31  8:37                                     ` Richard Biener
     [not found]                                       ` <78846d0a-354e-b73a-6e15-123752038fb2@redhat.com>
2019-08-01 14:11                                         ` Richard Biener
2019-08-01 16:35                                           ` Andrew MacLeod
2019-07-26  4:34                             ` Jeff Law
2019-07-24 20:52                           ` Andrew MacLeod
2019-07-25  9:13                             ` Richard Biener
2019-07-23  9:34                 ` Richard Biener
2019-07-23 23:05                   ` Andrew MacLeod
2019-07-24 13:28                     ` Richard Biener
2019-07-24 18:07                       ` Andrew MacLeod

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='CAFiYyc26ZcFT8QczAGyLJfW-JVRkBz+ARk8Ae2+UsR=hw6fXsQ@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.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).