From: Edmar Wienskoski <edmarwjr@gmail.com>
To: Richard Henderson <rth@redhat.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
Richard Biener <rguenther@suse.de>, Jan Hubicka <jh@suse.cz>,
gcc-patches@gcc.gnu.org, bernds@codesourcery.com, hp@axis.com,
hp@bitrange.com, uweigand@de.ibm.com,
Andreas.Krebbel@de.ibm.com, David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] DATA_ALIGNMENT vs. DATA_ABI_ALIGNMENT (PR target/56564)
Date: Wed, 12 Jun 2013 17:52:00 -0000 [thread overview]
Message-ID: <CAKkGaj7c6h++Rs8vFHCN5JDRcKf7JYAcFNBVkYWr3R4YRWgeEw@mail.gmail.com> (raw)
In-Reply-To: <51B245EF.3080602@redhat.com>
The e500v2 (SPE) hardware is such that if the address of vector (double world
load / stores) are not double world aligned the instruction will trap.
So this alignment is not optional.
Edmar
On Fri, Jun 7, 2013 at 3:43 PM, Richard Henderson <rth@redhat.com> wrote:
> On 06/07/2013 12:25 PM, Jakub Jelinek wrote:
>> This PR is about DATA_ALIGNMENT macro increasing alignment of some decls
>> for optimization purposes beyond ABI mandated levels. It is fine to emit
>> the vars aligned as much as we want for optimization purposes, but if we
>> can't be sure that references to that decl bind to the definition we
>> increased the alignment on (e.g. common variables, or -fpic code without
>> hidden visibility, weak vars etc.), we can't assume that alignment.
>
> When the linker merges common blocks, it chooses both maximum size and maximum
> alignment. Thus for any common block for which we can prove the block must
> reside in the module (any executable, or hidden common in shared object), we
> can go ahead and use the increased alignment.
>
> It's only in shared objects with non-hidden common blocks that we have a
> problem, since in that case we may resolve the common block via copy reloc to a
> memory block in another module.
>
> So while decl_binds_to_current_def_p is a good starting point, I think we can
> do a little better with common blocks. Which ought to take care of those
> vectorization regressions you mention.
>
>> @@ -966,8 +966,12 @@ align_variable (tree decl, bool dont_out
>> align = MAX_OFILE_ALIGNMENT;
>> }
>>
>> - /* On some machines, it is good to increase alignment sometimes. */
>> - if (! DECL_USER_ALIGN (decl))
>> + /* On some machines, it is good to increase alignment sometimes.
>> + But as DECL_ALIGN is used both for actually emitting the variable
>> + and for code accessing the variable as guaranteed alignment, we
>> + can only increase the alignment if it is a performance optimization
>> + if the references to it must bind to the current definition. */
>> + if (! DECL_USER_ALIGN (decl) && decl_binds_to_current_def_p (decl))
>> {
>> #ifdef DATA_ALIGNMENT
>> unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
>> @@ -988,12 +992,69 @@ align_variable (tree decl, bool dont_out
>> }
>> #endif
>> }
>> +#ifdef DATA_ABI_ALIGNMENT
>> + else if (! DECL_USER_ALIGN (decl))
>> + {
>> + unsigned int data_align = DATA_ABI_ALIGNMENT (TREE_TYPE (decl), align);
>> + /* For backwards compatibility, don't assume the ABI alignment for
>> + TLS variables. */
>> + if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
>> + align = data_align;
>> + }
>> +#endif
>
> This structure would seem to do the wrong thing if DATA_ABI_ALIGNMENT is
> defined, but DATA_ALIGNMENT isn't. And while I realize you documented it, I
> don't like the restriction that D_A /must/ return something larger than D_A_A.
> All that means is that in complex cases D_A will have to call D_A_A itself.
>
> I would think that it would be better to rearrange as
>
> if (!D_U_A)
> {
> #ifdef D_A_A
> align = ...
> #endif
> #ifdef D_A
> if (d_b_t_c_d_p)
> align = ...
> #endif
> }
>
> Why the special case for TLS? If we really want that special case surely that
> test should go into D_A_A itself, and not here in generic code.
>
>> Bootstrapped/regtested on x86_64-linux and i686-linux. No idea about other
>> targets, I've kept them all using DATA_ALIGNMENT, which is considered
>> optimization increase only now, if there is some ABI mandated alignment
>> increase on other targets, that should be done in DATA_ABI_ALIGNMENT as
>> well as DATA_ALIGNMENT.
>
> I've had a brief look over the instances of D_A within the tree atm. Most of
> them carry the cut-n-paste comment "for the same reasons". These I believe
> never intended an ABI change, and were really only interested in optimization.
>
> But these I think require a good hard look to see if they really intended an
> ABI alignment:
>
> c6x comment explicitly mentions abi
> cris compiler options for alignment -- systemwide or local?
> mmix comment mentions GETA instruction
> s390 comment mentions LARL instruction
> rs6000 SPE and E500 portion of the alignment non-optional?
>
> Relevant port maintainers CCed.
>
>
> r~
next prev parent reply other threads:[~2013-06-12 17:52 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 19:26 Jakub Jelinek
2013-06-07 20:43 ` Richard Henderson
2013-06-07 21:14 ` Jakub Jelinek
2013-06-08 15:13 ` Jakub Jelinek
2013-06-10 14:52 ` Richard Henderson
2013-06-10 15:45 ` Jakub Jelinek
2013-06-10 19:44 ` David Edelsohn
2013-06-11 0:44 ` DJ Delorie
2013-06-11 6:06 ` Jakub Jelinek
2013-06-11 15:20 ` DJ Delorie
2013-06-07 22:56 ` Hans-Peter Nilsson
2013-06-08 15:05 ` Jakub Jelinek
2013-06-10 10:51 ` Bernd Schmidt
2013-06-10 10:56 ` Jakub Jelinek
2013-06-10 11:03 ` Bernd Schmidt
2013-06-10 11:52 ` Ulrich Weigand
2013-06-12 17:52 ` Edmar Wienskoski [this message]
2013-06-13 7:41 ` Alan Modra
2013-06-13 15:37 ` Alan Modra
2013-06-13 15:42 ` Jakub Jelinek
2013-06-13 22:48 ` Alan Modra
2013-06-14 9:00 ` Jakub Jelinek
2013-06-14 10:42 ` Alan Modra
2013-06-14 10:54 ` Jakub Jelinek
2013-06-14 14:57 ` Alan Modra
2013-06-17 23:37 ` David Edelsohn
[not found] ` <0EFAB2BDD0F67E4FB6CCC8B9F87D75692B5204DB@IRSMSX101.ger.corp.intel.com>
2013-06-19 7:02 ` FW: " Igor Zamyatin
2013-06-19 7:05 ` Jakub Jelinek
2013-06-19 7:12 Igor Zamyatin
2013-06-19 7:22 ` Jakub Jelinek
2013-06-19 8:38 ` Richard Biener
2013-06-19 8:44 ` Jakub Jelinek
2013-06-19 16:32 ` Mike Stump
2013-06-19 16:25 ` Mike Stump
2013-06-19 19:27 ` Kirill Yukhin
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=CAKkGaj7c6h++Rs8vFHCN5JDRcKf7JYAcFNBVkYWr3R4YRWgeEw@mail.gmail.com \
--to=edmarwjr@gmail.com \
--cc=Andreas.Krebbel@de.ibm.com \
--cc=bernds@codesourcery.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hp@axis.com \
--cc=hp@bitrange.com \
--cc=jakub@redhat.com \
--cc=jh@suse.cz \
--cc=rguenther@suse.de \
--cc=rth@redhat.com \
--cc=uweigand@de.ibm.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).