Skip to content

Commit 4513141

Browse files
committed
Revert "Remove configure checks for supported instruction sets"
This reverts commit edccf32. This was reported to cause issues for as yet unknown reasons in bug #78769. As this was intended as code cleanup, revert this from 7.4 at least. May reapply it to master later.
1 parent c9abfae commit 4513141

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
@@ -2674,6 +2674,30 @@ AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [
26742674
[$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports])
26752675
])
26762676

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

configure.ac

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

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

0 commit comments

Comments
 (0)