Improve AVX2 compiler support detection.

Commit 735c40706f added uses of intrinsics that require at least
 gcc 9.0 (cf. <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78782>),
 even though AVX2 support may appear to be available in earlier gcc
 versions.
We were not testing for this.
Update the compiler test in configure.ac to use these intrinsics
 explicitly, so it will error out and disable AVX2 if they are not
 available.
This commit is contained in:
Timothy B. Terriberry 2024-02-22 04:49:51 -08:00
parent 833688e65d
commit 9cf12e92bb
No known key found for this signature in database
GPG key ID: 5A1149C19C699E4F

View file

@ -691,10 +691,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[
#include <time.h> #include <time.h>
]], ]],
[[ [[
unsigned char utest[16] = {1};
__m256 mtest; __m256 mtest;
__m256 mtest1;
__m256 mtest2;
mtest = _mm256_set1_ps((float)time(NULL)); mtest = _mm256_set1_ps((float)time(NULL));
mtest = _mm256_fmadd_ps(mtest, mtest, mtest); mtest = _mm256_fmadd_ps(mtest, mtest, mtest);
return _mm256_extract_epi16(_mm256_cvttps_epi32(mtest), 0); mtest1 = _mm256_set_m128i(_mm_loadu_si64(utest));
mtest2 =
_mm256_cvtepi16_epi32(_mm_loadu_si128((__m128i_u *)utest));
return _mm256_extract_epi16(_mm256_xor_si256(
_mm256_xor_si256(mtest1, mtest2), _mm256_cvttps_epi32(mtest)), 0);
]] ]]
) )
AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1" && test x"$OPUS_X86_PRESUME_AVX2" != x"1"], AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1" && test x"$OPUS_X86_PRESUME_AVX2" != x"1"],