Replace the implementation of the Mix function in arm64 back to 128bit multiplication (#1094)

pull/1157/head
Ren Zibei 3 years ago committed by GitHub
parent ca80034f59
commit 0c6302fe42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      absl/hash/internal/hash.h

@ -1090,15 +1090,10 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
}
ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t Mix(uint64_t state, uint64_t v) {
#if defined(__aarch64__)
// On AArch64, calculating a 128-bit product is inefficient, because it
// requires a sequence of two instructions to calculate the upper and lower
// halves of the result.
using MultType = uint64_t;
#else
// Though the 128-bit product on AArch64 needs two instructions, it is
// still a good balance between speed and hash quality.
using MultType =
absl::conditional_t<sizeof(size_t) == 4, uint64_t, uint128>;
#endif
// We do the addition in 64-bit space to make sure the 128-bit
// multiplication is fast. If we were to do it as MultType the compiler has
// to assume that the high word is non-zero and needs to perform 2

Loading…
Cancel
Save