[llvm-dev] Default hashing function for integers (DenseMapInfo.h)

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 9 17:31:29 PST 2017

> On Jan 9, 2017, at 2:10 AM, Francois Fayard via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi,
> I’ve been looking at Chandler Carruth talks about internal data structures for LLVM in order to implement my own library. That’s how I ended up looking at the internals of DenseMap and the default hash functions defined in DenseMapInfo.
> I have been very surprised by the hash function used for integers which is hash(k) = 37 * k.

As others have pointed out, 37 does have some nice properties (by being prime), but we’ve also had it from the very early days.  I wouldn’t say that it has been extremely well considered at all.


More information about the llvm-dev mailing list