diff options
author | Frank Du <frank.du@intel.com> | 2020-09-02 10:53:29 +0000 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-09-02 15:10:41 +0200 |
commit | c3299d7dab15aeed52a34535f1967d426f5327de (patch) | |
tree | 795ab495bd8ca3404ece2b849065f1b0d606fa36 /ext/standard/crc32.c | |
parent | cb284f668cbefa7b6dff726951c4473345e78bf9 (diff) | |
download | php-git-c3299d7dab15aeed52a34535f1967d426f5327de.tar.gz |
X86: Fast CRC32 computation using PCLMULQDQ instruction
Based on:
"Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
V. Gopal, E. Ozturk, et al., 2009, http://intel.ly/2ySEwL0
Signed-off-by: Frank Du <frank.du@intel.com>
Closes GH-6018
Diffstat (limited to 'ext/standard/crc32.c')
-rw-r--r-- | ext/standard/crc32.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 6ab5c317bf..40d9404053 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -17,6 +17,7 @@ #include "php.h" #include "basic_functions.h" #include "crc32.h" +#include "crc32_x86.h" #if HAVE_AARCH64_CRC32 # include <arm_acle.h> @@ -74,7 +75,7 @@ PHP_FUNCTION(crc32) char *p; size_t nr; uint32_t crcinit = 0; - register uint32_t crc; + uint32_t crc; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STRING(p, nr) @@ -89,6 +90,12 @@ PHP_FUNCTION(crc32) } #endif +#if ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE || ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER + size_t nr_simd = crc32_x86_simd_update(X86_CRC32B, &crc, (const unsigned char *)p, nr); + nr -= nr_simd; + p += nr_simd; +#endif + for (; nr--; ++p) { crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF ]; } |