From a19b68185e7be4a78faa9f2f937c981879b5e12c Mon Sep 17 00:00:00 2001 From: Oleksandr Melnyk Date: Sun, 5 Jun 2022 19:18:00 +0300 Subject: [PATCH] Fix SSE instructions --- src/Standart.Hash.xxHash/xxHash128.XXH.cs | 4 ++-- src/Standart.Hash.xxHash/xxHash128.XXH3.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Standart.Hash.xxHash/xxHash128.XXH.cs b/src/Standart.Hash.xxHash/xxHash128.XXH.cs index 2ef5fd6..66d67f1 100644 --- a/src/Standart.Hash.xxHash/xxHash128.XXH.cs +++ b/src/Standart.Hash.xxHash/xxHash128.XXH.cs @@ -96,8 +96,8 @@ namespace Standart.Hash.xxHash [MethodImpl(MethodImplOptions.AggressiveInlining)] private static unsafe uint128 XXH_mult64to128_bmi2(ulong lhs, ulong rhs) { - ulong product_high; - ulong product_low = Bmi2.X64.MultiplyNoFlags(lhs, rhs, &product_high); + ulong product_low; + ulong product_high = Bmi2.X64.MultiplyNoFlags(lhs, rhs, &product_low); uint128 r128; r128.low64 = product_low; r128.high64 = product_high; diff --git a/src/Standart.Hash.xxHash/xxHash128.XXH3.cs b/src/Standart.Hash.xxHash/xxHash128.XXH3.cs index 28dd64e..3c3ad29 100644 --- a/src/Standart.Hash.xxHash/xxHash128.XXH3.cs +++ b/src/Standart.Hash.xxHash/xxHash128.XXH3.cs @@ -503,17 +503,17 @@ namespace Standart.Hash.xxHash { const int m128i_size = 16; - var seed = Vector128.Create((long) seed64, (long) (0U - seed64)); + var seed = Vector128.Create((long)seed64, (long)(0U - seed64)); fixed (byte* secret = &XXH3_SECRET[0]) { - for (int i = 0; i < XXH_SECRET_DEFAULT_SIZE / m128i_size; ++i) + for (int i = 0; i < XXH_SECRET_DEFAULT_SIZE / m128i_size; i++) { int uint64_offset = i * 2; - var src16 = Sse2.LoadVector128((long*) secret + uint64_offset); + var src16 = Sse2.LoadVector128(((long*) secret) + uint64_offset); var dst16 = Sse2.Add(src16, seed); - Sse2.Store((long*) customSecret, dst16); + Sse2.Store((long*) customSecret + uint64_offset, dst16); } }