[llvm] [DenseMap] Update combineHashValue (PR #95970)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 17:39:34 PDT 2024
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/95970
>From 2ede7c10f0fce95cfaf5980133a3226b6a56814d Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Tue, 18 Jun 2024 11:49:20 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
llvm/include/llvm/ADT/DenseMapInfo.h | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h
index 5b7dce7b53c62..ba05309e4e413 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -26,17 +26,15 @@ namespace llvm {
namespace detail {
/// Simplistic combination of 32-bit hash values into 32-bit hash values.
+/// This uses a Murmur3-type mixer "Moremur" from Pelle Evensen.
static inline unsigned combineHashValue(unsigned a, unsigned b) {
- uint64_t key = (uint64_t)a << 32 | (uint64_t)b;
- key += ~(key << 32);
- key ^= (key >> 22);
- key += ~(key << 13);
- key ^= (key >> 8);
- key += (key << 3);
- key ^= (key >> 15);
- key += ~(key << 27);
- key ^= (key >> 31);
- return (unsigned)key;
+ uint64_t x = (uint64_t)a << 32 | (uint64_t)b;
+ x ^= x >> 27;
+ x *= 0x3C79AC492BA7B653UL;
+ x ^= x >> 33;
+ x *= 0x1C69B3F74AC4AE35UL;
+ x ^= x >> 27;
+ return (unsigned)x;
}
} // end namespace detail
More information about the llvm-commits
mailing list