[FFmpeg-devel] [PATCH] x86/synth_filter: improve FMA version
James Almer
jamrial at gmail.com
Mon Mar 17 20:40:28 CET 2014
Replace mulps+subps with fnmaddps, resulting in two less instructions inside the
inner loops.
About 1% faster FMA3 performance.
Signed-off-by: James Almer <jamrial at gmail.com>
---
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 4746784..c5a1e77 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]
- subps m1, m1, m5
%if ARCH_X86_64
- FMULADD_PS m8, m12, [win + %1 + j + mmsize + 16 * 4], m8, m12
+ 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
+ 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
+ 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
- FMULADD_PS m9, m11, [win + %1 + j + mmsize + 32 * 4], m9, m11
- FMULADD_PS m10, m12, [win + %1 + j + mmsize + 48 * 4], m10, m12
+ addps m9, m9, m11
+ addps m10, m10, m12
%endif
+%endif ; cpuflag(fma3)
sub j, 64 * 4
%endmacro
--
1.8.3.2
More information about the ffmpeg-devel
mailing list