This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: memmove optimization on X86_64


On 5/6/07, Aurelien Jarno <aurelien@aurel32.net> wrote:
memmove should still work when src and dest are shift by only one byte.
Doing 64 bits by 64 bits copy won't work in that case.

In this case you must copy from the end to the start, initially aligning with byte sized copies, followed by word sized copies, and finally aligning with bytes sized copies.

See string/memmove.c.

The compiler builtin __builtin_memmove can be inlined, and also does
the same optimizations.

See gcc/builtins.c (expand_builtin_memmove).

The builtin memmove is decomposed into a memcpy which is
expand_builtin_memcpy. Note that if you confuse the compiler and for
example it can't determine you passed a pointer to memmove's first
argument (validate_arglist), it will default to calling memmove
provided by the C library e.g. expand_call at the end of
expand_builtin.

Cheers,
Carlos O'Donell


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