From: Denys Vlasenko <dvlasenk@redhat.com>
To: Rich Felker <dalias@libc.org>, Denys Vlasenko <vda.linux@googlemail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] x86/memset: avoid performing final store twice
Date: Mon, 12 Oct 2020 14:18:54 +0200 [thread overview]
Message-ID: <08fd37cf-971c-2e6f-1b45-1442566b3416@redhat.com> (raw)
In-Reply-To: <20201011002514.GF17637@brightrain.aerifal.cx>
On 10/11/20 2:25 AM, Rich Felker wrote:
> On Sun, Oct 04, 2020 at 12:32:09AM +0200, Denys Vlasenko wrote:
>> From: Denys Vlasenko <dvlasenk@redhat.com>
>>
>> For not very short NBYTES case:
>>
>> To handle the tail alignment, the code performs a potentially
>> misaligned word store to fill the final 8 bytes of the buffer.
>> This is done even if the buffer's end is aligned.
>>
>> Eventually code fills the rest of the buffer, which is a multiple
>> of 8 bytes now, with NBYTES / 8 aligned word stores.
>>
>> However, this means that if NBYTES *was* divisible by 8,
>> we store last word too, again.
>>
>> This patch decrements byte count before dividing it by 8,
>> making one less store in "NBYTES is divisible by 8" case,
>> and not changing anything in all other cases.
>>
...
>> --- a/src/string/x86_64/memset.s
>> +++ b/src/string/x86_64/memset.s
>> @@ -53,7 +53,7 @@ memset:
>> 2: test $15,%edi
>> mov %rdi,%r8
>> mov %rax,-8(%rdi,%rdx)
>> - mov %rdx,%rcx
>> + lea -1(%rdx),%rcx
>> jnz 2f
>>
>> 1: shr $3,%rcx
>> --
>> 2.25.0
>
> Does this have measurably better performance on a system you've tested
> it on?
I did not test performance, I predict it will hardly be detectable.
prev parent reply other threads:[~2020-10-12 12:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-03 22:32 Denys Vlasenko
2020-10-11 0:25 ` Rich Felker
2020-10-12 12:18 ` Denys Vlasenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08fd37cf-971c-2e6f-1b45-1442566b3416@redhat.com \
--to=dvlasenk@redhat.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=vda.linux@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).