diff --git a/include/import/slz.h b/include/import/slz.h index 901a79027..5ff756c35 100644 --- a/include/import/slz.h +++ b/include/import/slz.h @@ -38,6 +38,7 @@ #define UNALIGNED_LE_OK #define UNALIGNED_FASTER #define USE_64BIT_QUEUE +#define HAVE_FAST_MULT #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) #define UNALIGNED_LE_OK //#define UNALIGNED_FASTER @@ -47,6 +48,7 @@ #elif defined(__ARM_ARCH_8A) || defined(__ARM_FEATURE_UNALIGNED) #define UNALIGNED_LE_OK #define UNALIGNED_FASTER +#define HAVE_FAST_MULT #endif /* Log2 of the size of the hash table used for the references table. */ diff --git a/src/slz.c b/src/slz.c index a41df72ae..1b0b13c57 100644 --- a/src/slz.c +++ b/src/slz.c @@ -388,6 +388,9 @@ static inline uint32_t slz_hash(uint32_t a) // but provides a slightly smoother hash __asm__ volatile("crc32l %1,%0" : "+r"(a) : "r"(0)); return a >> (32 - HASH_BITS); +#elif defined(HAVE_FAST_MULT) + // optimal factor for HASH_BITS=12 and HASH_BITS=13 among 48k tested: 0x1af42f + return (a * 0x1af42f) >> (32 - HASH_BITS); #else return ((a << 19) + (a << 6) - a) >> (32 - HASH_BITS); #endif