[llvm] [ADT] Update hash function of uint64_t for DenseMap (PR #95734)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 04:02:51 PDT 2024


================
@@ -137,7 +137,10 @@ template<> struct DenseMapInfo<unsigned long> {
   static inline unsigned long getTombstoneKey() { return ~0UL - 1L; }
 
   static unsigned getHashValue(const unsigned long& Val) {
-    return (unsigned)(Val * 37UL);
+    if constexpr (sizeof(Val) == 4)
+      return DenseMapInfo<unsigned>::getHashValue(Val);
+    else
+      return detail::combineHashValue(Val >> 32, Val);
----------------
RKSimon wrote:

@ChuanqiXu9  To silence MSVC warnings, could we change this to:
```
return detail::combineHashValue(Val >> (4 * sizeof(Val)), Val);
```

https://github.com/llvm/llvm-project/pull/95734


More information about the llvm-commits mailing list