Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make HAVE_ATTRIBUTE_TARGET check also check that SSSE3 intrinsics work #1886

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ config.h:
echo '#define HAVE_ATTRIBUTE_CONSTRUCTOR 1' >> $@
echo '#endif' >> $@
echo '#if (defined(__x86_64__) || defined(_M_X64))' >> $@
echo '#define HAVE_ATTRIBUTE_TARGET 1' >> $@
echo '#define HAVE_ATTRIBUTE_TARGET_SSSE3 1' >> $@
echo '#define HAVE_BUILTIN_CPU_SUPPORT_SSSE3 1' >> $@
echo '#endif' >> $@
echo '#if defined __linux__' >> $@
Expand Down
21 changes: 15 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,25 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[
])

dnl Check for function attribute used in conjunction with __builtin_cpu_supports
AC_MSG_CHECKING([for __attribute__((target))])
dnl and that it does enable the corresponding intrinsics (which is broken on ancient GCCs)
AC_MSG_CHECKING([for working __attribute__((target("ssse3")))])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef __x86_64__
#include "x86intrin.h"

__attribute__((target("ssse3")))
int zero(void) {
return 0;
void shuffle(char *aptr, char *bptr) {
__m128i a = _mm_lddqu_si128((__m128i *)aptr);
__m128i b = _mm_shuffle_epi8(a, a);
_mm_storeu_si128((__m128i *)bptr, b);
}
]], [[zero();]])], [
#else
void shuffle(char *aptr, char *bptr) { }
#endif
]], [[shuffle(0, 0);]])], [
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_ATTRIBUTE_TARGET], 1,
[Define if __attribute__((target(...))) is available.])
AC_DEFINE([HAVE_ATTRIBUTE_TARGET_SSSE3], 1,
[Define if __attribute__((target("ssse3"))) works.])
], [
AC_MSG_RESULT([no])
])
Expand Down
2 changes: 1 addition & 1 deletion sam_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static inline void nibble2base_default(uint8_t *nib, char *seq, int len) {
}

#if defined HAVE_ATTRIBUTE_CONSTRUCTOR && \
((defined __x86_64__ && defined HAVE_ATTRIBUTE_TARGET && defined HAVE_BUILTIN_CPU_SUPPORT_SSSE3) || \
((defined __x86_64__ && defined HAVE_ATTRIBUTE_TARGET_SSSE3 && defined HAVE_BUILTIN_CPU_SUPPORT_SSSE3) || \
(defined __ARM_NEON))
#define BUILDING_SIMD_NIBBLE2BASE
#endif
Expand Down
Loading