diff options
-rw-r--r-- | cmake/QtBuild.cmake | 45 | ||||
-rw-r--r-- | cmake/QtCompilerOptimization.cmake | 1 | ||||
-rw-r--r-- | src/gui/CMakeLists.txt | 9 |
3 files changed, 41 insertions, 14 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 80eceab27a..404415a99f 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -4909,12 +4909,44 @@ function(qt_add_simd_part target) endif() set(condition "QT_FEATURE_${arg_SIMD}") + string(TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags_var_name) + set(simd_flags_expanded "") + + # As per mkspecs/features/simd.prf, the arch_haswell SIMD compiler is enabled when + # qmake's CONFIG contains "avx2", which maps to CMake's QT_FEATURE_avx2. + # The list of dependencies 'avx2 bmi bmi2 f16c fma lzcnt popcnt' only influences whether + # the 'arch_haswell' SIMD flags need to be added explicitly to the compiler invocation. + # If the compiler adds them implicitly, they must be present in qmake's QT_CPU_FEATURES as + # detected by the architecture test, and thus they are present in TEST_subarch_result. if("${arg_SIMD}" STREQUAL arch_haswell) - set(condition "TEST_subarch_avx2 AND TEST_subarch_bmi AND TEST_subarch_bmi2 AND TEST_subarch_f16c AND TEST_subarch_fma AND TEST_subarch_lzcnt AND TEST_subarch_popcnt") + set(condition "QT_FEATURE_avx2") + + # Use avx2 flags as per simd.prf, if there are no specific arch_haswell flags specified in + # QtCompilerOptimization.cmake. + if("${simd_flags_var_name}" STREQUAL "") + set(simd_flags_var_name "QT_CFLAGS_AVX2") + endif() + + # The avx512 profiles dependencies DO influence if the SIMD compiler will be executed, + # so each of the profile dependencies have to be in qmake's CONFIG for the compiler to be + # enabled, which means the CMake features have to evaluate to true. + # Also the profile flags to be used are a combination of arch_haswell, avx512f and each of the + # dependencies. elseif("${arg_SIMD}" STREQUAL avx512common) - set(condition "TEST_subarch_avx512cd") + set(condition "QT_FEATURE_avx512cd") + list(APPEND simd_flags_expanded "${QT_CFLAGS_ARCH_HASWELL}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512F}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512CD}") + list(REMOVE_DUPLICATES simd_flags_expanded) elseif("${arg_SIMD}" STREQUAL avx512core) - set(condition "TEST_subarch_avx512cd AND TEST_subarch_avx512bw AND TEST_subarch_avx512dq AND TEST_subarch_avx512vl") + set(condition "QT_FEATURE_avx512cd AND QT_FEATURE_avx512bw AND QT_FEATURE_avx512dq AND QT_FEATURE_avx512vl") + list(APPEND simd_flags_expanded "${QT_CFLAGS_ARCH_HASWELL}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512F}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512CD}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512BW}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512DQ}") + list(APPEND simd_flags_expanded "${QT_CFLAGS_AVX512VL}") + list(REMOVE_DUPLICATES simd_flags_expanded) endif() set(name "${arg_NAME}") @@ -4927,12 +4959,15 @@ function(qt_add_simd_part target) if(QT_CMAKE_DEBUG_EXTEND_TARGET) message("qt_add_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated") endif() - string(TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags) + + if(NOT simd_flags_expanded) + set(simd_flags_expanded "${${simd_flags_var_name}}") + endif() foreach(source IN LISTS arg_SOURCES) set_property(SOURCE "${source}" APPEND PROPERTY COMPILE_OPTIONS - ${${simd_flags}} + ${simd_flags_expanded} ${arg_COMPILE_FLAGS} ) endforeach() diff --git a/cmake/QtCompilerOptimization.cmake b/cmake/QtCompilerOptimization.cmake index 42206368d9..fc2922089c 100644 --- a/cmake/QtCompilerOptimization.cmake +++ b/cmake/QtCompilerOptimization.cmake @@ -51,6 +51,7 @@ if(GCC OR CLANG) set(QT_CFLAGS_RDRND "-mrdrnd") set(QT_CFLAGS_AVX "-mavx") set(QT_CFLAGS_AVX2 "-mavx2") + set(QT_CFLAGS_ARCH_HASWELL "-march=core-avx2") set(QT_CFLAGS_AVX512F "-mavx512f") set(QT_CFLAGS_AVX512ER "-mavx512er") set(QT_CFLAGS_AVX512CD "-mavx512cd") diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 21dc18721e..a31b13ff58 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -305,15 +305,6 @@ if(QT_FEATURE_reduce_relocations AND UNIX AND GCC) endif() # special case begin -# Replace arch_haswell with avx2 feature. That is what is used in the code requireing -# this file, too! -qt_add_simd_part(Gui SIMD avx2 - SOURCES - painting/qdrawhelper_avx2.cpp -) -# special case end - -# special case begin qt_extend_target(Gui CONDITION QT_FEATURE_standarditemmodel SOURCES itemmodels/qstandarditemmodel.cpp itemmodels/qstandarditemmodel.h itemmodels/qstandarditemmodel_p.h |