From 2772f7c3ad1537e2dc265a94faf09ecdacead9f2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 27 Nov 2020 11:18:10 +0100 Subject: [PATCH] Avoid direct calls to zend_cpu_supports() While the use of zend_cpu_supports_*() is only strictly necessary inside ifunc resolvers, where the cpu state has not been initialized yet, we should prefer the compiler builtins in all cases. --- ext/opcache/jit/zend_jit_x86.dasc | 4 ++-- ext/standard/crc32_x86.c | 2 +- ext/standard/string.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 53f68e09fb..ca06f7bdea 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -2849,12 +2849,12 @@ extern char *_tls_end; static int zend_jit_setup(void) { - if (!zend_cpu_supports(ZEND_CPU_FEATURE_SSE2)) { + if (!zend_cpu_supports_sse2()) { zend_error(E_CORE_ERROR, "CPU doesn't support SSE2"); return FAILURE; } allowed_opt_flags = 0; - if (zend_cpu_supports(ZEND_CPU_FEATURE_AVX)) { + if (zend_cpu_supports_avx()) { allowed_opt_flags |= ZEND_JIT_CPU_AVX; } diff --git a/ext/standard/crc32_x86.c b/ext/standard/crc32_x86.c index 296eadeb94..eec0232640 100644 --- a/ext/standard/crc32_x86.c +++ b/ext/standard/crc32_x86.c @@ -339,7 +339,7 @@ size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(crc32_x86_intrin) { - if (zend_cpu_supports(ZEND_CPU_FEATURE_SSE42) && zend_cpu_supports(ZEND_CPU_FEATURE_PCLMULQDQ)) { + if (zend_cpu_supports_sse42() && zend_cpu_supports_pclmul()) { crc32_x86_simd_ptr = crc32_sse42_pclmul_update; } return SUCCESS; diff --git a/ext/standard/string.c b/ext/standard/string.c index addc236124..8d0754347a 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3615,7 +3615,7 @@ PHPAPI void php_stripslashes(zend_string *str) { /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(string_intrin) { - if (zend_cpu_supports(ZEND_CPU_FEATURE_SSE42)) { + if (zend_cpu_supports_sse42()) { php_addslashes_ptr = php_addslashes_sse42; php_stripslashes_ptr = php_stripslashes_sse42; } else { -- 2.40.0