Check FMA3 support before use it in SincResampler

This is a port of crrev.com/c/2936677.

Previously we only checked avx2 support and then use avx2/fma
intrinsics in SincResampler(crrev.com/c/2654647),this CL also
checks the fma support and avoids using avx2 code if fma is not
supported.

Bug: chromium:1410691
Change-Id: Ibf7c0a1bead87ebe5d3978cfd20cc23525169f40
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291702
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39238}
This commit is contained in:
Henrik Lundin 2023-01-31 15:49:55 +00:00 committed by WebRTC LUCI CQ
parent 0b7184ce06
commit cb4b0a6ad2
3 changed files with 6 additions and 3 deletions

View file

@ -126,8 +126,8 @@ void SincResampler::InitializeCPUSpecificFeatures() {
#if defined(WEBRTC_HAS_NEON)
convolve_proc_ = Convolve_NEON;
#elif defined(WEBRTC_ARCH_X86_FAMILY)
// Using AVX2 instead of SSE2 when AVX2 supported.
if (GetCPUInfo(kAVX2))
// Using AVX2 instead of SSE2 when AVX2/FMA3 supported.
if (GetCPUInfo(kAVX2) && GetCPUInfo(kFMA3))
convolve_proc_ = Convolve_AVX2;
else if (GetCPUInfo(kSSE2))
convolve_proc_ = Convolve_SSE;

View file

@ -16,7 +16,7 @@
namespace webrtc {
// List of features in x86.
typedef enum { kSSE2, kSSE3, kAVX2 } CPUFeature;
typedef enum { kSSE2, kSSE3, kAVX2, kFMA3 } CPUFeature;
// List of features in ARM.
enum {

View file

@ -103,6 +103,9 @@ int GetCPUInfo(CPUFeature feature) {
(cpu_info7[1] & 0x00000100) != 0 /* BMI2 */;
}
#endif // WEBRTC_ENABLE_AVX2
if (feature == kFMA3) {
return 0 != (cpu_info[2] & 0x00001000);
}
return 0;
}
#else