This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize in VRP loads from constant arrays (take 2)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 May 2017 10:03:59 +0200
- Subject: Re: [PATCH] Optimize in VRP loads from constant arrays (take 2)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49F0915567
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49F0915567
- References: <20170421140659.GB1809@tucnak> <5842BC6C-6CD8-4059-9DCF-625D39D2BAA6@suse.de> <20170429162849.GQ1809@tucnak> <alpine.LSU.2.20.1705021254411.17885@zhemvz.fhfr.qr> <20170502121213.GB1809@tucnak> <alpine.LSU.2.20.1705021444590.17885@zhemvz.fhfr.qr>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, May 02, 2017 at 02:50:16PM +0200, Richard Biener wrote:
> > If array_at_struct_end_p is wrong, it should be fixed ;)
>
> Indeed. It was originally meant to say false if you can trust
> TYPE_DOMAIN of the array but now it says false if there's some means
> to constrain the array size (the DECL_P path and now your STRING_CST
> one). But all callers afterwards just look at TYPE_DOMAIN ...
So shall we verify that TYPE_DOMAIN is consistent with the object size
in that case inside of array_at_struct_end_p?
> > > I'd restructure the patch quite different, using for_each_index on the
> > > ref gather an array of index pointers (bail out on sth unhandled).
> > > Then I'd see if I have interesting ranges for them, if not, bail out.
> > > Also compute the size product of all ranges and test that against
> > > PARAM_MAX_VRP_CONSTANT_ARRAY_LOADS. Then store the minimum range
> > > value in the index places (temporarily) and use get_base_ref_and_extent to
> > > get at the constant "starting" offset. From there iterate using
> > > the remembered indices (remember the ref tree as well via for_each_index),
> > > directly adjusting the constant offset so you can feed
> > > fold_ctor_reference the constant offsets of all elements that need to
> > > be considered. As optimization fold_ctor_reference would know how
> > > to start from the "last" offset (much refactoring would need to be
> > > done here given nested ctors and multiple indices I guess).
> >
> > But for this, don't you want to take it over?
>
> I can try. Is there a PR for this?
Ok, filed PR80603, it is now all yours.
> > I agree that the current implementation is not very efficient and that is
> > why it is also limited to that small number of iterations.
> > As many cases just aren't able to use the valueize callback, handling
> > arbitrary numbers of non-constant indexes would be harder.
>
> Sure. I'd have expected you simply handle ARRAY_REF of a VAR_DECL
> and nothing else ;)
That would be too simple and boring ;)
Jakub