From 3d42d383c7880d4cdc139dbeabd9949d3cb5b417 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Thu, 20 Aug 2020 00:58:25 +0000 Subject: [PATCH] Fix build for old gcc. Only enable ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO for gcc9 later, __builtin_cpu_supports support pclmul later. Also use _mm_move_epi64 instead. Signed-off-by: Frank Du --- Zend/zend_cpuinfo.h | 3 +++ Zend/zend_portability.h | 6 ++++-- ext/standard/crc32_x86.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Zend/zend_cpuinfo.h b/Zend/zend_cpuinfo.h index 5432b44f757ec..4deb5992c4c74 100644 --- a/Zend/zend_cpuinfo.h +++ b/Zend/zend_cpuinfo.h @@ -159,6 +159,8 @@ static zend_always_inline int zend_cpu_supports_sse42() { return __builtin_cpu_supports("sse4.2"); } +/* __builtin_cpu_supports has pclmul from GCC9 */ +#if (ZEND_GCC_VERSION >= 9000) ZEND_NO_SANITIZE_ADDRESS static zend_always_inline int zend_cpu_supports_pclmul() { #if PHP_HAVE_BUILTIN_CPU_INIT @@ -166,6 +168,7 @@ static zend_always_inline int zend_cpu_supports_pclmul() { #endif return __builtin_cpu_supports("pclmul"); } +#endif ZEND_NO_SANITIZE_ADDRESS static zend_always_inline int zend_cpu_supports_avx() { diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index bc44350807012..06bfb8d92d9a5 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -559,7 +559,7 @@ extern "C++" { #endif /* Do not use for conditional declaration of API functions! */ -#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) +#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (ZEND_GCC_VERSION >= 9000) # define ZEND_INTRIN_PCLMUL_FUNC_PROTO 1 #elif defined(ZEND_INTRIN_PCLMUL_RESOLVER) # define ZEND_INTRIN_PCLMUL_FUNC_PTR 1 @@ -584,7 +584,8 @@ extern "C++" { #endif /* Do not use for conditional declaration of API functions! */ -#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) +#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (ZEND_GCC_VERSION >= 9000) +/* __builtin_cpu_supports has pclmul from GCC9 */ # define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO 1 #elif defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) # define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR 1 @@ -608,6 +609,7 @@ extern "C++" { /* Do not use for conditional declaration of API functions! */ #if defined(ZEND_INTRIN_AVX2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) +/* __builtin_cpu_supports has pclmul from GCC9 */ # define ZEND_INTRIN_AVX2_FUNC_PROTO 1 #elif defined(ZEND_INTRIN_AVX2_RESOLVER) # define ZEND_INTRIN_AVX2_FUNC_PTR 1 diff --git a/ext/standard/crc32_x86.c b/ext/standard/crc32_x86.c index 5b46b227c5535..296eadeb9490b 100644 --- a/ext/standard/crc32_x86.c +++ b/ext/standard/crc32_x86.c @@ -173,7 +173,7 @@ size_t crc32_pclmul_batch(uint32_t *crc, const unsigned char *p, size_t nr, cons /* barrett reduction */ k = _mm_loadu_si128((__m128i*)consts->uPx); - x1 = _mm_loadu_si64(&x0); + x1 = _mm_move_epi64(x0); x1 = _mm_srli_si128(x1, 4); x1 = _mm_clmulepi64_si128(x1, k, 0x00); x1 = _mm_srli_si128(x1, 4);