Skip to content

Dynamic AVX detection is broken for MSVC #15292

Closed
@cmb69

Description

@cmb69

Description

4e30ab3 made a general important improvement for proper AVX detection, but unfortunately guarded the relevant code with

#if defined(__i386__) || defined(__x86_64__)

Neither of these macros are pre-defined for MSVC, what results in the following function definition:

php-src/Zend/zend_cpuinfo.c

Lines 109 to 111 in c68b43c

static bool is_avx_supported(void) {
return 0;
}

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

#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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions