From 68f1ec348dea5df67c009506070c3c480b1a6d8b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 11 Aug 2020 16:02:07 +0200 Subject: [PATCH] AVX gcc compatibility `_mm256_cvtss_f32` is only available in avxintrin.h of gcc-8 or later. There it is defined as ``` extern __inline float __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm256_cvtss_f32 (__m256 __A) { return __A[0]; } ``` While explicit `vcurrent[0]` works with gcc-5 and gcc-6, older gcc-4 fails with the following error: invalid types 'float __vector__[int]' for array subscript --- libs/ardour/sse_functions_avx_linux.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/ardour/sse_functions_avx_linux.cc b/libs/ardour/sse_functions_avx_linux.cc index 6ab2f1731f..e6e8d64ad2 100644 --- a/libs/ardour/sse_functions_avx_linux.cc +++ b/libs/ardour/sse_functions_avx_linux.cc @@ -137,7 +137,13 @@ x86_sse_avx_compute_peak(const float *src, uint32_t nframes, float current) // zero upper 128 bit of 256 bit ymm register to avoid penalties using non-AVX instructions _mm256_zeroupper(); - return vcurrent[0]; // _mm256_cvtss_f32 +#if defined(__GNUC__) && (__GNUC__ < 5) + return *((float *)&vcurrent); +#elif defined(__GNUC__) && (__GNUC__ < 8) + return vcurrent[0]; +#else + return _mm256_cvtss_f32 (vcurrent); +#endif } /**