diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2006-01-11 16:43:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-11 22:04:50 -0500 |
commit | 636dd2b7def5c9c72551b51d4d516a65c269de08 (patch) | |
tree | 8a3c1ec030fc0924a96e54c0ec19d94f17ecc44e /include/asm-x86_64/bitops.h | |
parent | bd9cb64df1d99c07ea9672661ede6ca3ba5c6579 (diff) |
[PATCH] x86_64: fls in asm for x86_64
Use single instruction for find largest set bit on x86_64.
[Updated by Jan Beulich to fix wrong asm constraints in original
patch -AK]
Cc: jbeulich@novell.com
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-x86_64/bitops.h')
-rw-r--r-- | include/asm-x86_64/bitops.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h index 3638ffff87fd..eb4df23e1e41 100644 --- a/include/asm-x86_64/bitops.h +++ b/include/asm-x86_64/bitops.h | |||
@@ -397,6 +397,22 @@ static __inline__ int fls64(__u64 x) | |||
397 | } | 397 | } |
398 | 398 | ||
399 | /** | 399 | /** |
400 | * fls - find last bit set | ||
401 | * @x: the word to search | ||
402 | * | ||
403 | * This is defined the same way as ffs. | ||
404 | */ | ||
405 | static __inline__ int fls(int x) | ||
406 | { | ||
407 | int r; | ||
408 | |||
409 | __asm__("bsrl %1,%0\n\t" | ||
410 | "cmovzl %2,%0" | ||
411 | : "=&r" (r) : "rm" (x), "rm" (-1)); | ||
412 | return r+1; | ||
413 | } | ||
414 | |||
415 | /** | ||
400 | * hweightN - returns the hamming weight of a N-bit word | 416 | * hweightN - returns the hamming weight of a N-bit word |
401 | * @x: the word to weigh | 417 | * @x: the word to weigh |
402 | * | 418 | * |
@@ -434,9 +450,6 @@ static __inline__ int fls64(__u64 x) | |||
434 | #define minix_find_first_zero_bit(addr,size) \ | 450 | #define minix_find_first_zero_bit(addr,size) \ |
435 | find_first_zero_bit((void*)addr,size) | 451 | find_first_zero_bit((void*)addr,size) |
436 | 452 | ||
437 | /* find last set bit */ | ||
438 | #define fls(x) generic_fls(x) | ||
439 | |||
440 | #endif /* __KERNEL__ */ | 453 | #endif /* __KERNEL__ */ |
441 | 454 | ||
442 | #endif /* _X86_64_BITOPS_H */ | 455 | #endif /* _X86_64_BITOPS_H */ |