@@ -3397,7 +3397,7 @@ function toolset_setup_intrinsic_cflags()
33973397 /* From oldest to newest. */
33983398 var scale = new Array ( "sse" , "sse2" , "sse3" , "ssse3" , "sse4.1" , "sse4.2" , "avx" , "avx2" , "avx512" ) ;
33993399
3400- if ( "disabled" == PHP_NATIVE_INTRINSICS || "no" == PHP_NATIVE_INTRINSICS ) {
3400+ if ( "disabled" == PHP_NATIVE_INTRINSICS ) {
34013401 return ;
34023402 }
34033403
@@ -3409,7 +3409,8 @@ function toolset_setup_intrinsic_cflags()
34093409 return ;
34103410 }
34113411
3412- if ( "yes" == PHP_NATIVE_INTRINSICS ) {
3412+ // if --enable-native-intrisics is not specified, it's "no" - enable default
3413+ if ( "no" == PHP_NATIVE_INTRINSICS || "yes" == PHP_NATIVE_INTRINSICS ) {
34133414 PHP_NATIVE_INTRINSICS = default_enabled ;
34143415 }
34153416
@@ -3449,9 +3450,6 @@ function toolset_setup_intrinsic_cflags()
34493450 }
34503451 }
34513452 configure_subst . Add ( "PHP_SIMD_SCALE" , scale [ j ] . toUpperCase ( ) ) ;
3452- /* There is no explicit way to enable intrinsics between SSE3 and SSE4.2.
3453- The declared macros therefore won't affect the code generation,
3454- but will enable the guarded code parts. */
34553453 if ( "avx512" == scale [ j ] ) {
34563454 ADD_FLAG ( "CFLAGS" , VS_TOOLSET ? "/arch:AVX512" : "-mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl" ) ;
34573455 j -= 3 ;
@@ -3463,11 +3461,24 @@ function toolset_setup_intrinsic_cflags()
34633461 j -= 1 ;
34643462 }
34653463 if ( VS_TOOLSET ) {
3466- /* MSVC doesn't auto-define SSE macros; clang does with -m flags */
3464+ /* MSVC has no explicit way to enable intrinsics between SSE3 and SSE4.2.
3465+ The declared macros won't affect code generation, but will enable
3466+ the guarded code parts. */
34673467 for ( var i = 0 ; i <= j ; i ++ ) {
34683468 var it = scale [ i ] ;
34693469 AC_DEFINE ( avail . Item ( it ) , 1 ) ;
34703470 }
3471+ } else if ( CLANG_TOOLSET ) {
3472+ /* clang supports -m flags for each SSE level and auto-defines
3473+ the corresponding __SSE*__ macros. Pass the highest requested
3474+ level; clang implicitly enables all lower levels. */
3475+ var clang_flag_map = {
3476+ "sse" : "-msse" , "sse2" : "-msse2" , "sse3" : "-msse3" ,
3477+ "ssse3" : "-mssse3" , "sse4.1" : "-msse4.1" , "sse4.2" : "-msse4.2"
3478+ } ;
3479+ if ( clang_flag_map [ scale [ j ] ] ) {
3480+ ADD_FLAG ( "CFLAGS" , clang_flag_map [ scale [ j ] ] ) ;
3481+ }
34713482 }
34723483 }
34733484}
0 commit comments