This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RS6000] strict alignment for little-endian
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, David Edelsohn <dje dot gcc at gmail dot com>, Michael Meissner <meissner at linux dot vnet dot ibm dot com>
- Date: Tue, 19 Nov 2013 10:42:08 +0100
- Subject: Re: [RS6000] strict alignment for little-endian
- Authentication-results: sourceware.org; auth=none
- References: <20130607012439 dot GH6878 at bubble dot grove dot modra dot org> <20130610191404 dot GA300 at ibm-tiger dot the-meissners dot org> <20131119065927 dot GB22514 at bubble dot grove dot modra dot org>
> It's not desirable since gcc easily loses track of alignment, for instance
> with -mstrict-align
>
> void foo (char *p, char *q)
> {
> __builtin_memcpy (p, q, 4);
> }
>
> generates
>
> lbz 7,0(4)
> lbz 8,1(4)
> lbz 10,2(4)
> lbz 9,3(4)
> stb 7,0(3)
> stb 8,1(3)
> stb 10,2(3)
> stb 9,3(3)
> blr
>
> whereas -mno-strict-align gives
>
> lwz 9,0(4)
> stw 9,0(3)
> blr
I presume you meant:
void foo (int *p, int *q)
{
__builtin_memcpy (p, q, 4);
}
which will yield the same generated code. Yes, it's an unfortunate regression
on strict-alignment platforms, up to 4.5 the generated code was the same.
--
Eric Botcazou