From: Richard Weinberger <richard@nod.at>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: lukes357@gmail.com, Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] small update for strlen, strnlen, use less cpu instructions
Date: Tue, 16 Jun 2015 13:43:43 +0200 [thread overview]
Message-ID: <55800BEF.7000301@nod.at> (raw)
In-Reply-To: <CACVxJT-rvN-NX-Z+Eby9uYkubka9_a5ZnEPCBcRT6FRwdVZW3Q@mail.gmail.com>
Am 16.06.2015 um 13:41 schrieb Alexey Dobriyan:
>> Now strlen() increments a variable for each character it faces,
>> hence it will consume more cycles.
>
> It doesn't matter if there is a dependency in a loop:
>
> Before:
> 520: 48 83 c0 01 add $0x1,%rax
> 524: 80 38 00 cmpb $0x0,(%rax)
> 527: 75 f7 jne 520
>
> After:
> 500: 48 83 c0 01 add $0x1,%rax
> 504: 80 3c 07 00 cmpb $0x0,(%rdi,%rax,1)
> 508: 75 f6 jne 500
>
Hmmm.
Thanks for pointing this out!
Thanks,
//richard
next prev parent reply other threads:[~2015-06-16 11:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-16 11:41 [PATCH] small update for strlen, strnlen, use less cpu instructions Alexey Dobriyan
2015-06-16 11:43 ` Richard Weinberger [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-06-16 9:40 Orestes Leal Rodriguez
2015-06-16 10:03 ` Mihai Donțu
2015-06-16 9:36 Orestes Leal Rodriguez
2015-06-16 9:28 Orestes Leal Rodriguez
2015-06-16 10:37 ` Richard Weinberger
2015-06-16 18:56 ` Luke Skywalker
2015-06-16 19:06 ` Darth Vader
2015-06-16 9:26 Luke Skywalker
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=55800BEF.7000301@nod.at \
--to=richard@nod.at \
--cc=adobriyan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukes357@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox