From cdb78d79935cb3d1063601223548465bc09b26d8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 27 Jan 2022 20:34:40 -0800 Subject: qsimd/x86: disable the F16C, FMA, and VAES features if AVX is disabled Those three features can't be used without the VEX prefix, which requires that the OS has enabled saving of the AVX state on context switches (i.e., use XSAVE). The list is automatically maintained by the updated script in OpenDCDiag[1]. I need to update the copy in util/x86simdgen. [1] https://github.com/opendcdiag/opendcdiag/blob/main/framework/scripts/x86simd_generate.pl Pick-to: 6.3 Change-Id: I6fcda969a9e9427198bffffd16ce55193a6cb069 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/global/qfloat16.cpp | 6 +++--- src/corelib/global/qsimd.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 9646943620..d816d8b888 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -194,9 +194,9 @@ int qfloat16::fpClassify() const noexcept #if QT_COMPILER_SUPPORTS(F16C) static inline bool hasFastF16() { - // All processors with F16C also support AVX, but YMM registers - // might not be supported by the OS, or they might be disabled. - return qCpuHasFeature(F16C) && qCpuHasFeature(AVX); + // qsimd.cpp:detectProcessorFeatures() turns off this feature if AVX + // state-saving is not enabled by the OS + return qCpuHasFeature(F16C); } QT_FUNCTION_TARGET(F16C) diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp index b96a67b14b..5692b6ef03 100644 --- a/src/corelib/global/qsimd.cpp +++ b/src/corelib/global/qsimd.cpp @@ -371,8 +371,8 @@ static quint64 adjustedXcr0(quint64 xcr0) static quint64 detectProcessorFeatures() { - static const quint64 AllAVX2 = CpuFeatureAVX2 | AllAVX512; - static const quint64 AllAVX = CpuFeatureAVX | AllAVX2; + static const quint64 AllAVX = AllAVX512 | CpuFeatureAVX | CpuFeatureAVX2 | CpuFeatureF16C + | CpuFeatureFMA | CpuFeatureVAES; quint64 features = 0; int cpuidLevel = maxBasicCpuidSupported(); -- cgit v1.2.3