Enable tzcnt intrinsic for GCC when BMI is defined

pull/131/head
Jeffrey Walton 2016-04-25 07:20:37 -04:00
parent 412a41faa0
commit 5c41ccb8fb
1 changed files with 3 additions and 3 deletions

6
misc.h
View File

@ -59,7 +59,7 @@
#include <byteswap.h> #include <byteswap.h>
#endif #endif
#if defined(__GNUC__) && defined(__AVX2__) #if defined(__GNUC__) && defined(__BMI__)
# include <immintrin.h> # include <immintrin.h>
#endif #endif
@ -607,7 +607,7 @@ inline unsigned int TrailingZeros(word32 v)
// We don't enable for Microsoft because it requires a runtime check. // We don't enable for Microsoft because it requires a runtime check.
// http://msdn.microsoft.com/en-us/library/hh977023%28v=vs.110%29.aspx // http://msdn.microsoft.com/en-us/library/hh977023%28v=vs.110%29.aspx
assert(v != 0); assert(v != 0);
#if defined(__GNUC__) && defined(__AVX2__) #if defined(__GNUC__) && defined(__BMI__)
return (unsigned int)_tzcnt_u32(v); return (unsigned int)_tzcnt_u32(v);
#elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400) #elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400)
return (unsigned int)__builtin_ctz(v); return (unsigned int)__builtin_ctz(v);
@ -638,7 +638,7 @@ inline unsigned int TrailingZeros(word64 v)
// We don't enable for Microsoft because it requires a runtime check. // We don't enable for Microsoft because it requires a runtime check.
// http://msdn.microsoft.com/en-us/library/hh977023%28v=vs.110%29.aspx // http://msdn.microsoft.com/en-us/library/hh977023%28v=vs.110%29.aspx
assert(v != 0); assert(v != 0);
#if defined(__GNUC__) && defined(__AVX2__) #if defined(__GNUC__) && defined(__BMI__)
return (unsigned int)_tzcnt_u64(v); return (unsigned int)_tzcnt_u64(v);
#elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400) #elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400)
return (unsigned int)__builtin_ctzll(v); return (unsigned int)__builtin_ctzll(v);