From: Stephen Hemminger <shemminger@osdl.org>
To: Andi Kleen <ak@suse.de>, Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] fls in asm for x86_64
Date: Fri, 2 Dec 2005 16:24:36 -0800 [thread overview]
Message-ID: <20051202162436.2a96313b@localhost.localdomain> (raw)
In-Reply-To: <20051202162240.746c436e@localhost.localdomain>
Use single instruction for find largest set bit on x86_64.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
--- orig/include/asm-x86_64/bitops.h
+++ new/include/asm-x86_64/bitops.h
@@ -370,6 +370,22 @@ static __inline__ int ffs(int x)
}
/**
+ * fls - find last bit set
+ * @x: the word to search
+ *
+ * This is defined the same way as ffs.
+ */
+static __inline__ int fls(int x)
+{
+ int r;
+
+ __asm__("bsrl %1,%0\n\t"
+ "cmovzl %2,%0"
+ : "=r" (r) : "rm" (x), "r" (-1));
+ return r+1;
+}
+
+/**
* hweightN - returns the hamming weight of a N-bit word
* @x: the word to weigh
*
@@ -407,9 +423,6 @@ static __inline__ int ffs(int x)
#define minix_find_first_zero_bit(addr,size) \
find_first_zero_bit((void*)addr,size)
-/* find last set bit */
-#define fls(x) generic_fls(x)
-
#endif /* __KERNEL__ */
#endif /* _X86_64_BITOPS_H */
next prev parent reply other threads:[~2005-12-03 0:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-03 0:22 [PATCH] fls in asm for i386 Stephen Hemminger
2005-12-03 0:24 ` Stephen Hemminger [this message]
2005-12-03 1:44 ` [PATCH] fls in asm for x86_64 Andi Kleen
2005-12-05 13:46 ` [PATCH] fls in asm for i386 Pádraig Brady
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=20051202162436.2a96313b@localhost.localdomain \
--to=shemminger@osdl.org \
--cc=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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