diff --git a/zlib/deflate.c b/zlib/deflate.c index b00bdca..ea92322 100644 --- a/zlib/deflate.c +++ b/zlib/deflate.c @@ -49,6 +49,9 @@ /* @(#) $Id$ */ +#if __ARM_NEON +#include +#endif #include "deflate.h" const char deflate_copyright[] = @@ -1253,6 +1256,43 @@ local void check_match(s, start, match, length) # define check_match(s, start, match, length) #endif /* DEBUG */ +#if __ARM_NEON +/* ARM neon version of hash table rebase */ +local inline void slide_hash_table(Posf *table, uInt entries, unsigned window_size) +{ + register uint16x8_t v, *p; + register size_t n; + + size_t size = entries*sizeof(table[0]); + Assert((size % sizeof(uint16x8_t) * 8 == 0), "hash table size err"); + + Assert(sizeof(Posf) == 2, "Wrong Posf size"); + v = vdupq_n_u16(window_size); + + p = (uint16x8_t *)table; + n = size / (sizeof(uint16x8_t) * 8); + do { + p[0] = vqsubq_u16(p[0], v); + p[1] = vqsubq_u16(p[1], v); + p[2] = vqsubq_u16(p[2], v); + p[3] = vqsubq_u16(p[3], v); + p[4] = vqsubq_u16(p[4], v); + p[5] = vqsubq_u16(p[5], v); + p[6] = vqsubq_u16(p[6], v); + p[7] = vqsubq_u16(p[7], v); + p += 8; + } while (--n); +} +#else +/* generic version for hash table rebase */ +local inline void slide_hash_table(Posf *table, uInt entries, unsigned window_size) +{ + uInt i; + for (i = 0; i < entries; i++) { + table[i] = (table[i] >= window_size) ? (table[i] - window_size) : NIL; + } +} +#endif /* =========================================================================== * Fill the window when the lookahead becomes insufficient. * Updates strstart and lookahead. @@ -1304,23 +1344,10 @@ local void fill_window(s) zlib, so we don't care about this pathological case.) */ /* %%% avoid this when Z_RLE */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); + slide_hash_table(s->head, s->hash_size, wsize); - n = wsize; #ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); + slide_hash_table(s->prev, wsize, wsize); #endif more += wsize; }