diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-07-25 11:59:06 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-07-25 12:26:18 +0200 |
| commit | 27c44ce9c3be36d49b829e3dfbdcc983bddd727d (patch) | |
| tree | 20a97508a2ac63cf43a7b55bb2e9ac8076444c28 | |
| parent | 5f6a61e16524025a690ac5512669583145db94b1 (diff) | |
| download | rust-27c44ce9c3be36d49b829e3dfbdcc983bddd727d.tar.gz rust-27c44ce9c3be36d49b829e3dfbdcc983bddd727d.zip | |
siphash: Reorder hash state in the struct
If they are ordered v0, v2, v1, v3, the compiler can find just a few simd optimizations itself. The new optimization I could observe on x86-64 was using 128 bit registers for the v = key ^ constant operations in new / reset.
| -rw-r--r-- | src/libcore/hash/sip.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 5b6fd46f677..93bdadff549 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -32,9 +32,13 @@ pub struct SipHasher { k0: u64, k1: u64, length: usize, // how many bytes we've processed + // v0, v2 and v1, v3 show up in pairs in the algorithm, + // and simd implementations of SipHash will use vectors + // of v02 and v13. By placing them in this order in the struct, + // the compiler can pick up on just a few simd optimizations by itself. v0: u64, // hash state - v1: u64, v2: u64, + v1: u64, v3: u64, tail: u64, // unprocessed bytes le ntail: usize, // how many bytes in tail are valid |
