aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-09-13 14:14:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-09-13 14:14:53 -0400
commit72d931046030beb2d13dad6d205be0e228618432 (patch)
tree2a1f26ae904f9476b4269ff0d9a677580d0c8c9b
parent186cec317e87b85b296713426fa39eaa41ec6056 (diff)
Make ARCH_HAS_FAST_MULTIPLIER a real config variable
It used to be an ad-hoc hack defined by the x86 version of <asm/bitops.h> that enabled a couple of library routines to know whether an integer multiply is faster than repeated shifts and additions. This just makes it use the real Kconfig system instead, and makes x86 (which was the only architecture that did this) select the option. NOTE! Even for x86, this really is kind of wrong. If we cared, we would probably not enable this for builds optimized for netburst (P4), where shifts-and-adds are generally faster than multiplies. This patch does *not* change that kind of logic, though, it is purely a syntactic change with no code changes. This was triggered by the fact that we have other places that really want to know "do I want to expand multiples by constants by hand or not", particularly the hash generation code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/include/asm/bitops.h2
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/hweight.c4
-rw-r--r--lib/string.c4
5 files changed, 8 insertions, 6 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 778178f4c7d1..36327438caf0 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -23,6 +23,7 @@ config X86
23 def_bool y 23 def_bool y
24 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 24 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
25 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS 25 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
26 select ARCH_HAS_FAST_MULTIPLIER
26 select ARCH_MIGHT_HAVE_PC_PARPORT 27 select ARCH_MIGHT_HAVE_PC_PARPORT
27 select ARCH_MIGHT_HAVE_PC_SERIO 28 select ARCH_MIGHT_HAVE_PC_SERIO
28 select HAVE_AOUT if X86_32 29 select HAVE_AOUT if X86_32
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index afcd35d331de..cfe3b954d5e4 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -497,8 +497,6 @@ static __always_inline int fls64(__u64 x)
497 497
498#include <asm-generic/bitops/sched.h> 498#include <asm-generic/bitops/sched.h>
499 499
500#define ARCH_HAS_FAST_MULTIPLIER 1
501
502#include <asm/arch_hweight.h> 500#include <asm/arch_hweight.h>
503 501
504#include <asm-generic/bitops/const_hweight.h> 502#include <asm-generic/bitops/const_hweight.h>
diff --git a/lib/Kconfig b/lib/Kconfig
index a5ce0c7f6c30..54cf309a92a5 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -51,6 +51,9 @@ config PERCPU_RWSEM
51config ARCH_USE_CMPXCHG_LOCKREF 51config ARCH_USE_CMPXCHG_LOCKREF
52 bool 52 bool
53 53
54config ARCH_HAS_FAST_MULTIPLIER
55 bool
56
54config CRC_CCITT 57config CRC_CCITT
55 tristate "CRC-CCITT functions" 58 tristate "CRC-CCITT functions"
56 help 59 help
diff --git a/lib/hweight.c b/lib/hweight.c
index b7d81ba143d1..9a5c1f221558 100644
--- a/lib/hweight.c
+++ b/lib/hweight.c
@@ -11,7 +11,7 @@
11 11
12unsigned int __sw_hweight32(unsigned int w) 12unsigned int __sw_hweight32(unsigned int w)
13{ 13{
14#ifdef ARCH_HAS_FAST_MULTIPLIER 14#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
15 w -= (w >> 1) & 0x55555555; 15 w -= (w >> 1) & 0x55555555;
16 w = (w & 0x33333333) + ((w >> 2) & 0x33333333); 16 w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
17 w = (w + (w >> 4)) & 0x0f0f0f0f; 17 w = (w + (w >> 4)) & 0x0f0f0f0f;
@@ -49,7 +49,7 @@ unsigned long __sw_hweight64(__u64 w)
49 return __sw_hweight32((unsigned int)(w >> 32)) + 49 return __sw_hweight32((unsigned int)(w >> 32)) +
50 __sw_hweight32((unsigned int)w); 50 __sw_hweight32((unsigned int)w);
51#elif BITS_PER_LONG == 64 51#elif BITS_PER_LONG == 64
52#ifdef ARCH_HAS_FAST_MULTIPLIER 52#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
53 w -= (w >> 1) & 0x5555555555555555ul; 53 w -= (w >> 1) & 0x5555555555555555ul;
54 w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul); 54 w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul);
55 w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful; 55 w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful;
diff --git a/lib/string.c b/lib/string.c
index 992bf30af759..f3c6ff596414 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -807,9 +807,9 @@ void *memchr_inv(const void *start, int c, size_t bytes)
807 return check_bytes8(start, value, bytes); 807 return check_bytes8(start, value, bytes);
808 808
809 value64 = value; 809 value64 = value;
810#if defined(ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64 810#if defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
811 value64 *= 0x0101010101010101; 811 value64 *= 0x0101010101010101;
812#elif defined(ARCH_HAS_FAST_MULTIPLIER) 812#elif defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER)
813 value64 *= 0x01010101; 813 value64 *= 0x01010101;
814 value64 |= value64 << 32; 814 value64 |= value64 << 32;
815#else 815#else