From 1c5c763203fee969dce2f3f8eabb95b5fb9dc25d Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 22 Apr 2024 13:36:00 +0200 Subject: [PATCH] Improve compiler compatibility of nibble2base_ssse3 --- htslib/hts_defs.h | 8 ++++++++ sam_internal.h | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htslib/hts_defs.h b/htslib/hts_defs.h index e714e8fdab..b0dcf8cc66 100644 --- a/htslib/hts_defs.h +++ b/htslib/hts_defs.h @@ -118,6 +118,14 @@ DEALINGS IN THE SOFTWARE. */ #define HTS_FORMAT(type, idx, first) #endif +#define HTS_COMPILER_HAS_TARGET (HTS_COMPILER_HAS(target) || HTS_GCC_AT_LEAST(4, 8)) + +#if (defined(__x86_64__) || defined(_M_X64)) +#define HTS_BUILD_IS_X86_64 1 +#else +#define HTS_BUILD_IS_X86_64 0 +#endif + #if defined(_WIN32) || defined(__CYGWIN__) #if defined(HTS_BUILDING_LIBRARY) #define HTSLIB_EXPORT __declspec(dllexport) diff --git a/sam_internal.h b/sam_internal.h index f901070b66..626ad807fb 100644 --- a/sam_internal.h +++ b/sam_internal.h @@ -99,7 +99,8 @@ static inline void nibble2base_default(uint8_t *nib, char *seq, int len) { seq[i] = seq_nt16_str[bam_seqi(nib, i)]; } -#if HTS_GCC_AT_LEAST(4,8) +#if HTS_BUILD_IS_X86_64 && HTS_COMPILER_HAS_TARGET +#include "immintrin.h" /* * Convert a nibble encoded BAM sequence to a string of bases. * @@ -108,7 +109,7 @@ static inline void nibble2base_default(uint8_t *nib, char *seq, int len) { * be converted to the IUPAC characters. * It falls back on the nibble2base_default function for the remainder. */ -#include "tmmintrin.h" + __attribute__((target("ssse3"))) static inline void nibble2base_ssse3(uint8_t *nib, char *seq, int len) { seq[0] = 0;