Skip to content

Commit

Permalink
prevent XXH64 from being autovectorized by XXH512 by default
Browse files Browse the repository at this point in the history
backport fix Cyan4973/xxHash#924 from libxxhash
  • Loading branch information
Cyan4973 committed Mar 8, 2024
1 parent 8689633 commit 007cda8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/common/xxhash.h
Expand Up @@ -3317,6 +3317,23 @@ static xxh_u64 XXH64_round(xxh_u64 acc, xxh_u64 input)
acc += input * XXH_PRIME64_2;
acc = XXH_rotl64(acc, 31);
acc *= XXH_PRIME64_1;
#if (defined(__AVX512F__)) && !defined(XXH_ENABLE_AUTOVECTORIZE)
/*
* DISABLE AUTOVECTORIZATION:
* A compiler fence is used to prevent GCC and Clang from
* autovectorizing the XXH64 loop (pragmas and attributes don't work for some
* reason) without globally disabling AVX512.
*
* Autovectorization of XXH64 tends to be detrimental,
* though the exact outcome may change depending on exact cpu and compiler version.
* For information, it has been reported as detrimental for Skylake-X,
* but possibly beneficial for Zen4.
*
* The default is to disable auto-vectorization,
* but you can select to enable it instead using `XXH_ENABLE_AUTOVECTORIZE` build variable.
*/
XXH_COMPILER_GUARD(acc);
#endif
return acc;
}

Expand Down

0 comments on commit 007cda8

Please sign in to comment.