public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: "Bin.Cheng" <amker.cheng@gmail.com>
Cc: Jeff Law <law@redhat.com>, Alan Lawrence <alan.lawrence@arm.com>,
	    gcc-patches List <gcc-patches@gcc.gnu.org>,
	mjambor@suse.cz
Subject: Re: [PATCH 3/5] Build ARRAY_REFs when the base is of ARRAY_TYPE.
Date: Wed, 26 Aug 2015 07:40:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1508260925470.4884@zhemvz.fhfr.qr> (raw)
In-Reply-To: <CAHFci28s3pw9Sj+=uaRTLG9MH7esyYXbSx25FRjrLzUv5LtKbQ@mail.gmail.com>

On Wed, 26 Aug 2015, Bin.Cheng wrote:

> On Wed, Aug 26, 2015 at 3:50 AM, Jeff Law <law@redhat.com> wrote:
> > On 08/25/2015 05:06 AM, Alan Lawrence wrote:
> >>
> >> When SRA completely scalarizes an array, this patch changes the
> >> generated accesses from e.g.
> >>
> >> MEM[(int[8] *)&a + 4B] = 1;
> >>
> >> to
> >>
> >> a[1] = 1;
> >>
> >> This overcomes a limitation in dom2, that accesses to equivalent
> >> chunks of e.g. MEM[(int[8] *)&a] are not hashable_expr_equal_p with
> >> accesses to e.g. MEM[(int[8] *)&a]. This is necessary for constant
> >> propagation in the ssa-dom-cse-2.c testcase (after the next patch
> >> that makes SRA handle constant-pool loads).
> >>
> >> I tried to work around this by making dom2's hashable_expr_equal_p
> >> less conservative, but found that on platforms without AArch64's
> >> vectorized reductions (specifically Alpha, hppa, PowerPC, and SPARC,
> >> mentioned in ssa-dom-cse-2.c), I also needed to make MEM[(int[8]
> >> *)&a] equivalent to a[0], etc.; a complete overhaul of
> >> hashable_expr_equal_p seems like a larger task than this patch
> >> series.
> >>
> >> I can't see how to write a testcase for this in C though as direct
> >> assignment to an array is not possible; such assignments occur only
> >> with constant pool data, which is dealt with in the next patch.
> >
> > It's a general issue that if there's > 1 common way to represent an
> > expression, then DOM will often miss discovery of the CSE opportunity
> > because of the way it hashes expressions.
> >
> > Ideally we'd be moving to a canonical form, but I also realize that in
> > the case of memory references like this, that may not be feasible.
> IIRC, there were talks about lowering all memory reference on GIMPLE?
> Which is the reverse approach.  Since SRA is in quite early
> compilation stage, don't know if lowered memory reference has impact
> on other optimizers.

Yeah, I'd only do the lowering after loop opts.  Which also may make
the DOM issue moot as the array refs would be lowered as well and thus
DOM would see a consistent set of references again.  The lowering should
also simplify SLSR and expose address computation redundancies to DOM.

I'd place such lowering before the late reassoc (any takers?  I suppose
you can pick up one of the bitfield lowering passes posted in the
previous years as this should also handle bitfield accesses correctly).

Thanks,
Richard.

> Thanks,
> bin
> >
> > It does make me wonder how many CSEs we're really missing due to the two
> > ways to represent array accesses.
> >
> >
> >> Bootstrap + check-gcc on x86-none-linux-gnu,
> >> arm-none-linux-gnueabihf, aarch64-none-linux-gnu.
> >>
> >> gcc/ChangeLog:
> >>
> >> * tree-sra.c (completely_scalarize): Move some code into:
> >> (get_elem_size): New. (build_ref_for_offset): Build ARRAY_REF if base
> >> is aligned array. --- gcc/tree-sra.c | 110
> >> ++++++++++++++++++++++++++++++++++++--------------------- 1 file
> >> changed, 69 insertions(+), 41 deletions(-)
> >>
> >> diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 08fa8dc..af35fcc
> >> 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -957,6 +957,20 @@
> >> scalarizable_type_p (tree type) } }
> >>
> >> +static bool +get_elem_size (const_tree type, unsigned HOST_WIDE_INT
> >> *sz_out)
> >
> > Function comment needed.
> >
> > I may have missed it in the earlier patches, but can you please make
> > sure any new functions you created have comments in those as well.  Such
> > patches are pre-approved.
> >
> > With the added function comment, this patch is fine.
> >
> > jeff
> >
> >
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)

  reply	other threads:[~2015-08-26  7:29 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 11:06 [PATCH 0/5][tree-sra.c] PR/63679 Make SRA replace constant pool loads Alan Lawrence
2015-08-25 11:06 ` [RFC 5/5] Always completely replace constant pool entries Alan Lawrence
2015-08-25 20:09   ` Jeff Law
2015-08-26  7:29     ` Richard Biener
2015-08-25 11:06 ` [RFC 4/5] Handle constant-pool entries Alan Lawrence
2015-08-25 20:19   ` Jeff Law
2015-08-26  7:24     ` Richard Biener
2015-08-26 15:51     ` Alan Lawrence
2015-08-26 14:08   ` Martin Jambor
2015-08-25 11:21 ` [PATCH 2/5] completely_scalarize arrays as well as records Alan Lawrence
2015-08-25 19:40   ` Jeff Law
2015-08-27 16:54     ` Fixing sra-12.c (was: Re: [PATCH 2/5] completely_scalarize arrays as well as records) Alan Lawrence
2015-08-27 20:58       ` Fixing sra-12.c Jeff Law
2015-08-25 21:44   ` [PATCH 2/5] completely_scalarize arrays as well as records Martin Jambor
2015-08-25 21:55     ` Jeff Law
2015-08-26  7:11       ` Richard Biener
2015-08-26  9:39         ` Martin Jambor
2015-08-26 10:12           ` Richard Biener
2015-08-26 16:30             ` Alan Lawrence
2015-08-26 19:18               ` Richard Biener
2015-08-27 16:00     ` Alan Lawrence
2015-08-28  7:19       ` Christophe Lyon
2015-08-28  8:06         ` Richard Biener
2015-08-28  8:16           ` Christophe Lyon
2015-08-28  8:31             ` Richard Biener
2015-08-28 10:09             ` Alan Lawrence
2015-08-28 13:35               ` Richard Biener
2015-08-28 14:05                 ` Alan Lawrence
2015-08-28 15:17                   ` Alan Lawrence
2015-09-07 13:20                     ` Alan Lawrence
2015-09-08 12:47                       ` Martin Jambor
2015-09-14 17:41                         ` Alan Lawrence
2015-09-15  7:49                           ` Richard Biener
2015-09-17 17:12                             ` Alan Lawrence
2015-09-18  8:36                               ` Richard Biener
2015-08-25 11:30 ` [PATCH 1/5] Refactor completely_scalarize_var Alan Lawrence
2015-08-25 19:36   ` Jeff Law
2015-08-25 21:42   ` Martin Jambor
2015-08-25 12:30 ` [PATCH 3/5] Build ARRAY_REFs when the base is of ARRAY_TYPE Alan Lawrence
2015-08-25 19:54   ` Jeff Law
2015-08-26  6:34     ` Bin.Cheng
2015-08-26  7:40       ` Richard Biener [this message]
2015-08-26  7:41         ` Bin.Cheng
2015-08-26  7:20     ` Richard Biener
2015-08-25 22:51   ` Martin Jambor

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=alpine.LSU.2.11.1508260925470.4884@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=alan.lawrence@arm.com \
    --cc=amker.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=mjambor@suse.cz \
    /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).