aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/arch_hweight.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
index 9686c3d9ff73..259a7c1ef709 100644
--- a/arch/x86/include/asm/arch_hweight.h
+++ b/arch/x86/include/asm/arch_hweight.h
@@ -21,7 +21,7 @@
21 * ARCH_HWEIGHT_CFLAGS in <arch/x86/Kconfig> for the respective 21 * ARCH_HWEIGHT_CFLAGS in <arch/x86/Kconfig> for the respective
22 * compiler switches. 22 * compiler switches.
23 */ 23 */
24static inline unsigned int __arch_hweight32(unsigned int w) 24static __always_inline unsigned int __arch_hweight32(unsigned int w)
25{ 25{
26 unsigned int res = 0; 26 unsigned int res = 0;
27 27
@@ -42,20 +42,23 @@ static inline unsigned int __arch_hweight8(unsigned int w)
42 return __arch_hweight32(w & 0xff); 42 return __arch_hweight32(w & 0xff);
43} 43}
44 44
45#ifdef CONFIG_X86_32
45static inline unsigned long __arch_hweight64(__u64 w) 46static inline unsigned long __arch_hweight64(__u64 w)
46{ 47{
47 unsigned long res = 0;
48
49#ifdef CONFIG_X86_32
50 return __arch_hweight32((u32)w) + 48 return __arch_hweight32((u32)w) +
51 __arch_hweight32((u32)(w >> 32)); 49 __arch_hweight32((u32)(w >> 32));
50}
52#else 51#else
52static __always_inline unsigned long __arch_hweight64(__u64 w)
53{
54 unsigned long res = 0;
55
53 asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) 56 asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
54 : "="REG_OUT (res) 57 : "="REG_OUT (res)
55 : REG_IN (w)); 58 : REG_IN (w));
56#endif /* CONFIG_X86_32 */
57 59
58 return res; 60 return res;
59} 61}
62#endif /* CONFIG_X86_32 */
60 63
61#endif 64#endif