This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Memory alignment optimization
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Anton Titov <anton at titov dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 28 May 2013 11:35:57 +0200
- Subject: Re: Memory alignment optimization
- References: <51A475CE dot 5050606 at titov dot net>
On Tue, May 28, 2013 at 12:15:58PM +0300, Anton Titov wrote:
> Hello everybody,
>
> (I'm not a member, CC me in replies)
>
> I'm trying to force gcc to trust me that my memory allocation
> function is returning aligned memory. So far I tried everything I
> found with no luck. What I have is:
>
snip
> alignedvoid *aptr__=_mp_malloc(pool, asize__);\
> memset(aptr__, 0, asize__);\
snip
> to produce assembly code that calls _mp_malloc and afterwards
> assumes that the returned value is properly aligned for fast store
> and hopefully makes use of the fact that size is also rounded
> properly so no code for filling the trailing odd bytes is generated.
>
Did you tried if following gets optimized out?
(((long)atpr)%16 != 0) abort();
Code generated by memset is quite suboptimal, I do not know if this is
caused by gcc not handling what memset generates or because
expansion happens after analysis that uses alignment.