diff options
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 5 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary_unix.cpp | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index a40ba575fd..ec6d98cc3c 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -133,6 +133,11 @@ void QFactoryLoader::update() // versions of the same Qt libraries (due to the plugin's dependencies). if (isDebugPlugin != isDebugLibrary) continue; +#elif defined(Q_PROCESSOR_X86) + if (fileName.endsWith(QLatin1String(".avx2")) || fileName.endsWith(QLatin1String(".avx512"))) { + // ignore AVX2-optimized file, we'll do a bait-and-switch to it later + continue; + } #endif if (qt_debug_component()) { qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName; diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 23b9ad6434..7ffd1369b9 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Intel Corporation ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -43,6 +44,7 @@ #include "qlibrary_p.h" #include <qcoreapplication.h> #include <private/qfilesystementry_p.h> +#include <private/qsimd_p.h> #include <dlfcn.h> @@ -178,6 +180,27 @@ bool QLibraryPrivate::load_sys() prefixes.append(QString()); } +#if defined(Q_PROCESSOR_X86) && !defined(Q_OS_DARWIN) + if (qCpuHasFeature(ArchHaswell)) { + auto transform = [](QStringList &list, QString (*f)(QString)) { + QStringList tmp; + qSwap(tmp, list); + list.reserve(tmp.size() * 2); + for (const QString &s : qAsConst(tmp)) { + list.append(f(s)); + list.append(s); + } + }; + if (pluginState == IsAPlugin) { + // add ".avx2" to each suffix in the list + transform(suffixes, [](QString s) { return s.append(QLatin1String(".avx2")); }); + } else { + // prepend "haswell/" to each prefix in the list + transform(prefixes, [](QString s) { return s.prepend(QLatin1String("haswell/")); }); + } + } +#endif + bool retry = true; for(int prefix = 0; retry && !pHnd && prefix < prefixes.size(); prefix++) { for(int suffix = 0; retry && !pHnd && suffix < suffixes.size(); suffix++) { |