mmx: Use Loongson pextrh instruction in expand565
authorMatt Turner <mattst88@gmail.com>
Tue, 17 Apr 2012 16:16:55 +0000 (12:16 -0400)
committerMatt Turner <mattst88@gmail.com>
Fri, 27 Apr 2012 17:42:07 +0000 (13:42 -0400)
Same story as pinsrh in the previous commit.

 text data bss dec hex filename
25336 1952   0   27288    6a98 .libs/libpixman_loongson_mmi_la-pixman-mmx.o
25072 1952   0   27024    6990 .libs/libpixman_loongson_mmi_la-pixman-mmx.o

-dsll: 95
+dsll: 70
-dsrl: 135
+dsrl: 105
-ldc1: 462
+ldc1: 445
-lw: 721
+lw: 700
+pextrh: 30

pixman/loongson-mmintrin.h
pixman/pixman-mmx.c

index 1c74ed8..508366c 100644 (file)
@@ -218,6 +218,17 @@ _mm_xor_si64 (__m64 __m1, __m64 __m2)
 }
 
 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+loongson_extract_pi16 (__m64 __m, int64_t __pos)
+{
+       __m64 ret;
+       asm("pextrh %0, %1, %2\n\t"
+          : "=f" (ret)
+          : "f" (__m), "f" (*(__m64 *)&__pos)
+       );
+       return ret;
+}
+
+extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 loongson_insert_pi16 (__m64 __m1, __m64 __m2, int64_t __pos)
 {
        __m64 ret;
index 7aa4019..d5d34ac 100644 (file)
@@ -493,7 +493,11 @@ expand565 (__m64 pixel, int pos)
     __m64 t1, t2;
 
     /* move pixel to low 16 bit and zero the rest */
+#ifdef USE_LOONGSON_MMI
+    p = loongson_extract_pi16 (p, pos);
+#else
     p = shift (shift (p, (3 - pos) * 16), -48);
+#endif
 
     t1 = shift (p, 36 - 11);
     t2 = shift (p, 16 - 5);