adenilson / rpms / zlib

Forked from rpms/zlib 9 months ago
Clone
e6944d
--- a/configure	2022-04-19 17:46:39.589212290 +0300
e6944d
+++ b/configure	2022-04-19 17:48:26.737818784 +0300
e6944d
@@ -115,6 +115,7 @@
e6944d
       echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
e6944d
       echo '    [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
e6944d
       echo '    [--dfltcc]' | tee -a configure.log
e6944d
+      echo '    [--enable-sse_slide]' | tee -a configure.log
e6944d
         exit 0 ;;
e6944d
     -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
e6944d
     -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
e6944d
@@ -144,6 +145,12 @@
e6944d
 	    PIC_OBJC="$PIC_OBJC dfltcc.lo"
e6944d
       shift
e6944d
       ;; 
e6944d
+    --enable-sse_slide)
e6944d
+	    CFLAGS="$CFLAGS -DUSE_SSE_SLIDE"
e6944d
+	    OBJC="$OBJC slide_sse.o"
e6944d
+	    PIC_OBJC="$PIC_OBJC slide_sse.lo"
e6944d
+      shift
e6944d
+      ;; 
e6944d
     *)
e6944d
       echo "unknown option: $1" | tee -a configure.log
e6944d
       echo "$0 --help for help" | tee -a configure.log
e6944d
--- a/Makefile.in	2022-04-11 18:00:47.184530801 +0300
e6944d
+++ b/Makefile.in	2022-04-11 18:02:47.815927655 +0300
e6944d
@@ -151,6 +151,14 @@
e6944d
 	$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/dfltcc.o $(SRCDIR)contrib/s390/dfltcc.c
e6944d
 	-@mv objs/dfltcc.o $@
e6944d
 
e6944d
+slide_sse.o: $(SRCDIR)slide_sse.c
e6944d
+	$(CC) $(CFLAGS) $(ZINC) -msse2 -c -o $@ $(SRCDIR)slide_sse.c
e6944d
+
e6944d
+slide_sse.lo: $(SRCDIR)slide_sse.c
e6944d
+	-@mkdir objs 2>/dev/null || test -d objs
e6944d
+	$(CC) $(SFLAGS) $(ZINC) -DPIC -msse2 -c -o objs/slide_sse.o $(SRCDIR)slide_sse.c
e6944d
+	-@mv objs/slide_sse.o $@
e6944d
+
e6944d
 example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
e6944d
 	$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c
e6944d
 
e6944d
--- a/deflate.c	2022-04-19 11:43:42.333320519 +0300
e6944d
+++ b/deflate.c	2022-04-19 15:55:30.636531139 +0300
e6944d
@@ -90,6 +90,8 @@
e6944d
 
e6944d
 local int deflateStateCheck      OF((z_streamp strm));
e6944d
 local void slide_hash     OF((deflate_state *s));
e6944d
+local void slide_hash_c     OF((deflate_state *s));
e6944d
+extern void slide_hash_sse     (deflate_state *s);
e6944d
 local void fill_window    OF((deflate_state *s));
e6944d
 local block_state deflate_stored OF((deflate_state *s, int flush));
e6944d
 local block_state deflate_fast   OF((deflate_state *s, int flush));
e6944d
@@ -212,7 +214,7 @@
e6944d
  * bit values at the expense of memory usage). We slide even when level == 0 to
e6944d
  * keep the hash table consistent if we switch back to level > 0 later.
e6944d
  */
e6944d
-local void slide_hash(s)
e6944d
+local void slide_hash_c(s)
e6944d
     deflate_state *s;
e6944d
 {
e6944d
     unsigned n, m;
e6944d
@@ -238,6 +240,15 @@
e6944d
 #endif
e6944d
 }
e6944d
 
e6944d
+local void slide_hash(deflate_state *s)
e6944d
+{
e6944d
+#ifdef USE_SSE_SLIDE
e6944d
+	slide_hash_sse(s);
e6944d
+#else
e6944d
+	slide_hash_c(s);
e6944d
+#endif
e6944d
+}
e6944d
+
e6944d
 /* ========================================================================= */
e6944d
 int ZEXPORT deflateInit_(strm, level, version, stream_size)
e6944d
     z_streamp strm;
e6944d
diff --git a/slide_sse.c b/slide_sse.c
e6944d
new file mode 100644
e6944d
index 0000000..2ef2669
e6944d
--- /dev/null
e6944d
+++ b/slide_sse.c
e6944d
@@ -0,0 +1,49 @@
e6944d
+/*
e6944d
+ * SSE optimized hash slide
e6944d
+ *
e6944d
+ * Copyright (C) 2017 Intel Corporation
e6944d
+ * Authors:
e6944d
+ *   Arjan van de Ven	<arjan@linux.intel.com>
e6944d
+ *   Jim Kukunas	<james.t.kukunas@linux.intel.com>
e6944d
+ *
e6944d
+ * For conditions of distribution and use, see copyright notice in zlib.h
e6944d
+ */
e6944d
+#include "deflate.h"
e6944d
+#include <immintrin.h>
e6944d
+
e6944d
+void slide_hash_sse(deflate_state *s)
e6944d
+{
e6944d
+    unsigned n;
e6944d
+    Posf *p;
e6944d
+    uInt wsize = s->w_size;
e6944d
+    z_const __m128i xmm_wsize = _mm_set1_epi16(s->w_size);
e6944d
+
e6944d
+    n = s->hash_size;
e6944d
+    p = &s->head[n] - 8;
e6944d
+    do {
e6944d
+        __m128i value, result;
e6944d
+
e6944d
+	value = _mm_loadu_si128((__m128i *)p);
e6944d
+	result= _mm_subs_epu16(value, xmm_wsize);
e6944d
+	_mm_storeu_si128((__m128i *)p, result);
e6944d
+	p -= 8;
e6944d
+	n -= 8;
e6944d
+    } while (n > 0);
e6944d
+
e6944d
+#ifndef FASTEST
e6944d
+    n = wsize;
e6944d
+    p = &s->prev[n] - 8;
e6944d
+    do {
e6944d
+        __m128i value, result;
e6944d
+
e6944d
+	value = _mm_loadu_si128((__m128i *)p);
e6944d
+	result= _mm_subs_epu16(value, xmm_wsize);
e6944d
+	_mm_storeu_si128((__m128i *)p, result);
e6944d
+
e6944d
+	p -= 8;
e6944d
+	n -= 8;
e6944d
+    } while (n > 0);
e6944d
+#endif
e6944d
+}
e6944d
+
e6944d
+
e6944d
-- 
e6944d
2.27.0
e6944d