aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/hash.h')
-rw-r--r--include/linux/hash.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/hash.h b/include/linux/hash.h
index bd1754c7ecef..d0494c399392 100644
--- a/include/linux/hash.h
+++ b/include/linux/hash.h
@@ -37,6 +37,9 @@ static __always_inline u64 hash_64(u64 val, unsigned int bits)
37{ 37{
38 u64 hash = val; 38 u64 hash = val;
39 39
40#if defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
41 hash = hash * GOLDEN_RATIO_PRIME_64;
42#else
40 /* Sigh, gcc can't optimise this alone like it does for 32 bits. */ 43 /* Sigh, gcc can't optimise this alone like it does for 32 bits. */
41 u64 n = hash; 44 u64 n = hash;
42 n <<= 18; 45 n <<= 18;
@@ -51,6 +54,7 @@ static __always_inline u64 hash_64(u64 val, unsigned int bits)
51 hash += n; 54 hash += n;
52 n <<= 2; 55 n <<= 2;
53 hash += n; 56 hash += n;
57#endif
54 58
55 /* High bits are more random, so use them. */ 59 /* High bits are more random, so use them. */
56 return hash >> (64 - bits); 60 return hash >> (64 - bits);