lkml.org 
[lkml]   [2021]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] lib/string: Bring optimized memcmp from glibc
From
Date


On 21.07.21 г. 22:26, Linus Torvalds wrote:
> On Wed, Jul 21, 2021 at 11:45 AM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> I can do the mutual alignment too, but I'd actually prefer to do it as
>> a separate patch, for when there are numbers for that.
>>
>> And I wouldn't do it as a byte-by-byte case, because that's just stupid.
>
> Here's that "try to align one of the pointers in order to avoid the
> lots-of-unaligned case" patch.
>
> It's not quite as simple, and the generated assembly isn't quite as
> obvious. But it still generates code that looks good, it's just that
> the code to align the first pointer ends up being a bit harder to
> read.
>

This one also works, tested only on x86-64. Looking at the perf diff:

30.44% -28.66% [kernel.vmlinux] [k] memcmp


Comparing your 2 version that you submitted the difference is:

1.05% +0.72% [kernel.vmlinux] [k] memcmp


So the pointer alignment one is slightly more expensive. However those
measurements were done only on x86-64.

Now on a more practical note, IIUC your 2nd version makes sense if the
cost of doing a one unaligned access in the loop body is offset by the
fact we are doing a native word-sized comparison, right?


<snip>

\
 
 \ /
  Last update: 2021-07-22 19:35    [W:0.189 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site