qsimd: simplify the code slightly
Only x86 requires more than 32 different bits in the CPU feature variable, so enforce the need for 64-bit atomics only for it. Everyone else can stick to 32-bit atomics, which are supported everywhere. Change-Id: I54f205f6b7314351b078fffd16cf7c7d50a84102 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
d9f1d2c9df
commit
d08f59d083
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
** Copyright (C) 2019 Intel Corporation.
|
** Copyright (C) 2022 Intel Corporation.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
** This file is part of the QtCore module of the Qt Toolkit.
|
||||||
@ -583,11 +583,7 @@ static const int features_count = (sizeof features_indices) / (sizeof features_i
|
|||||||
// record what CPU features were enabled by default in this Qt build
|
// record what CPU features were enabled by default in this Qt build
|
||||||
static const quint64 minFeature = qCompilerCpuFeatures;
|
static const quint64 minFeature = qCompilerCpuFeatures;
|
||||||
|
|
||||||
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
QBasicAtomicInteger<QCpuFeatureType> qt_cpu_features[1] = { 0 };
|
||||||
Q_CORE_EXPORT QBasicAtomicInteger<quint64> qt_cpu_features[1] = { Q_BASIC_ATOMIC_INITIALIZER(0) };
|
|
||||||
#else
|
|
||||||
Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2] = { Q_BASIC_ATOMIC_INITIALIZER(0), Q_BASIC_ATOMIC_INITIALIZER(0) };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
quint64 qDetectCpuFeatures()
|
quint64 qDetectCpuFeatures()
|
||||||
{
|
{
|
||||||
@ -626,9 +622,6 @@ quint64 qDetectCpuFeatures()
|
|||||||
}
|
}
|
||||||
|
|
||||||
qt_cpu_features[0].storeRelaxed(f | quint32(QSimdInitialized));
|
qt_cpu_features[0].storeRelaxed(f | quint32(QSimdInitialized));
|
||||||
#ifndef Q_ATOMIC_INT64_IS_SUPPORTED
|
|
||||||
qt_cpu_features[1].storeRelaxed(f >> 32);
|
|
||||||
#endif
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,11 +357,12 @@ static const quint64 qCompilerCpuFeatures = 0
|
|||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
#ifdef Q_PROCESSOR_X86
|
||||||
extern Q_CORE_EXPORT QBasicAtomicInteger<quint64> qt_cpu_features[1];
|
using QCpuFeatureType = quint64;
|
||||||
#else
|
#else
|
||||||
extern Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2];
|
using QCpuFeatureType = unsigned;
|
||||||
#endif
|
#endif
|
||||||
|
extern Q_CORE_EXPORT QBasicAtomicInteger<QCpuFeatureType> qt_cpu_features[1];
|
||||||
Q_CORE_EXPORT quint64 qDetectCpuFeatures();
|
Q_CORE_EXPORT quint64 qDetectCpuFeatures();
|
||||||
|
|
||||||
#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !defined(QT_BOOTSTRAPPED)
|
#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !defined(QT_BOOTSTRAPPED)
|
||||||
@ -376,9 +377,6 @@ static inline qsizetype qRandomCpu(void *, qsizetype) noexcept
|
|||||||
static inline quint64 qCpuFeatures()
|
static inline quint64 qCpuFeatures()
|
||||||
{
|
{
|
||||||
quint64 features = qt_cpu_features[0].loadRelaxed();
|
quint64 features = qt_cpu_features[0].loadRelaxed();
|
||||||
#ifndef Q_ATOMIC_INT64_IS_SUPPORTED
|
|
||||||
features |= quint64(qt_cpu_features[1].loadRelaxed()) << 32;
|
|
||||||
#endif
|
|
||||||
if (Q_UNLIKELY(features == 0)) {
|
if (Q_UNLIKELY(features == 0)) {
|
||||||
features = qDetectCpuFeatures();
|
features = qDetectCpuFeatures();
|
||||||
Q_ASSUME(features != 0);
|
Q_ASSUME(features != 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user