]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Reduce number of branches in partial chunk copy based on chunk size.
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 13 Jun 2021 22:57:28 +0000 (15:57 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 18 Jun 2021 07:19:48 +0000 (09:19 +0200)
arch/arm/chunkset_neon.c
arch/x86/chunkset_avx.c
arch/x86/chunkset_sse.c
chunkset.c
chunkset_tpl.h

index b153298275208ba8565d30d0fd967aff836ed635..22c3785c11fe3aeae4332a7f48a5c308f1943cbc 100644 (file)
@@ -13,6 +13,8 @@
 
 typedef uint8x16_t chunk_t;
 
+#define CHUNK_SIZE 16
+
 #define HAVE_CHUNKMEMSET_1
 #define HAVE_CHUNKMEMSET_2
 #define HAVE_CHUNKMEMSET_4
index eb76c0db99b6cef6557316635010b227214410bf..7a9a56a096d395c56e818e89d5e94a1b271c854b 100644 (file)
@@ -9,6 +9,8 @@
 
 typedef __m256i chunk_t;
 
+#define CHUNK_SIZE 32
+
 #define HAVE_CHUNKMEMSET_1
 #define HAVE_CHUNKMEMSET_2
 #define HAVE_CHUNKMEMSET_4
index 1d5a0faa938be87fb6e6a41036588b3f6067fae8..d38e99dad6dcddbca7bef81ff655a59efaf04cdd 100644 (file)
@@ -10,6 +10,8 @@
 
 typedef __m128i chunk_t;
 
+#define CHUNK_SIZE 16
+
 #define HAVE_CHUNKMEMSET_1
 #define HAVE_CHUNKMEMSET_2
 #define HAVE_CHUNKMEMSET_4
index 2aa8d4e47feca9681904a3d7e0d118f257bf303a..b07e6f482710f45a4af8d63bddb2c53cd95562ce 100644 (file)
@@ -14,6 +14,8 @@ typedef struct chunk_t { uint32_t u32[2]; } chunk_t;
 typedef struct chunk_t { uint8_t u8[8]; } chunk_t;
 #endif
 
+#define CHUNK_SIZE 8
+
 #define HAVE_CHUNKMEMSET_1
 #define HAVE_CHUNKMEMSET_4
 #define HAVE_CHUNKMEMSET_8
index 62cd4aa780d6862827f60fb19e2dd8638e6bb900..2026ff37ccd41fb9adf8b1a2845d308c80540d08 100644 (file)
@@ -40,17 +40,20 @@ Z_INTERNAL uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len) {
 Z_INTERNAL uint8_t* CHUNKCOPY_SAFE(uint8_t *out, uint8_t const *from, unsigned len, uint8_t *safe) {
     len = MIN(len, safe - out + 1);
     if (len < sizeof(chunk_t)) {
-        int32_t use_chunk16 = sizeof(chunk_t) > 16 && (len & 16);
-        if (use_chunk16) {
+#if CHUNK_SIZE > 16
+        if (len & 16) {
             memcpy(out, from, 16);
             out += 16;
             from += 16;
         }
+#endif
+#if CHUNK_SIZE > 8
         if (len & 8) {
             memcpy(out, from, 8);
             out += 8;
             from += 8;
         }
+#endif
         if (len & 4) {
             memcpy(out, from, 4);
             out += 4;