From d7af7dd7cb395bc256f126c841139330afdde9a6 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Mon, 8 Dec 2025 10:20:49 +0100 Subject: [PATCH] Get code to compile with older VS with partial AVX2 support. This is inspired by https://aomedia.googlesource.com/aom/+/b2f80f721fe87547e3bae73be550e3d75ba478ad/aom_ports/msvc.h#57 This was reported on https://github.com/opencv/opencv/pull/28139 Change-Id: Iad38d842ef1647fc1a578a851b3593281855e30e --- src/dsp/cpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dsp/cpu.h b/src/dsp/cpu.h index 6462d870..23154723 100644 --- a/src/dsp/cpu.h +++ b/src/dsp/cpu.h @@ -94,6 +94,17 @@ #define WEBP_HAVE_AVX2 #endif +#if defined(WEBP_MSC_AVX2) && _MSC_VER <= 1900 +#include + +static WEBP_INLINE int _mm256_extract_epi32(__m256i a, const int i) { + return a.m256i_i32[i & 7]; +} +static WEBP_INLINE int _mm256_cvtsi256_si32(__m256i a) { + return _mm256_extract_epi32(a, 0); +} +#endif + #undef WEBP_MSC_AVX2 #undef WEBP_MSC_SSE41 #undef WEBP_MSC_SSE2