From 43ff604f9453edb24154c2ab5ea72bafe0fc501d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Jun 2016 19:03:19 -0700 Subject: [PATCH] x86: Fix build with BMI but no LZCNT extensions The GCC builtins for clzs and ctzs are enabled when the x86 extension for LZCNT and TZCNT are enabled. The use of only __BMI__ in commit f5f47987ce369aa3f7553e6c0da509461a1ddf1a was incorrect. But GCC needs both BMI and LZCNT enabled to enable this builtin. Change-Id: I1cc7601489634e96833cfffd145647e9fc9f2f51 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qalgorithms.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 14465240b4..4f704d6764 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -626,7 +626,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOT Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW { #if defined(Q_CC_GNU) -# if QT_HAS_BUILTIN(__builtin_ctzs) || defined(__BMI__) +# if QT_HAS_BUILTIN(__builtin_ctzs) || (defined(__LZCNT__) && defined(__BMI__)) return v ? __builtin_ctzs(v) : 16U; # else return v ? __builtin_ctz(v) : 16U; @@ -689,7 +689,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTH Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW { #if defined(Q_CC_GNU) -# if QT_HAS_BUILTIN(__builtin_clzs) || defined(__BMI__) +# if QT_HAS_BUILTIN(__builtin_clzs) || (defined(__LZCNT__) && defined(__BMI__)) return v ? __builtin_clzs(v) : 16U; # else return v ? __builtin_clz(v)-16U : 16U;