diff options
| author | Lioncash <mathew1800@gmail.com> | 2018-03-31 17:09:33 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2018-03-31 18:09:45 -0400 |
| commit | c3483a1823d5a5f4a8174682228f78d00cee3247 (patch) | |
| tree | 085331ee9dd055c4e3cd406d02312e4ede70ea34 /Source/Core/Common/Hash.cpp | |
| parent | 76e1a5b892b546ff30320dd8c1193148db7c9ef9 (diff) | |
CommonFuncs: Generify rotation functions and move them to BitUtils.h
These are bit manipulation functions, so they belong within BitUtils.
This also gets rid of duplicated code and avoids relying on compiler
reserved names existing or not existing to determine whether or not we
define a set of functions.
Optimizers are smart enough in GCC and clang to transform the code to a
ROR or ROL instruction in the respective functions.
Diffstat (limited to 'Source/Core/Common/Hash.cpp')
| -rw-r--r-- | Source/Core/Common/Hash.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp index 7074e12e55..2678ab89bc 100644 --- a/Source/Core/Common/Hash.cpp +++ b/Source/Core/Common/Hash.cpp @@ -3,8 +3,10 @@ // Refer to the license.txt file included. #include "Common/Hash.h" + #include <algorithm> #include <cstring> +#include "Common/BitUtils.h" #include "Common/CPUDetect.h" #include "Common/CommonFuncs.h" #include "Common/Intrinsics.h" @@ -117,15 +119,15 @@ static u64 getblock(const u64* p, int i) static void bmix64(u64& h1, u64& h2, u64& k1, u64& k2, u64& c1, u64& c2) { k1 *= c1; - k1 = _rotl64(k1, 23); + k1 = Common::RotateLeft(k1, 23); k1 *= c2; h1 ^= k1; h1 += h2; - h2 = _rotl64(h2, 41); + h2 = Common::RotateLeft(h2, 41); k2 *= c2; - k2 = _rotl64(k2, 23); + k2 = Common::RotateLeft(k2, 23); k2 *= c1; h2 ^= k2; h2 += h1; @@ -396,15 +398,15 @@ static u32 fmix32(u32 h) static void bmix32(u32& h1, u32& h2, u32& k1, u32& k2, u32& c1, u32& c2) { k1 *= c1; - k1 = _rotl(k1, 11); + k1 = Common::RotateLeft(k1, 11); k1 *= c2; h1 ^= k1; h1 += h2; - h2 = _rotl(h2, 17); + h2 = Common::RotateLeft(h2, 17); k2 *= c2; - k2 = _rotl(k2, 11); + k2 = Common::RotateLeft(k2, 11); k2 *= c1; h2 ^= k2; h2 += h1; |
