This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __builtin_memcpy and alignment assumptions
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Eric Botcazou <ebotcazou at libertysurf dot fr>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, gcc at gcc dot gnu dot org, Steve Ellcey <sellcey at imgtec dot com>
- Date: Fri, 8 Jan 2016 12:32:20 +0100
- Subject: Re: __builtin_memcpy and alignment assumptions
- Authentication-results: sourceware.org; auth=none
- References: <5e991791-a201-4b8d-89fd-78db873368c7 at BAMAIL02 dot ba dot imgtec dot org> <CAFiYyc3yPAusG2eqw5KoC2eEFBbJyP=ovGGytCYnfG9X4t=S3g at mail dot gmail dot com> <1482639 dot JCa9WsCs7z at polaris>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jan 08, 2016 at 12:24:49PM +0100, Eric Botcazou wrote:
> > See some existing PR. The GCC middle-end cannot assume that pointers
> > are aligned according to their type (while at least the C language would
> > support that notion).
>
> Only on x86. It could (and used to) do it on strict-alignment architectures.
I think we only assume it if the pointer is actually dereferenced, otherwise
it just breaks too much code in the wild. And while memcpy dereferences, it
dereferences it through a char * cast, and thus only the minimum alignment
is assumed.
Jakub