summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-08-17 09:08:04 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-08-17 09:08:06 +0200
commit8842d9d1e6c0286922bf18357ca30c146d692316 (patch)
tree93b78c4f8dcb21275517f94da2ccc4500005e8c2 /src/corelib/tools
parent67352c92761fcb2e2c6a98b24e1bf5f33805cb3a (diff)
parent29778037f8a7b2c86bc4044409b37d5a51a15432 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qalgorithms.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index b658d8afcf..0146e22fa3 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -651,6 +651,7 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
// So it's an acceptable compromise.
#if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__)
#define QALGORITHMS_USE_BUILTIN_POPCOUNT
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
{
return __popcnt(v);
@@ -663,13 +664,15 @@ Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
{
return __popcnt16(v);
}
-#if Q_PROCESSOR_WORDSIZE == 8
-#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
{
+#if Q_PROCESSOR_WORDSIZE == 8
return __popcnt64(v);
-}
+#else
+ return __popcnt(quint32(v)) + __popcnt(quint32(v >> 32));
#endif // MSVC 64bit
+}
+
#endif // __AVX__ || __SSE4_2__ || __POPCNT__
#endif // MSVC