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] Use memcpy in memmove when possible


On 4/09/2012, at 5:47 PM, OndÅej BÃlka wrote:

> On Tue, Sep 04, 2012 at 05:17:52PM +1200, Maxim Kuvyrkov wrote:
>> On 2/09/2012, at 12:51 AM, H.J. Lu wrote:
>> 
>>> On Sat, Sep 1, 2012 at 1:16 AM, Maxim Kuvyrkov <maxim@codesourcery.com> wrote:
>>>> Several architectures, e.g., MIPS, have well-optimized memcpy implementations, which can also be used for either forward or backward direction in memmove.  This patch adds an option for ports to define MEMCPY_OK_FOR_{FWD,BWD}_MEMMOVE macros to make generic memmove use memcpy when safe to do so.
>>>> 
>>>> This patch speeds up forward-direction memmove on MIPS by 50%.  Tested with no regressions.
>>>> 
>>> 
>>> If memcpy is safe for memmove, you can simply make memmove an alias of
>>> memcpy in memcpy source.  Why do you need to update string/memmove.c?
>> 
>> Because memcpy is safe only for a particular direction of memmove in case input and output areas intersect.
> 
> Which wouldn't be problem if memcpy had flag to reverse direction.

This is a good point, but it doesn't change this patch [much].  Ports still need to implement the backward memcpy, which often means tweaking assembly in non-obvious ways and testing.

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics



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