summaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorAdenilson Cavalcanti <adenilson.cavalcanti@arm.com>2017-11-30 01:34:16 +0000
committerCommit Bot <commit-bot@chromium.org>2017-11-30 01:34:16 +0000
commitd7601c23c6fe4a8061394af350df935772f520f3 (patch)
treefeadec9e4490d87ecf8b4feade6e41780d8516e0 /inflate.c
parent079f41943ea7fb4ec0ccb726a21fd86ee37b024b (diff)
downloadzlib-d7601c23c6fe4a8061394af350df935772f520f3.tar.gz
Using ARMv8 CRC32 specific instruction
CRC32 affects performance for both image decompression (PNG) as also in general browsing while accessing websites that serve content using compression (i.e. Content-Encoding: gzip). This patch implements an optimized CRC32 function using the dedicated instruction available in ARMv8. This instruction is available in new Android devices featuring an ARMv8 SoC, like Nexus 5x and Google Pixel. It should be between 6x (A53: 116ms X 22ms for a 4Kx4Kx4 buffer) to 10x faster (A72: 91ms x 9ms) than the C implementation currently used by zlib. PNG decoding performance gains should be around 5-9%. Finally it also introduces code to perform the ARM CPU features detection using getauxval()@Linux/CrOS or android_getCpuFeatures(). We pre-built and link the CRC32 instruction dependent code but will decide if to use it at run time. If the feature is not supported, we fallback to the C implementation. This approach allows to use the instruction in both 32bits and 64bits builds and works fine either in ARMv7 or ARMv8 processor. I tested the generated Chromium apk in both a ARMv7 (Nexus 4 and 6) and ARMv8 (Nexus 5x and Google Pixel). Change-Id: I069408ebc06c49a3c2be4ba3253319e025ee09d7 Bug: 709716 Reviewed-on: https://chromium-review.googlesource.com/612629 Reviewed-by: Chris Blume <cblume@chromium.org> Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#520377} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 35988c821c051a57e30c76f9fcd87b7b677bd9bd
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/inflate.c b/inflate.c
index e84be46..71d07dd 100644
--- a/inflate.c
+++ b/inflate.c
@@ -85,6 +85,9 @@
#include "inflate.h"
#include "inffast.h"
#include "x86.h"
+#if defined(USE_ARMV8_CRC32)
+#include "contrib/optimizations/arm/arm_features.h"
+#endif
#ifdef MAKEFIXED
# ifndef BUILDFIXED
@@ -201,8 +204,11 @@ int stream_size;
{
int ret;
struct inflate_state FAR *state;
-
+#if defined(ADLER32_SIMD_SSE3)
x86_check_features();
+#elif defined(USE_ARMV8_CRC32)
+ arm_check_features();
+#endif
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
stream_size != (int)(sizeof(z_stream)))