Skip to content

Commit b509d67

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Revert "Remove configure checks for supported instruction sets"
2 parents 5b447d4 + 4513141 commit b509d67

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

Zend/zend_portability.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,21 +532,21 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
532532
#endif
533533

534534
#if (defined(__i386__) || defined(__x86_64__))
535-
# if defined(HAVE_TMMINTRIN_H)
536-
# define PHP_HAVE_SSSE3
535+
# if PHP_HAVE_SSSE3_INSTRUCTIONS && defined(HAVE_TMMINTRIN_H)
536+
# define PHP_HAVE_SSSE3
537537
# endif
538538

539-
# if defined(HAVE_NMMINTRIN_H)
540-
# define PHP_HAVE_SSE4_2
539+
# if PHP_HAVE_SSE4_2_INSTRUCTIONS && defined(HAVE_NMMINTRIN_H)
540+
# define PHP_HAVE_SSE4_2
541541
# endif
542542

543543
/*
544544
* AVX2 support was added in gcc 4.7, but AVX2 intrinsics don't work in
545545
* __attribute__((target("avx2"))) functions until gcc 4.9.
546546
*/
547-
# if defined(HAVE_IMMINTRIN_H) && \
547+
# if PHP_HAVE_AVX2_INSTRUCTIONS && defined(HAVE_IMMINTRIN_H) && \
548548
(defined(__llvm__) || defined(__clang__) || (defined(__GNUC__) && ZEND_GCC_VERSION >= 4009))
549-
# define PHP_HAVE_AVX2
549+
# define PHP_HAVE_AVX2
550550
# endif
551551
#endif
552552

build/php.m4

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,30 @@ AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [
26772677
[$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports])
26782678
])
26792679

2680+
dnl
2681+
dnl PHP_CHECK_CPU_SUPPORTS
2682+
dnl
2683+
AC_DEFUN([PHP_CHECK_CPU_SUPPORTS], [
2684+
AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_INIT])
2685+
AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_SUPPORTS])
2686+
have_ext_instructions=0
2687+
if test $have_builtin_cpu_supports = 1; then
2688+
AC_MSG_CHECKING([for $1 instructions supports])
2689+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
2690+
int main() {
2691+
return __builtin_cpu_supports("$1")? 0 : 1;
2692+
}
2693+
]])], [
2694+
have_ext_instructions=1
2695+
AC_MSG_RESULT([yes])
2696+
], [
2697+
AC_MSG_RESULT([no])
2698+
], [AC_MSG_RESULT([no])])
2699+
fi
2700+
AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HAVE_$1_INSTRUCTIONS]),
2701+
[$have_ext_instructions], [Whether the compiler supports $1 instructions])
2702+
])
2703+
26802704
dnl
26812705
dnl PHP_PATCH_CONFIG_HEADERS([FILE])
26822706
dnl

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ PHP_CHECK_BUILTIN_CPU_INIT
540540
dnl Check __builtin_cpu_supports
541541
PHP_CHECK_BUILTIN_CPU_SUPPORTS
542542

543+
dnl Check instructions.
544+
PHP_CHECK_CPU_SUPPORTS([ssse3])
545+
PHP_CHECK_CPU_SUPPORTS([sse4.2])
546+
PHP_CHECK_CPU_SUPPORTS([avx])
547+
PHP_CHECK_CPU_SUPPORTS([avx2])
548+
543549
dnl Check for structure members.
544550
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
545551
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])

0 commit comments

Comments
 (0)