Skip to content

Commit db996d2

Browse files
authored
Merge pull request #3933 from facebook/fix3819
prevent XXH64 from being autovectorized by XXH512 by default
2 parents 7a43609 + 007cda8 commit db996d2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/common/xxhash.h

+17
Original file line numberDiff line numberDiff line change
@@ -3329,6 +3329,23 @@ static xxh_u64 XXH64_round(xxh_u64 acc, xxh_u64 input)
33293329
acc += input * XXH_PRIME64_2;
33303330
acc = XXH_rotl64(acc, 31);
33313331
acc *= XXH_PRIME64_1;
3332+
#if (defined(__AVX512F__)) && !defined(XXH_ENABLE_AUTOVECTORIZE)
3333+
/*
3334+
* DISABLE AUTOVECTORIZATION:
3335+
* A compiler fence is used to prevent GCC and Clang from
3336+
* autovectorizing the XXH64 loop (pragmas and attributes don't work for some
3337+
* reason) without globally disabling AVX512.
3338+
*
3339+
* Autovectorization of XXH64 tends to be detrimental,
3340+
* though the exact outcome may change depending on exact cpu and compiler version.
3341+
* For information, it has been reported as detrimental for Skylake-X,
3342+
* but possibly beneficial for Zen4.
3343+
*
3344+
* The default is to disable auto-vectorization,
3345+
* but you can select to enable it instead using `XXH_ENABLE_AUTOVECTORIZE` build variable.
3346+
*/
3347+
XXH_COMPILER_GUARD(acc);
3348+
#endif
33323349
return acc;
33333350
}
33343351

0 commit comments

Comments
 (0)