Bug 880419: disable AVX2 asm if the compiler/assembler don't support it r=glandium
☠☠ backed out by 425f6246b622 ☠ ☠
authorRandell Jesup <rjesup@jesup.org>
Thu, 30 Jan 2014 19:55:09 -0500
changeset 182168 57d558b5d3dfa289fccdac7b295d24cf0a8c2e5e
parent 182167 be17fb052374387c6a27d797180e2517f112cf9a
child 182169 604818812338693e46868c0d1a098eb2e9bd3ffa
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs880419
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 880419: disable AVX2 asm if the compiler/assembler don't support it r=glandium
build/gyp.mozbuild
configure.in
media/libyuv/include/libyuv/row.h
media/libyuv/libyuv.gyp
--- a/build/gyp.mozbuild
+++ b/build/gyp.mozbuild
@@ -19,16 +19,17 @@ gyp_vars = {
     'enable_android_opensl': 1,
     # use_system_lib* still seems to be in use in trunk/build
     'use_system_libjpeg': 0,
     'use_system_libvpx': 0,
     'build_libjpeg': 0,
     'build_libvpx': 0,
     'build_libyuv': 0,
     'libyuv_dir': '/media/libyuv',
+    'yuv_disable_avx2': 0 if CONFIG['HAVE_X86_AVX2'] else 1,
 
     # saves 4MB when webrtc_trace is off
     'enable_lazy_trace_alloc': 1,
 
      # turn off mandatory use of NEON and instead use NEON detection
     'arm_neon': 0,
 
     'moz_widget_toolkit_gonk': 0,
--- a/configure.in
+++ b/configure.in
@@ -1346,16 +1346,30 @@ if test "$GNU_CC"; then
     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
     _SAVE_CFLAGS=$CFLAGS
     CFLAGS="$CFLAGS -msse4.1"
     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
                      AC_MSG_RESULT([no]))
     CFLAGS=$_SAVE_CFLAGS
 
+    case "${CPU_ARCH}" in
+    x86 | x86_64)
+      AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
+      AC_TRY_COMPILE([],
+                     [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
+                     result="yes", result="no")
+      AC_MSG_RESULT("$result")
+      if test "$result" = "yes"; then
+          HAVE_X86_AVX2=1
+          AC_DEFINE(HAVE_X86_AVX2)
+          AC_SUBST(HAVE_X86_AVX2)
+      fi
+    esac
+
     # Turn on GNU-specific warnings:
     # -Wall - turn on a lot of warnings
     # -Wpointer-arith - good to have
     # -Wdeclaration-after-statement - MSVC doesn't like these
     # -Werror=return-type - catches missing returns, zero false positives
     # -Werror=int-to-pointer-cast - catches cast to pointer from integer of different size
     # -Wtype-limits - catches overflow bugs, few false positives
     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
--- a/media/libyuv/include/libyuv/row.h
+++ b/media/libyuv/include/libyuv/row.h
@@ -169,18 +169,18 @@ extern "C" {
 // Visual C 2012 required for AVX2.
 #if defined(_M_IX86) && defined(_MSC_VER) && _MSC_VER >= 1700
 #define VISUALC_HAS_AVX2 1
 #endif  // VisualStudio >= 2012
 
 // The following are available on all x86 platforms, but
 // require VS2012, clang 3.4 or gcc 4.7.
 // The code supports NaCL but requires a new compiler and validator.
-#if !defined(LIBYUV_DISABLE_X86) && (defined(VISUALC_HAS_AVX2) || \
-    defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2))
+#if !defined(LIBYUV_DISABLE_AVX2) && !defined(LIBYUV_DISABLE_X86) &&    \
+    (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2))
 // Effects:
 #define HAS_ARGBPOLYNOMIALROW_AVX2
 #define HAS_ARGBSHUFFLEROW_AVX2
 #define HAS_ARGBCOPYALPHAROW_AVX2
 #define HAS_ARGBCOPYYTOALPHAROW_AVX2
 #endif
 
 // The following are require VS2012.
--- a/media/libyuv/libyuv.gyp
+++ b/media/libyuv/libyuv.gyp
@@ -8,16 +8,17 @@
 
 {
   'includes': [
     'libyuv.gypi',
   ],
   'variables': {
     'use_system_libjpeg%': 0,
     'yuv_disable_asm%': 0,
+    'yuv_disable_avx2%': 0,
     'build_neon': 0,
     'conditions': [
        ['target_arch == "arm" and arm_version >= 7 and (arm_neon == 1 or arm_neon_optional == 1)', {
          'build_neon': 1,
        }],
     ],
   },
   'conditions': [
@@ -106,32 +107,39 @@
         [ 'yuv_disable_asm!=0', {
           'defines': [
             # Enable the following 3 macros to turn off assembly for specified CPU.
             'LIBYUV_DISABLE_X86',
             'LIBYUV_DISABLE_NEON',
             'LIBYUV_DISABLE_MIPS',
           ],
         }],
+        [ 'yuv_disable_avx2==1', {
+          'defines': [
+            'LIBYUV_DISABLE_AVX2',
+          ]
+        }],
         ['build_with_mozilla==1', {
           'include_dirs': [
             '$(DEPTH)/dist/include',
           ],
           'direct_dependent_settings': {
             'include_dirs': [
               '$(DEPTH)/dist/include',
             ],
           },
         }],
       ],
       'defines': [
         # Enable the following 3 macros to turn off assembly for specified CPU.
         # 'LIBYUV_DISABLE_X86',
         # 'LIBYUV_DISABLE_NEON',
         # 'LIBYUV_DISABLE_MIPS',
+        # This disables AVX2 (Haswell) support, overriding compiler checks
+        # 'LIBYUV_DISABLE_AVX2',
         # Enable the following macro to build libyuv as a shared library (dll).
         # 'LIBYUV_USING_SHARED_LIBRARY',
       ],
       'include_dirs': [
         'include',
         '.',
       ],
       'direct_dependent_settings': {