[x265] [PATCH] copy_cnt_16, AVX2 asm code as per new interface, performance improved from 14.22x to 23.57x on HASWELL-I5

praveen at multicorewareinc.com praveen at multicorewareinc.com
Wed Sep 10 10:05:40 CEST 2014


# HG changeset patch
# User Praveen Tiwari
# Date 1410336330 -19800
# Node ID c5b3e04e4eba2fcc4298c225d11ab25e0da82558
# Parent  d29cb300975a491287abdfb6abd2a9d3141e99f0
copy_cnt_16, AVX2 asm code as per new interface, performance improved from 14.22x to 23.57x on HASWELL-I5

diff -r d29cb300975a -r c5b3e04e4eba source/common/x86/blockcopy8.asm
--- a/source/common/x86/blockcopy8.asm	Wed Sep 10 11:22:51 2014 +0530
+++ b/source/common/x86/blockcopy8.asm	Wed Sep 10 13:35:30 2014 +0530
@@ -4187,69 +4187,69 @@
 
 
 INIT_YMM avx2
-cglobal copy_cnt_16, 3,5,5
+cglobal copy_cnt_16, 3,5,7
     add         r2d, r2d
-    lea         r4, [r2 * 3]
-    mov         r3d, 16/4
-    ; NOTE: xorpd is faster than pxor
-    xorpd       m4, m4
-    xorpd       m3, m3
-
-.loop
-    ; row 0
+    lea         r3,  [r2 * 3]
+    mov         r4d, 256/128
+
+    xorpd       m5, m5
+    xorpd       m6, m6
+
+.loop:
+    ; row 0 - 1
     movu        m0, [r1]
-    movu        xm1, [r1 + mmsize/2]
-    pmovsxwd    m2, xm0
-    pmovsxwd    m1, xm1
-    movu        [r0 + 0 * mmsize], m2
-    movu        [r0 + 1 * mmsize], m1
-
-    ; row 1
+    movu        [r0], m0
     movu        m1, [r1 + r2]
-    movu        xm2, [r1 + r2 + mmsize/2]
-    packsswb    m0, m1
-    pcmpeqb     m0, m3
-    paddb       m4, m0
-    pmovsxwd    m1, xm1
-    pmovsxwd    m2, xm2
-    movu        [r0 + 2 * mmsize], m1
-    movu        [r0 + 3 * mmsize], m2
-
-    ; move output pointer here to avoid 128 bytes offset limit
-    add         r0, 4 * mmsize
-
-    ; row 2
-    movu        m0, [r1 + r2 * 2]
-    movu        xm1, [r1 + r2 * 2 + mmsize/2]
-    pmovsxwd    m2, xm0
-    pmovsxwd    m1, xm1
-    movu        [r0 + 0 * mmsize], m2
-    movu        [r0 + 1 * mmsize], m1
-
-    ; row 3
-    movu        m1, [r1 + r4]
-    movu        xm2, [r1 + r4 + mmsize/2]
-    packsswb    m0, m1
-    pcmpeqb     m0, m3
-    paddb       m4, m0
-    pmovsxwd    m1, xm1
-    pmovsxwd    m2, xm2
-    movu        [r0 + 2 * mmsize], m1
-    movu        [r0 + 3 * mmsize], m2
-
-    add         r0, 4 * mmsize
-    lea         r1, [r1 + r2 * 4]
-    dec         r3d
+    movu        [r0 + 32], m1
+
+    vpacksswb    m0, m1
+    pminub       m0, [pb_1]
+
+    ; row 2 - 3
+    movu        m1, [r1 + r2 * 2]
+    movu        [r0 + 64], m1
+    movu        m2, [r1 + r3]
+    movu        [r0 + 96], m2
+
+    vpacksswb    m1, m2
+    pminub       m1, [pb_1]
+    paddb        m0, m1
+
+    ; row 4 - 5
+    lea        r1, [r1 + r2 * 4]
+    movu       m2, [r1]
+    movu       [r0 + 128], m2
+    movu       m3, [r1 + r2]
+    movu       [r0 + 160], m3
+
+    vpacksswb    m2, m3
+    pminub       m2, [pb_1]
+
+    ; row 6 - 7
+    movu       m3, [r1 + r2 * 2]
+    movu       [r0 + 192], m3
+    movu       m4, [r1 + r3]
+    movu       [r0 + 224], m4
+
+    vpacksswb    m3, m4
+    pminub       m3, [pb_1]
+    paddb        m2, m3
+
+    paddb        m0, m2
+    paddb        m6, m0
+
+    add         r0, 256
+    lea         r1, [r1 + 4 * r2]
+    dec         r4d
     jnz        .loop
 
     ; get count
-    vextracti128 xm0, m4, 1
-    paddb        xm0, xm4
-    movhlps     xm1, xm0
-    paddb       xm0, xm1
-    paddb       xm0, [pb_32]
-    psadbw      xm0, xm3
-    movd        eax, xm0
+    vextracti128 xm1, m6, 1
+    paddb        xm6, xm1
+    psadbw       xm6, xm5
+    movhlps      xm1, xm6
+    paddd        xm6, xm1
+    movd         eax, xm6
     RET
 
 ;--------------------------------------------------------------------------------------


More information about the x265-devel mailing list