x86: Add optimized popcnt variants
Add support for the hardware version of the Hamming weight function, popcnt, present in CPUs which advertize it under CPUID, Function 0x0000_0001_ECX[23]. On CPUs which don't support it, we fallback to the default lib/hweight.c sw versions. A synthetic benchmark comparing popcnt with __sw_hweight64 showed almost a 3x speedup on a F10h machine. Signed-off-by:Borislav Petkov <borislav.petkov@amd.com> LKML-Reference: <20100318112015.GC11152@aftab> Signed-off-by:
H. Peter Anvin <hpa@zytor.com>
Showing
- arch/x86/Kconfig 5 additions, 0 deletionsarch/x86/Kconfig
- arch/x86/include/asm/alternative.h 6 additions, 3 deletionsarch/x86/include/asm/alternative.h
- arch/x86/include/asm/arch_hweight.h 59 additions, 0 deletionsarch/x86/include/asm/arch_hweight.h
- arch/x86/include/asm/bitops.h 3 additions, 1 deletionarch/x86/include/asm/bitops.h
- include/asm-generic/bitops/arch_hweight.h 18 additions, 4 deletionsinclude/asm-generic/bitops/arch_hweight.h
- lib/Makefile 3 additions, 0 deletionslib/Makefile
- lib/hweight.c 10 additions, 10 deletionslib/hweight.c
- scripts/Makefile.lib 4 additions, 0 deletionsscripts/Makefile.lib
arch/x86/include/asm/arch_hweight.h
0 → 100644
Please register or sign in to comment