This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Memory alignment optimization
- From: Anton Titov <anton at titov dot net>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 28 May 2013 12:46:17 +0300
- Subject: Re: Memory alignment optimization
- References: <51A475CE dot 5050606 at titov dot net> <20130528093557 dot GA13267 at domone dot kolej dot mff dot cuni dot cz>
On 28.05.2013 12:35, OndÅej BÃlka wrote:
Did you tried if following gets optimized out?
(((long)atpr)%16 != 0) abort();
No, it is not, it generates:
406eb0: a8 0f test $0xf,%al
406eb2: 48 89 44 24 58 mov %rax,0x58(%rsp) // unrelated
406eb7: 0f 85 79 16 00 00 jne 408536
<serve_file+0x16c6> // on this address there is a call to abort
However __builtin_assume_aligned fixes this and it gets optimized out:
alignedvoid *aptr__=__builtin_assume_aligned(_mp_malloc(pool, asize__),
MP_ALIGN);
if (((long)aptr__)%16 != 0) abort();
Best,
Anton