]> granicus.if.org Git - php/commitdiff
Avoid direct calls to zend_cpu_supports()
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Nov 2020 10:18:10 +0000 (11:18 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Nov 2020 10:18:10 +0000 (11:18 +0100)
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
ext/standard/crc32_x86.c
ext/standard/string.c

index 53f68e09fbac382b12954a2f8cb85034f1899705..ca06f7bdea0e84e1aa20ed1c894296a260ad0ad5 100644 (file)
@@ -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;
        }
 
index 296eadeb9490bf812f901150af1178555dddac8c..eec023264002f6482ccac6bccba7caf95c9c1e2e 100644 (file)
@@ -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;
index addc2361245b5c03fce6768a74a828f0b05b656d..8d0754347a0ac4903eaf4fb464546f725faa7502 100644 (file)
@@ -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 {