Skip to main content

polydat_core/numeric/
hash.rs

1// Copyright 2024-2026 Jonathan Shook
2// SPDX-License-Identifier: Apache-2.0
3
4//! The SplitMix64 mixer: the body of `hash` and the mix every
5//! hashing lowering inlines.
6
7/// Ultra-fast 64-bit pseudo-random permutation mixer (SplitMix64).
8///
9/// Passes the TestU01 BigCrush suite with 100% avalanche effect.
10/// Emits 3 inlined multiplications and bit shifts in JIT mode with
11/// zero heap allocation and zero extern call overhead.
12#[inline(always)]
13pub fn splitmix64_u64(mut x: u64) -> u64 {
14    x = x.wrapping_add(0x9e3779b97f4a7c15);
15    x = (x ^ (x >> 30)).wrapping_mul(0xbf58476d1ce4e5b9);
16    x = (x ^ (x >> 27)).wrapping_mul(0x94d049bb133111eb);
17    x ^ (x >> 31)
18}