]> granicus.if.org Git - libjpeg-turbo/commitdiff
MMI: Use aligned store instructions when possible
authorDRC <information@virtualgl.org>
Wed, 30 Jan 2019 20:12:06 +0000 (14:12 -0600)
committerDRC <information@virtualgl.org>
Thu, 31 Jan 2019 21:30:58 +0000 (15:30 -0600)
This improves decompression performance by 2-5%.

simd/loongson/jdcolext-mmi.c
simd/loongson/loongson-mmintrin.h

index 560d9b022786ae8a0ee201c742b19f097a4b4571..7f4464959a03bee4c999cd013da3a85fbf813134 100644 (file)
@@ -2,8 +2,8 @@
  * Loongson MMI optimizations for libjpeg-turbo
  *
  * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
- * Copyright (C) 2015, D. R. Commander.  All Rights Reserved.
- * Copyright (C) 2016-2017, Loongson Technology Corporation Limited, BeiJing.
+ * Copyright (C) 2015, 2019, D. R. Commander.  All Rights Reserved.
+ * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
  *                          All Rights Reserved.
  * Authors:  ZhuChen     <zhuchen@loongson.cn>
  *           SunZhangzhi <sunzhangzhi-cq@loongson.cn>
@@ -251,9 +251,15 @@ void jsimd_ycc_rgb_convert_mmi(JDIMENSION out_width, JSAMPIMAGE input_buf,
       mmC = _mm_unpacklo_pi32(mmC, mmF);    /* mmC=(15 25 06 16 26 07 17 27) */
 
       if (num_cols >= 8) {
-        _mm_store_si64((__m64 *)outptr, mmA);
-        _mm_store_si64((__m64 *)(outptr + 8), mmE);
-        _mm_store_si64((__m64 *)(outptr + 16), mmC);
+        if (!(((long)outptr) & 7)) {
+          _mm_store_si64((__m64 *)outptr, mmA);
+          _mm_store_si64((__m64 *)(outptr + 8), mmE);
+          _mm_store_si64((__m64 *)(outptr + 16), mmC);
+        } else {
+          _mm_storeu_si64((__m64 *)outptr, mmA);
+          _mm_storeu_si64((__m64 *)(outptr + 8), mmE);
+          _mm_storeu_si64((__m64 *)(outptr + 16), mmC);
+        }
         outptr += RGB_PIXELSIZE * 8;
       } else {
         col = num_cols * 3;
index 50d166b75325e17e79fc5f0edaf9618fa5c8432a..db9b35ab6064bd34117a940ef4f1b5d79e2aa428 100644 (file)
@@ -1217,14 +1217,24 @@ _mm_store_pi32(__m32 *dest, __m64 src)
 extern __inline void FUNCTION_ATTRIBS
 _mm_store_si64(__m64 *dest, __m64 src)
 {
-  asm("gssdlc1 %1, 7+%0\n\t"
-      "gssdrc1 %1, %0\n\t"
+  asm("sdc1 %1, %0 \n\t"
       : "=m" (*dest)
       : "f" (src)
       : "memory"
      );
 }
 
+extern __inline void FUNCTION_ATTRIBS
+_mm_storeu_si64(__m64 *dest, __m64 src)
+{
+  asm("gssdlc1 %1, 7(%0) \n\t"
+      "gssdrc1 %1, 0(%0) \n\t"
+      :
+      : "r" (dest), "f" (src)
+      : "memory"
+     );
+}
+
 extern __inline __m64 FUNCTION_ATTRIBS
 _mm_load_si32(const __m32 *src)
 {