Make hash_64() use a 64-bit multiply when appropriate
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 13 Sep 2014 18:24:03 +0000 (11:24 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 15 Jun 2016 20:28:14 +0000 (21:28 +0100)
commitb37e88cd2afe14184cdeb1007f8b6df3c4567b23
treec7882a68f56f541dcc14d3307c275ffed502e4ea
parent5145514ddb58c05d26bd23d6443affd20dbb2755
Make hash_64() use a 64-bit multiply when appropriate

commit 23d0db76ffa13ffb95229946e4648568c3c29db5 upstream.

The hash_64() function historically does the multiply by the
GOLDEN_RATIO_PRIME_64 number with explicit shifts and adds, because
unlike the 32-bit case, gcc seems unable to turn the constant multiply
into the more appropriate shift and adds when required.

However, that means that we generate those shifts and adds even when the
architecture has a fast multiplier, and could just do it better in
hardware.

Use the now-cleaned-up CONFIG_ARCH_HAS_FAST_MULTIPLIER (together with
"is it a 64-bit architecture") to decide whether to use an integer
multiply or the explicit sequence of shift/add instructions.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[bwh: This has no immediate effect in 3.2 because nothing defines
 CONFIG_ARCH_HAS_FAST_MULTIPLIER. However the following fix removes
 that condition.]
include/linux/hash.h