Merge branch 'rrl_avx2' into 'master'

KRU: fix collision if target architecture/optimization is specified

See merge request knot/knot-dns!1815
This commit is contained in:
Daniel Salzman 2025-10-20 10:49:44 +02:00
commit ec4a2567b2

View file

@ -3,17 +3,17 @@
* For more information, see <https://www.knot-dns.cz/>
*/
// Checked with clang 5 (2017) and gcc 6 (2016).
// Checked with clang 12 (2021) and gcc 6 (2016).
// For other cases we'll rather keep just the generic implementation.
#if defined(__x86_64__) && (__clang_major__ >= 5 || __GNUC__ >= 6) && !defined(__APPLE__)
#if defined(__x86_64__) && (__clang_major__ >= 12 || __GNUC__ >= 6) && !defined(__APPLE__)
// This file has code for new-ish x86 (2015+ usually, Atom 2021+) - AES + AVX2
#if __clang_major__ >= 12
#pragma clang attribute push (__attribute__((target("arch=x86-64-v3,aes"))), \
apply_to = function)
#elif __clang__
#pragma clang attribute push (__attribute__((target("avx2,aes"))), \
apply_to = function)
#ifdef __clang__
// Force using specific instructions only if target architecture/optimization not specified
#if !defined(__AVX2__)
#pragma clang attribute push (__attribute__((target("arch=x86-64-v3,aes"))), \
apply_to = function)
#endif
#else
#pragma GCC push_options
#if __GNUC__ >= 11
@ -33,7 +33,9 @@
const struct kru_api KRU_AVX2 = KRU_API_INITIALIZER;
#ifdef __clang__
#pragma clang attribute pop
#if !defined(__AVX2__)
#pragma clang attribute pop
#endif
#else
#pragma GCC pop_options
#endif