Skip to content

Commit 5dc9418

Browse files
committed
Reapply "Remove configure checks for supported instruction sets"
I reverted this previously for 7.4 because of bug #78769. Relanding it now for master, because I still believe that this change is right, and if it causes complications, those indicate a bug elsewhere. --- These were checking whether the instruction set is supported by the host CPU, however they were only used to condition on whether this instruction set is targeted at all. It would still use dynamic dispatch (e.g. based on ifunc resolvers) to select the actual implementation. Whether the target is guaranteed to support the instruction set without dispatch is determined based on pre-defined macros like __SSE2__. This removes the configure-time builtin cpu checks to remove confusion. Additionally this allows targeting an architecture that is newer than the host architecture.
1 parent a0abc26 commit 5dc9418

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

Zend/zend_portability.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,21 @@ extern "C++" {
494494
#endif
495495

496496
#if (defined(__i386__) || defined(__x86_64__))
497-
# if PHP_HAVE_SSSE3_INSTRUCTIONS && defined(HAVE_TMMINTRIN_H)
498-
# define PHP_HAVE_SSSE3
497+
# if defined(HAVE_TMMINTRIN_H)
498+
# define PHP_HAVE_SSSE3
499499
# endif
500500

501-
# if PHP_HAVE_SSE4_2_INSTRUCTIONS && defined(HAVE_NMMINTRIN_H)
502-
# define PHP_HAVE_SSE4_2
501+
# if defined(HAVE_NMMINTRIN_H)
502+
# define PHP_HAVE_SSE4_2
503503
# endif
504504

505505
/*
506506
* AVX2 support was added in gcc 4.7, but AVX2 intrinsics don't work in
507507
* __attribute__((target("avx2"))) functions until gcc 4.9.
508508
*/
509-
# if PHP_HAVE_AVX2_INSTRUCTIONS && defined(HAVE_IMMINTRIN_H) && \
509+
# if defined(HAVE_IMMINTRIN_H) && \
510510
(defined(__llvm__) || defined(__clang__) || (defined(__GNUC__) && ZEND_GCC_VERSION >= 4009))
511-
# define PHP_HAVE_AVX2
511+
# define PHP_HAVE_AVX2
512512
# endif
513513
#endif
514514

build/php.m4

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

2672-
dnl
2673-
dnl PHP_CHECK_CPU_SUPPORTS
2674-
dnl
2675-
AC_DEFUN([PHP_CHECK_CPU_SUPPORTS], [
2676-
AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_INIT])
2677-
AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_SUPPORTS])
2678-
have_ext_instructions=0
2679-
if test $have_builtin_cpu_supports = 1; then
2680-
AC_MSG_CHECKING([for $1 instructions supports])
2681-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
2682-
int main() {
2683-
return __builtin_cpu_supports("$1")? 0 : 1;
2684-
}
2685-
]])], [
2686-
have_ext_instructions=1
2687-
AC_MSG_RESULT([yes])
2688-
], [
2689-
AC_MSG_RESULT([no])
2690-
], [AC_MSG_RESULT([no])])
2691-
fi
2692-
AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HAVE_$1_INSTRUCTIONS]),
2693-
[$have_ext_instructions], [Whether the compiler supports $1 instructions])
2694-
])
2695-
26962672
dnl
26972673
dnl PHP_PATCH_CONFIG_HEADERS([FILE])
26982674
dnl

configure.ac

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,6 @@ PHP_CHECK_BUILTIN_CPU_INIT
499499
dnl Check __builtin_cpu_supports
500500
PHP_CHECK_BUILTIN_CPU_SUPPORTS
501501

502-
dnl Check instructions.
503-
PHP_CHECK_CPU_SUPPORTS([ssse3])
504-
PHP_CHECK_CPU_SUPPORTS([sse4.2])
505-
PHP_CHECK_CPU_SUPPORTS([avx])
506-
PHP_CHECK_CPU_SUPPORTS([avx2])
507-
508502
dnl Check for structure members.
509503
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
510504
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])

0 commit comments

Comments
 (0)