summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Ren Zibei <31380016+renzibei@users.noreply.github.com>2022-03-29 04:12:44 +0800
committerGravatar GitHub <noreply@github.com>2022-03-28 16:12:44 -0400
commit0c6302fe427963ec5c471d3ee660120682ab15f7 (patch)
tree06d4807b460faebcd1665b589bd61b92fd70c939 /absl
parentca80034f59f43eddb6c4c72314572c0e212bf98f (diff)
Replace the implementation of the Mix function in arm64 back to 128bit multiplication (#1094)
Diffstat (limited to 'absl')
-rw-r--r--absl/hash/internal/hash.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h
index f8103334..45dfdd46 100644
--- a/absl/hash/internal/hash.h
+++ b/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