This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Memory alignment optimization


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]