diff options
author | Brotli <no-reply@google.com> | 2024-05-08 17:59:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-08 17:59:58 -0700 |
commit | bb809ac908a4b42772eaf4f5e9fb66ca7886a6c9 (patch) | |
tree | 53b3fe4ecb1d3d1981b662f8b2f419134fecc229 /c/common | |
parent | d01a4caaa80c0072fe1b6bf073814b9400667fcc (diff) | |
download | brotli-bb809ac908a4b42772eaf4f5e9fb66ca7886a6c9.zip brotli-bb809ac908a4b42772eaf4f5e9fb66ca7886a6c9.tar.gz brotli-bb809ac908a4b42772eaf4f5e9fb66ca7886a6c9.tar.bz2 |
Use a hash table header and SIMD to speed up hash table operations (similar to [Swiss Tables](https://abseil.io/about/design/swisstables)).
PiperOrigin-RevId: 631982664
Diffstat (limited to 'c/common')
-rw-r--r-- | c/common/platform.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/c/common/platform.h b/c/common/platform.h index c18ff02..7965fea 100644 --- a/c/common/platform.h +++ b/c/common/platform.h @@ -282,6 +282,11 @@ static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { memcpy(&t, p, sizeof t); return t; } +static BROTLI_INLINE size_t BrotliUnalignedReadSizeT(const void* p) { + size_t t; + memcpy(&t, p, sizeof t); + return t; +} static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { memcpy(p, &v, sizeof v); } @@ -489,6 +494,23 @@ BROTLI_COMMON_API void* BrotliDefaultAllocFunc(void* opaque, size_t size); /* Default brotli_free_func */ BROTLI_COMMON_API void BrotliDefaultFreeFunc(void* opaque, void* address); +/* Circular logical rotates. */ +static BROTLI_INLINE uint16_t BrotliRotateRight16(uint16_t const value, + size_t count) { + count &= 0x0F; /* for fickle pattern recognition */ + return (value >> count) | (uint16_t)(value << ((0U - count) & 0x0F)); +} +static BROTLI_INLINE uint32_t BrotliRotateRight32(uint32_t const value, + size_t count) { + count &= 0x1F; /* for fickle pattern recognition */ + return (value >> count) | (uint32_t)(value << ((0U - count) & 0x1F)); +} +static BROTLI_INLINE uint64_t BrotliRotateRight64(uint64_t const value, + size_t count) { + count &= 0x3F; /* for fickle pattern recognition */ + return (value >> count) | (uint64_t)(value << ((0U - count) & 0x3F)); +} + BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) { BROTLI_UNUSED(&BrotliSuppressUnusedFunctions); BROTLI_UNUSED(&BrotliUnalignedRead16); @@ -534,6 +556,13 @@ BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) { # define PREFETCH_L1(ptr) do { (void)(ptr); } while (0) /* disabled */ # define PREFETCH_L2(ptr) do { (void)(ptr); } while (0) /* disabled */ #endif + +/* The SIMD matchers are only faster at certain quality levels. */ +#if defined(_M_X64) && defined(BROTLI_TZCNT64) +#define BROTLI_MAX_SIMD_QUALITY 7 +#elif defined(BROTLI_TZCNT64) +#define BROTLI_MAX_SIMD_QUALITY 6 +#endif } #endif /* BROTLI_COMMON_PLATFORM_H_ */ |