shithub: opus

Download patch

ref: 9cf12e92bbd25b2416b340b06090efbde9ad3fa6
parent: 833688e65dda31b6cfc319b5dcd0a54f3a2ef616
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Wed Feb 21 23:49:51 EST 2024

Improve AVX2 compiler support detection.

Commit 735c40706f37 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.

--- a/configure.ac
+++ b/configure.ac
@@ -691,10 +691,17 @@
            #include <time.h>
          ]],
          [[
+             unsigned char utest[16] = {1};
              __m256 mtest;
+             __m256 mtest1;
+             __m256 mtest2;
              mtest = _mm256_set1_ps((float)time(NULL));
              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"],
--