[php-src] Issue #15292: Dynamic AVX detection is broken for MSVC
| From: | cmb69 | Date: | Thu, 08 Aug 2024 11:47:20 +0000 |
| Subject: | [php-src] Issue #15292: Dynamic AVX detection is broken for MSVC | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247463@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15292
Author: cmb69
### Description
https://github.com/php/php-src/commit/4e30ab33d84232ba2686e7ed5b125861db63142d
made a general important improvement for proper AVX detection, but unfortunately guarded the
relevant code with
https://github.com/php/php-src/blob/c68b43c71bc32eafd3597184a9971caa4157ba21/Zend/zend_cpuinfo.c#L76
Neither of these macros are pre-defined for MSVC, what results in the following function definition:
https://github.com/php/php-src/blob/c68b43c71bc32eafd3597184a9971caa4157ba21/Zend/zend_cpuinfo.c#L109-L111
That means that even though AVX and even AVX2 are supported by the processor, no support is flagged,
and the optimized implementations are never called.
If I change the guard code to
````c
#if defined(_WIN32) || defined(_WIN64)
````
AVX detections works on my machine (x64, have not tested x86 yet), but I'm not sure whether
these would be the appropriate macros, or whether ARM needs special treatment. Maybe someone else
knows, or could test it (I don't have an ARM available).
In my opinion, we need to fix this for
master and may consider to target a lower branch
(maybe backport only after a while, when PHP 8.4 has been sufficiently tested).
### PHP Version
PHP 7.4+
### Operating System
Windows