From f6d9cc5b79d545be0c64ff6fd85131a89ee21edd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 20 Jun 2018 19:08:14 -0700 Subject: SIMD: Refactor the constants to be actual bit values ... instead of being the bit numbers. This allows us to test more than one feature at a time with qCpuHasFeature (see commit about the Haswell architecture features). The drawback is that we won't be able to handle more than 63 different CPU features, though we're likely quite far from it (x86 currently has only 36 features). Change-Id: Iff4151c519c144d580c4fffd153a0acbfd74c2c6 Reviewed-by: Oswald Buddenhagen Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/corelib/tools/qsimd_p.h') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 7080f01619..af262ec88f 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -270,30 +270,30 @@ QT_BEGIN_NAMESPACE #ifndef Q_PROCESSOR_X86 enum CPUFeatures { #if defined(Q_PROCESSOR_ARM) - CpuFeatureNEON = 0, + CpuFeatureNEON = 2, CpuFeatureARM_NEON = CpuFeatureNEON, - CpuFeatureCRC32 = 1, + CpuFeatureCRC32 = 4, #elif defined(Q_PROCESSOR_MIPS) - CpuFeatureDSP = 0, - CpuFeatureDSPR2 = 1, + CpuFeatureDSP = 2, + CpuFeatureDSPR2 = 4, #endif // used only to indicate that the CPU detection was initialised - QSimdInitialized = 0x80000000 + QSimdInitialized = 1 }; static const quint64 qCompilerCpuFeatures = 0 #if defined __ARM_NEON__ - | (Q_UINT64_C(1) << CpuFeatureNEON) + | CpuFeatureNEON #endif #if defined __ARM_FEATURE_CRC32 - | (Q_UINT64_C(1) << CpuFeatureCRC32) + | CpuFeatureCRC32 #endif #if defined __mips_dsp - | (Q_UINT64_C(1) << CpuFeatureDSP) + | CpuFeatureDSP #endif #if defined __mips_dspr2 - | (Q_UINT64_C(1) << CpuFeatureDSPR2) + | CpuFeatureDSPR2 #endif ; #endif @@ -322,8 +322,8 @@ static inline quint64 qCpuFeatures() return features; } -#define qCpuHasFeature(feature) ((qCompilerCpuFeatures & (Q_UINT64_C(1) << CpuFeature ## feature)) \ - || (qCpuFeatures() & (Q_UINT64_C(1) << CpuFeature ## feature))) +#define qCpuHasFeature(feature) (((qCompilerCpuFeatures & CpuFeature ## feature) == CpuFeature ## feature) \ + || ((qCpuFeatures() & CpuFeature ## feature) == CpuFeature ## feature)) #define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \ for (; i < static_cast(qMin(static_cast(length), ((4 - ((reinterpret_cast(ptr) >> 2) & 0x3)) & 0x3))); ++i) -- cgit v1.2.3