From aa1f38015cb0d04a5c50a8957dd7aba79f0d8882 Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 17 Mar 2014 16:40:28 -0300 Subject: [PATCH] x86/synth_filter: improve FMA version Replace mulps+subps with fnmaddps, resulting in two less instructions inside the inner loops. About 1% faster FMA3 performance. Signed-off-by: James Almer Signed-off-by: Michael Niedermayer --- libavcodec/x86/dcadsp.asm | 42 ++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/libavcodec/x86/dcadsp.asm b/libavcodec/x86/dcadsp.asm index 4746784795..c5a1e77bc2 100644 --- a/libavcodec/x86/dcadsp.asm +++ b/libavcodec/x86/dcadsp.asm @@ -230,14 +230,27 @@ DCA_LFE_FIR 1 SHUF m11, ptr2 + j + (15 - 3) * 4 - mmsize, m12 mova m12, [ptr1 + j + mmsize] %endif - FMULADD_PS m2, m6, [win + %1 + j + 16 * 4], m2, m6 +%if cpuflag(fma3) + fmaddps m2, m6, [win + %1 + j + 16 * 4], m2 + fnmaddps m1, m5, [win + %1 + j], m1 +%if ARCH_X86_64 + fmaddps m8, m12, [win + %1 + j + mmsize + 16 * 4], m8 + fnmaddps m7, m11, [win + %1 + j + mmsize], m7 +%endif +%else ; non-FMA + mulps m6, m6, [win + %1 + j + 16 * 4] mulps m5, m5, [win + %1 + j] +%if ARCH_X86_64 + mulps m12, m12, [win + %1 + j + mmsize + 16 * 4] + mulps m11, m11, [win + %1 + j + mmsize] +%endif + addps m2, m2, m6 subps m1, m1, m5 %if ARCH_X86_64 - FMULADD_PS m8, m12, [win + %1 + j + mmsize + 16 * 4], m8, m12 - mulps m11, m11, [win + %1 + j + mmsize] + addps m8, m8, m12 subps m7, m7, m11 %endif +%endif ; cpuflag(fma3) ;~ c += window[i + j + 32] * (synth_buf[16 + i + j]) ;~ d += window[i + j + 48] * (synth_buf[31 - i + j]) SHUF m6, ptr2 + j + (31 - 3) * 4, m5 @@ -246,12 +259,27 @@ DCA_LFE_FIR 1 SHUF m12, ptr2 + j + (31 - 3) * 4 - mmsize, m11 mova m11, [ptr1 + j + mmsize + 16 * 4] %endif - FMULADD_PS m3, m5, [win + %1 + j + 32 * 4], m3, m5 - FMULADD_PS m4, m6, [win + %1 + j + 48 * 4], m4, m6 +%if cpuflag(fma3) + fmaddps m3, m5, [win + %1 + j + 32 * 4], m3 + fmaddps m4, m6, [win + %1 + j + 48 * 4], m4 %if ARCH_X86_64 - FMULADD_PS m9, m11, [win + %1 + j + mmsize + 32 * 4], m9, m11 - FMULADD_PS m10, m12, [win + %1 + j + mmsize + 48 * 4], m10, m12 + fmaddps m9, m11, [win + %1 + j + mmsize + 32 * 4], m9 + fmaddps m10, m12, [win + %1 + j + mmsize + 48 * 4], m10 %endif +%else ; non-FMA + mulps m5, m5, [win + %1 + j + 32 * 4] + mulps m6, m6, [win + %1 + j + 48 * 4] +%if ARCH_X86_64 + mulps m11, m11, [win + %1 + j + mmsize + 32 * 4] + mulps m12, m12, [win + %1 + j + mmsize + 48 * 4] +%endif + addps m3, m3, m5 + addps m4, m4, m6 +%if ARCH_X86_64 + addps m9, m9, m11 + addps m10, m10, m12 +%endif +%endif ; cpuflag(fma3) sub j, 64 * 4 %endmacro