[all-commits] [llvm/llvm-project] ad79a1: [ADT] Update hash function of uint64_t for DenseMa...
Chuanqi Xu via All-commits
all-commits at lists.llvm.org
Wed Jun 19 18:58:34 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ad79a14c9e5ec4a369eed4adf567c22cc029863f
https://github.com/llvm/llvm-project/commit/ad79a14c9e5ec4a369eed4adf567c22cc029863f
Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
Date: 2024-06-20 (Thu, 20 Jun 2024)
Changed paths:
M llvm/include/llvm/ADT/DenseMapInfo.h
Log Message:
-----------
[ADT] Update hash function of uint64_t for DenseMap (#95734)
(Background: See the comment:
https://github.com/llvm/llvm-project/pull/92083#issuecomment-2168121729)
It looks like the hash function for 64bits integers are not very good:
```
static unsigned getHashValue(const unsigned long long& Val) {
return (unsigned)(Val * 37ULL);
}
```
Since the result is truncated to 32 bits. It looks like the higher 32
bits won't contribute to the result. So that `0x1'00000001` will have
the the same results to `0x2'00000001`, `0x3'00000001`, ...
Then we may meet a lot collisions in such cases. I feel it should
generally good to include higher 32 bits for hashing functions.
Not sure who's the appropriate reviewer, adding some people by
impressions.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list