Skip to content

Commit 3d42d38

Browse files
committed
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 <[email protected]>
1 parent 1b3319a commit 3d42d38

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Zend/zend_cpuinfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,16 @@ static zend_always_inline int zend_cpu_supports_sse42() {
159159
return __builtin_cpu_supports("sse4.2");
160160
}
161161

162+
/* __builtin_cpu_supports has pclmul from GCC9 */
163+
#if (ZEND_GCC_VERSION >= 9000)
162164
ZEND_NO_SANITIZE_ADDRESS
163165
static zend_always_inline int zend_cpu_supports_pclmul() {
164166
#if PHP_HAVE_BUILTIN_CPU_INIT
165167
__builtin_cpu_init();
166168
#endif
167169
return __builtin_cpu_supports("pclmul");
168170
}
171+
#endif
169172

170173
ZEND_NO_SANITIZE_ADDRESS
171174
static zend_always_inline int zend_cpu_supports_avx() {

Zend/zend_portability.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ extern "C++" {
559559
#endif
560560

561561
/* Do not use for conditional declaration of API functions! */
562-
#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
562+
#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (ZEND_GCC_VERSION >= 9000)
563563
# define ZEND_INTRIN_PCLMUL_FUNC_PROTO 1
564564
#elif defined(ZEND_INTRIN_PCLMUL_RESOLVER)
565565
# define ZEND_INTRIN_PCLMUL_FUNC_PTR 1
@@ -584,7 +584,8 @@ extern "C++" {
584584
#endif
585585

586586
/* Do not use for conditional declaration of API functions! */
587-
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
587+
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (ZEND_GCC_VERSION >= 9000)
588+
/* __builtin_cpu_supports has pclmul from GCC9 */
588589
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO 1
589590
#elif defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
590591
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR 1
@@ -608,6 +609,7 @@ extern "C++" {
608609

609610
/* Do not use for conditional declaration of API functions! */
610611
#if defined(ZEND_INTRIN_AVX2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
612+
/* __builtin_cpu_supports has pclmul from GCC9 */
611613
# define ZEND_INTRIN_AVX2_FUNC_PROTO 1
612614
#elif defined(ZEND_INTRIN_AVX2_RESOLVER)
613615
# define ZEND_INTRIN_AVX2_FUNC_PTR 1

ext/standard/crc32_x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ size_t crc32_pclmul_batch(uint32_t *crc, const unsigned char *p, size_t nr, cons
173173

174174
/* barrett reduction */
175175
k = _mm_loadu_si128((__m128i*)consts->uPx);
176-
x1 = _mm_loadu_si64(&x0);
176+
x1 = _mm_move_epi64(x0);
177177
x1 = _mm_srli_si128(x1, 4);
178178
x1 = _mm_clmulepi64_si128(x1, k, 0x00);
179179
x1 = _mm_srli_si128(x1, 4);

0 commit comments

Comments
 (0)