Re: [PATCH -tip 2/2] x86/hweight: Use POPCNT when available with X86_NATIVE_CPU option
From: Borislav Petkov
Date: Tue Mar 25 2025 - 13:12:04 EST
On Tue, Mar 25, 2025 at 05:48:38PM +0100, Uros Bizjak wrote:
> +#ifdef __POPCNT__
> + asm_inline (ASM_FORCE_CLR "popcntl %[val], %[cnt]"
> + : [cnt] "=&r" (res)
> + : [val] ASM_INPUT_RM (w));
> +#else
> asm_inline (ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
> "call __sw_hweight32",
> ASM_CLR "popcntl %[val], %[cnt]",
> X86_FEATURE_POPCNT)
> : [cnt] "=a" (res), ASM_CALL_CONSTRAINT
> : [val] REG_IN (w));
> -
> +#endif
A whopping 599 bytes which makes the asm more ugly.
Not worth the effort IMO.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette