Skip to content

Commit 2772f7c

Browse files
committed
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.
1 parent f35b194 commit 2772f7c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,12 +2849,12 @@ extern char *_tls_end;
28492849

28502850
static int zend_jit_setup(void)
28512851
{
2852-
if (!zend_cpu_supports(ZEND_CPU_FEATURE_SSE2)) {
2852+
if (!zend_cpu_supports_sse2()) {
28532853
zend_error(E_CORE_ERROR, "CPU doesn't support SSE2");
28542854
return FAILURE;
28552855
}
28562856
allowed_opt_flags = 0;
2857-
if (zend_cpu_supports(ZEND_CPU_FEATURE_AVX)) {
2857+
if (zend_cpu_supports_avx()) {
28582858
allowed_opt_flags |= ZEND_JIT_CPU_AVX;
28592859
}
28602860

ext/standard/crc32_x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ size_t crc32_x86_simd_update(X86_CRC32_TYPE type, uint32_t *crc, const unsigned
339339
/* {{{ PHP_MINIT_FUNCTION */
340340
PHP_MINIT_FUNCTION(crc32_x86_intrin)
341341
{
342-
if (zend_cpu_supports(ZEND_CPU_FEATURE_SSE42) && zend_cpu_supports(ZEND_CPU_FEATURE_PCLMULQDQ)) {
342+
if (zend_cpu_supports_sse42() && zend_cpu_supports_pclmul()) {
343343
crc32_x86_simd_ptr = crc32_sse42_pclmul_update;
344344
}
345345
return SUCCESS;

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,7 @@ PHPAPI void php_stripslashes(zend_string *str) {
36153615
/* {{{ PHP_MINIT_FUNCTION */
36163616
PHP_MINIT_FUNCTION(string_intrin)
36173617
{
3618-
if (zend_cpu_supports(ZEND_CPU_FEATURE_SSE42)) {
3618+
if (zend_cpu_supports_sse42()) {
36193619
php_addslashes_ptr = php_addslashes_sse42;
36203620
php_stripslashes_ptr = php_stripslashes_sse42;
36213621
} else {

0 commit comments

Comments
 (0)