Memory alignment optimization
Anton Titov
anton@titov.net
Tue May 28 09:46:00 GMT 2013
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
More information about the Gcc
mailing list