Re: [PATCH] x86: Optimize variable_test_bit()

From: Peter Zijlstra
Date: Mon May 04 2015 - 09:43:26 EST


On Fri, May 01, 2015 at 05:16:30PM +0200, Peter Zijlstra wrote:

> diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
> index cfe3b954d5e4..bcf4fa77c04f 100644
> --- a/arch/x86/include/asm/bitops.h
> +++ b/arch/x86/include/asm/bitops.h
> @@ -313,6 +313,15 @@ static __always_inline int constant_test_bit(long nr, const volatile unsigned lo
>
> static inline int variable_test_bit(long nr, volatile const unsigned long *addr)
> {
> +#ifdef CC_HAVE_ASM_GOTO
> + asm_volatile_goto ("bt %1, %0\n\t"
> + "jc %l[cc_label]"
> + : : "m" (*(unsigned long *)addr), "Ir" (nr)
> + : : cc_label);
> + return 0;
> +cc_label:
> + return 1;
> +#else

I figured I'd try both jc and jnc versions:

text data bss dec hex filename
12203914 1738112 1081344 15023370 e53d0a defconfig-build/vmlinux
12204228 1738112 1081344 15023684 e53e44 defconfig-build/vmlinux-jc
12203240 1738112 1081344 15022696 e53a68 defconfig-build/vmlinux-jnc

Clearly I picked the wrong one :-) It also shows there is real value in
exposing this decision to GCC.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/