]> granicus.if.org Git - php/commitdiff
Revert "Remove configure checks for supported instruction sets"
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 4 Nov 2019 10:32:46 +0000 (11:32 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 4 Nov 2019 10:32:46 +0000 (11:32 +0100)
This reverts commit edccf32f7f36a8bc759b9482737e0c3efcb3a005.

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.

Zend/zend_portability.h
build/php.m4
configure.ac

index 3331b9ed10440c9905e40c51e26ccbef2153ece1..1e549d300be84e68636b516b0fff5f704702a7d6 100644 (file)
@@ -532,21 +532,21 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
 #endif
 
 #if (defined(__i386__) || defined(__x86_64__))
-# if defined(HAVE_TMMINTRIN_H)
-#  define PHP_HAVE_SSSE3
+# if PHP_HAVE_SSSE3_INSTRUCTIONS && defined(HAVE_TMMINTRIN_H)
+# define PHP_HAVE_SSSE3
 # endif
 
-# if defined(HAVE_NMMINTRIN_H)
-#  define PHP_HAVE_SSE4_2
+# if PHP_HAVE_SSE4_2_INSTRUCTIONS && defined(HAVE_NMMINTRIN_H)
+# define PHP_HAVE_SSE4_2
 # endif
 
 /*
  * AVX2 support was added in gcc 4.7, but AVX2 intrinsics don't work in
  * __attribute__((target("avx2"))) functions until gcc 4.9.
  */
-# if defined(HAVE_IMMINTRIN_H) && \
+# if PHP_HAVE_AVX2_INSTRUCTIONS && defined(HAVE_IMMINTRIN_H) && \
   (defined(__llvm__) || defined(__clang__) || (defined(__GNUC__) && ZEND_GCC_VERSION >= 4009))
-#  define PHP_HAVE_AVX2
+# define PHP_HAVE_AVX2
 # endif
 #endif
 
index fd37373f20f5508d78a7a7aea2de173fc039c97f..e91ef9887c7b660c32599962b1bf684076c2cbdb 100644 (file)
@@ -2674,6 +2674,30 @@ AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [
    [$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports])
 ])
 
+dnl
+dnl PHP_CHECK_CPU_SUPPORTS
+dnl
+AC_DEFUN([PHP_CHECK_CPU_SUPPORTS], [
+  AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_INIT])
+  AC_REQUIRE([PHP_CHECK_BUILTIN_CPU_SUPPORTS])
+  have_ext_instructions=0
+  if test $have_builtin_cpu_supports = 1; then
+    AC_MSG_CHECKING([for $1 instructions supports])
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
+int main() {
+       return __builtin_cpu_supports("$1")? 0 : 1;
+}
+    ]])], [
+      have_ext_instructions=1
+      AC_MSG_RESULT([yes])
+    ], [
+      AC_MSG_RESULT([no])
+    ], [AC_MSG_RESULT([no])])
+  fi
+  AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HAVE_$1_INSTRUCTIONS]),
+   [$have_ext_instructions], [Whether the compiler supports $1 instructions])
+])
+
 dnl
 dnl PHP_PATCH_CONFIG_HEADERS([FILE])
 dnl
index 39dc519a6c9240b2843e4da0da8ef1e415407145..038a3fbb9fa8d15dcb7d4a544661b3958b121fc5 100644 (file)
@@ -541,6 +541,12 @@ PHP_CHECK_BUILTIN_CPU_INIT
 dnl Check __builtin_cpu_supports
 PHP_CHECK_BUILTIN_CPU_SUPPORTS
 
+dnl Check instructions.
+PHP_CHECK_CPU_SUPPORTS([ssse3])
+PHP_CHECK_CPU_SUPPORTS([sse4.2])
+PHP_CHECK_CPU_SUPPORTS([avx])
+PHP_CHECK_CPU_SUPPORTS([avx2])
+
 dnl Check for structure members.
 AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
 AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])