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: [PATCH RFC] Imporve 64bit memcpy performance for Haswell CPU with AVX instruction


Ling Ma wrote:
[...]
>>> +#ifdef USE_AS_MEMMOVE
>>> +	cmp	%rsi, %rdi
>>> +	jae	L(copy_backward)
>>> +#endif
>> this could be unpredictable branch, backward copy only when overlap is
>> better.
> 
> If we compare whether it is overlap, have to introduce another branch
> instruction, so keep it.

No, combined overlap/backward copy detection needs only *single* branch
instruction (but some extra arithmetic). See generic C code or i686 assembler
version:
=== cut string/memmove.c ===
 /* This test makes the forward copying code be used whenever possible.
    Reduces the working set.  */
 if (dstp - srcp >= len)       /* *Unsigned* compare!  */
   {
     /* Copy from the beginning to the end.  */
=== cut sysdeps/i386/i686/memmove.S ===
[...]


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