From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: "George Spelvin" <linux@horizon.com>
Cc: akpm@linux-foundation.org, chris@chris-wilson.co.uk,
davem@davemloft.net, dborkman@redhat.com,
hannes@stressinduktion.org, klimov.linux@gmail.com,
laijs@cn.fujitsu.com, linux-kernel@vger.kernel.org,
msalter@redhat.com, takahiro.akashi@linaro.org, tgraf@suug.ch,
valentinrothberg@gmail.com, yury.norov@gmail.com
Subject: Re: [PATCH v3 1/3] lib: find_*_bit reimplementation
Date: Fri, 13 Feb 2015 11:13:43 +0100 [thread overview]
Message-ID: <87386ayv8o.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <20150212234603.30908.qmail@ns.horizon.com> (George Spelvin's message of "12 Feb 2015 18:46:03 -0500")
On Fri, Feb 13 2015, "George Spelvin" <linux@horizon.com> wrote:
>> the main loop is 20--3b. The test instruction at 2e seems to be
>> redundant. The same at 37: the sub instruction already sets plenty of
>> flags that could be used, so explicitly comparing %rbx to -1 seems
>> redundant.
>
> Er... I think you hand-edited that code; it's wrong. The loop assumes that
> %rbx is in units of words, but the prologue sets it up in units of bits.
No, but I messed up the source by hand :-) My DIV_ROUND_UP macro was
bogus. Well spotted. Fixing that I still see the redundant cmp and
test, though.
> The mov to %rcx is also redundant, since it could be eliminated with
> some minor rescheduling.
>
> The code generation I *want* for that function is:
>
> # addr in %rdi, size in %rsi
> movl %esi, %ecx
> leaq 0x3f(%rsi), %rax
> negl %ecx
> movq $-1, %rdx
> shrq $6, %rax
> shrq %cl, %rdx
> jmp 2f
> 1:
> movq $-1, %rdx
> 2:
> subq $1, %rax
> jc 3f
> andq (%rdi,%rax,8), %rdx
> jeq 1b
>
> bsrq %rdx, %rdx
> salq $6, %rax
> addq %rdx, %rax
> ret
> 3:
> movq %rsi, %rax
> retq
Nice. But I don't think find_last_bit is important enough to warrant
arch-specific versions.
So, where are we with this? Have we reached some kind of consensus?
Rasmus
next prev parent reply other threads:[~2015-02-13 10:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-08 14:10 [PATCH v3 0/3] lib: find_*_bit reimplementation Yury Norov
2015-02-08 14:10 ` [PATCH v3 1/3] " Yury Norov
2015-02-08 18:48 ` George Spelvin
2015-02-09 8:32 ` George Spelvin
2015-02-09 11:53 ` Rasmus Villemoes
2015-02-09 16:45 ` George Spelvin
2015-02-11 22:14 ` Rasmus Villemoes
2015-02-11 23:05 ` Yury
2015-02-12 8:15 ` George Spelvin
2015-02-12 9:58 ` Rasmus Villemoes
2015-02-12 23:46 ` George Spelvin
2015-02-13 10:13 ` Rasmus Villemoes [this message]
2015-02-08 14:10 ` [PATCH v3 2/3] lib: move find_last_bit to lib/find_next_bit.c Yury Norov
2015-02-08 14:10 ` [PATCH v3 3/3] lib: rename lib/find_next_bit.c to lib/find_bit.c Yury Norov
2015-02-17 2:35 ` [PATCH v4 0/3] lib: find_*_bit reimplementation Yury Norov
2015-02-17 2:35 ` [PATCH v4 1/3] " Yury Norov
2015-02-18 17:57 ` Rasmus Villemoes
2015-02-17 2:35 ` [PATCH v4 2/3] lib: move find_last_bit to lib/find_next_bit.c Yury Norov
2015-02-17 2:35 ` [PATCH v4 3/3] lib: rename lib/find_next_bit.c to lib/find_bit.c Yury Norov
2015-02-22 17:24 ` [PATCH v5 0/3] lib: find_*_bit reimplementation Yury Norov
2015-02-22 17:24 ` [PATCH v5 1/3] " Yury Norov
2015-02-23 21:50 ` Rasmus Villemoes
2015-02-24 0:29 ` George Spelvin
2015-02-22 17:24 ` [PATCH v5 2/3] lib: move find_last_bit to lib/find_next_bit.c Yury Norov
2015-02-22 17:24 ` [PATCH v5 3/3] lib: rename lib/find_next_bit.c to lib/find_bit.c Yury Norov
2015-02-24 0:40 ` [PATCH v5 0/3] lib: find_*_bit reimplementation Andrew Morton
2015-03-08 18:17 ` Yury Norov
[not found] <CAAH8bW-mk0kk-GKDNny6hsjrbcjwdcAacsF_DEaXmNG==hXhRw@mail.gmail.com>
2015-02-13 21:09 ` [PATCH v3 1/3] " George Spelvin
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=87386ayv8o.fsf@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.org \
--cc=chris@chris-wilson.co.uk \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=hannes@stressinduktion.org \
--cc=klimov.linux@gmail.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
--cc=msalter@redhat.com \
--cc=takahiro.akashi@linaro.org \
--cc=tgraf@suug.ch \
--cc=valentinrothberg@gmail.com \
--cc=yury.norov@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