Skip to content

Commit 2f17f15

Browse files
committed
Support AVX-512 builds on Windows
"Since limited support for `/arch:AVX512` was added in Visual Studio 2017, and expanded in Visual Studio 2019"[1], we can safely offer this option, since PHP 8.4 is supposed to build with Visual Studio 2022, and it is unlikely that someone tries to build PHP 8.4 with Visual Studio, requesting AVX-512 support. [1] <https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170>
1 parent 9083ce4 commit 2f17f15

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

win32/build/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ ARG_WITH("test-ini-ext-exclude", "Comma separated list of shared extensions to \
393393
be excluded from the test.ini", "no");
394394

395395
ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations to enable. \
396-
Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2. \
396+
Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512. \
397397
SSE and SSE2 are enabled by default. The best instruction set specified will \
398398
automatically enable all the older instruction sets. Note, that the produced binary \
399399
might not work properly, if the chosen instruction sets are not available on the target \

win32/build/confutils.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,8 +3331,6 @@ function toolset_setup_common_cflags()
33313331
function toolset_setup_intrinsic_cflags()
33323332
{
33333333
var default_enabled = "sse2";
3334-
/* XXX AVX and above needs to be reflected in /arch, for now SSE4.2 is
3335-
the best possible optimization.*/
33363334
var avail = WScript.CreateObject("Scripting.Dictionary");
33373335
avail.Add("sse", "__SSE__");
33383336
avail.Add("sse2", "__SSE2__");
@@ -3341,7 +3339,7 @@ function toolset_setup_intrinsic_cflags()
33413339
avail.Add("sse4.1", "__SSE4_1__");
33423340
avail.Add("sse4.2", "__SSE4_2__");
33433341
/* From oldest to newest. */
3344-
var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2", "avx", "avx2");
3342+
var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2", "avx", "avx2", "avx512");
33453343

33463344
if (VS_TOOLSET) {
33473345
if ("disabled" == PHP_NATIVE_INTRINSICS) {
@@ -3367,9 +3365,9 @@ function toolset_setup_intrinsic_cflags()
33673365
AC_DEFINE(avail.Item(list[i]), 1);
33683366
}
33693367

3370-
/* All means all. __AVX__ and __AVX2__ are defined by compiler. */
3371-
ADD_FLAG("CFLAGS","/arch:AVX2");
3372-
configure_subst.Add("PHP_SIMD_SCALE", "AVX2");
3368+
/* All means all. __AVX__, __AVX2__, and __AVX512*__ are defined by compiler. */
3369+
ADD_FLAG("CFLAGS","/arch:AVX512");
3370+
configure_subst.Add("PHP_SIMD_SCALE", "AVX512");
33733371
} else {
33743372
var list = PHP_NATIVE_INTRINSICS.split(",");
33753373
var j = 0;
@@ -3378,7 +3376,7 @@ function toolset_setup_intrinsic_cflags()
33783376
var it = list[i].toLowerCase();
33793377
if (scale[k] == it) {
33803378
j = k > j ? k : j;
3381-
} else if (!avail.Exists(it) && "avx2" != it && "avx" != it) {
3379+
} else if (!avail.Exists(it) && "avx512" != it && "avx2" != it && "avx" != it) {
33823380
WARNING("Unknown intrinsic name '" + it + "' ignored");
33833381
}
33843382
}
@@ -3395,7 +3393,10 @@ function toolset_setup_intrinsic_cflags()
33953393
/* There is no explicit way to enable intrinsics between SSE3 and SSE4.2.
33963394
The declared macros therefore won't affect the code generation,
33973395
but will enable the guarded code parts. */
3398-
if ("avx2" == scale[j]) {
3396+
if ("avx512" == scale[j]) {
3397+
ADD_FLAG("CFLAGS","/arch:AVX512");
3398+
j -= 3;
3399+
} else if ("avx2" == scale[j]) {
33993400
ADD_FLAG("CFLAGS","/arch:AVX2");
34003401
j -= 2;
34013402
} else if ("avx" == scale[j]) {

0 commit comments

Comments
 (0)