linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: David Howells <dhowells@redhat.com>
Cc: linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/3] X86: Optimise fls(), ffs() and fls64()
Date: Wed, 13 Jan 2010 21:15:13 +0100	[thread overview]
Message-ID: <10f740e81001131215y6f15b25bq3bfa2ce2cea164a9@mail.gmail.com> (raw)
In-Reply-To: <20100113193923.22272.87546.stgit@warthog.procyon.org.uk>

On Wed, Jan 13, 2010 at 20:39, David Howells <dhowells@redhat.com> wrote:
> diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
> index b097cf8..f81e04c 100644
> --- a/include/asm-generic/bitops/fls64.h
> +++ b/include/asm-generic/bitops/fls64.h
> @@ -18,16 +18,25 @@
>  static __always_inline int fls64(__u64 x)
>  {
>        __u32 h = x >> 32;
> -       if (h)
> -               return fls(h) + 32;
> -       return fls(x);
> +       int bitpos = -1;
> +
> +       asm("bsrl       %1,%0   \n"
> +           "subl       %2,%0   \n"
> +           "bsrl       %3,%0   \n"
> +           : "+r" (bitpos)
> +           : "rm" (x), "i"(32), "rm" (h));
> +
> +       return bitpos + 33;
>  }
>  #elif BITS_PER_LONG == 64
>  static __always_inline int fls64(__u64 x)
>  {
> -       if (x == 0)
> -               return 0;
> -       return __fls(x) + 1;
> +       long bitpos = -1;
> +
> +       asm("bsrq %1,%0"
> +           : "+r" (bitpos)
> +           : "rm" (x));
> +       return bitpos + 1;
>  }
>  #else
>  #error BITS_PER_LONG not 32 or 64

Why do you put x86 assembler in asm-generic? Those files are supposed
to be platform-agnostic.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

  parent reply	other threads:[~2010-01-13 20:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-13 19:39 [PATCH 1/3] X86: Optimise fls(), ffs() and fls64() David Howells
2010-01-13 19:39 ` [PATCH 2/3] Adjust the comment on get_order() to describe the size==0 case David Howells
2010-01-13 19:39 ` [PATCH 3/3] Optimise get_order() David Howells
2010-01-13 20:15 ` Geert Uytterhoeven [this message]
2010-01-13 21:59 ` [PATCH 1/3] X86: Optimise fls(), ffs() and fls64() David Howells
     [not found] <4BACCB4E.7010108@draigBrady.com>
2010-03-26 14:42 ` David Howells
2010-03-26 17:23   ` Linus Torvalds
2010-03-26 17:37     ` Scott Lurndal
2010-03-26 17:42       ` Linus Torvalds
2010-04-06 13:57         ` Jamie Lokier
2010-04-06 14:40           ` Linus Torvalds
2010-03-26 17:42   ` David Howells
2010-03-26 17:45     ` Linus Torvalds
2010-03-26 17:58       ` Ralf Baechle
2010-03-26 18:03         ` Linus Torvalds
2010-03-26 18:16           ` Matthew Wilcox
2010-04-06 13:30           ` Matthew Wilcox
2010-04-14 11:49           ` David Howells
2010-04-14 14:30             ` Avi Kivity
2010-04-15  8:48             ` David Howells
2010-04-15  8:49               ` Avi Kivity
2010-04-15 11:41                 ` Jamie Lokier
2010-03-26 17:52     ` Matthew Wilcox
2010-04-14 13:13   ` David Howells

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=10f740e81001131215y6f15b25bq3bfa2ce2cea164a9@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=dhowells@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).