From 6bfc370b193f5b757268a9bc1ed84a993db39794 Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Sat, 3 Dec 2022 22:05:02 -0800 Subject: [PATCH] Unroll longest_match() inner loop --- deflate.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/deflate.c b/deflate.c index f06f1784f..85ffa0483 100644 --- a/deflate.c +++ b/deflate.c @@ -1266,12 +1266,20 @@ static uint32_t longest_match(s, cur_match) if (xor) { int match_byte = __builtin_ctzl(xor) / 8; scan += match_byte; - match += match_byte; break; - } else { - scan += 8; - match += 8; } + scan += 8; + match += 8; + sv = *(uint64_t*)(void*)scan; + mv = *(uint64_t*)(void*)match; + xor = sv ^ mv; + if (xor) { + int match_byte = __builtin_ctzl(xor) / 8; + scan += match_byte; + break; + } + scan += 8; + match += 8; } while (scan < strend); if (scan > strend)