From c3a4ec5d0bbd5f2710f4fd1d3bd4a2d7f0f507ad Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 May 2018 00:54:19 -0300 Subject: SIMD: Add a haswell sub-architecture selection to our support As the comment says, Haswell is a nice divider and is a good optimization target. I'm using -march=core-avx2 instead of -march=haswell because the latter form was only added to GCC 4.9 but we still support 4.7 and that has support for AVX2. This commit changes the AVX2-optimized code in QtGui to Haswell- optimized instead. That means, for example, that qdrawhelper_avx2.cpp can now use the FMA instructions. Change-Id: If025d476890745368955fffd153129c1716ba006 Reviewed-by: Lars Knoll Reviewed-by: Allan Sandfeld Jensen --- mkspecs/features/simd.prf | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'mkspecs/features/simd.prf') diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf index 65ba4b0d08..a0b40fcf11 100644 --- a/mkspecs/features/simd.prf +++ b/mkspecs/features/simd.prf @@ -141,6 +141,28 @@ addSimdCompiler(neon) addSimdCompiler(mips_dsp) addSimdCompiler(mips_dspr2) +# Haswell sub-architecture +defineTest(addSimdArch) { + name = arch_$$1 + dependencies = $$2 + upname = $$upper($$name) + + cpu_features_missing = + for(part, dependencies) { + !contains(QT_CPU_FEATURES, $$part): cpu_features_missing = 1 + } + + CONFIG += $$name + isEmpty(cpu_features_missing): QT_CPU_FEATURES += $$name + + export(QT_CPU_FEATURES) + export(CONFIG) + addSimdCompiler($$name) +} + +isEmpty(QMAKE_CFLAGS_ARCH_HASWELL): QMAKE_CFLAGS_ARCH_HASWELL = $$QMAKE_CFLAGS_AVX2 +avx2: addSimdArch(haswell, avx2 bmi bmi2 f16c fma lzcnt popcnt) + # Follow the Intel compiler's lead and define profiles of AVX512 instructions defineTest(addAvx512Profile) { name = $$1 @@ -149,7 +171,7 @@ defineTest(addAvx512Profile) { varname = QMAKE_CFLAGS_$$upname cpu_features_missing = - cflags = $$QMAKE_CFLAGS_AVX512F + cflags = $$QMAKE_CFLAGS_ARCH_HASWELL $$QMAKE_CFLAGS_AVX512F for(part, dependencies) { !CONFIG($$part): return() # Profile isn't supported by the compiler -- cgit v1.2.3