Bug 880419: disable AVX2 asm if the compiler/assembler don't support it r=glandium
authorRandell Jesup <rjesup@jesup.org>
Thu, 30 Jan 2014 19:55:09 -0500
changeset 166825 326a283714a8330ac1749c8cacafe857f1da2e02
parent 166824 0930352a2b0e04285d5d876566ce34e419152e74
child 166826 2c84be83868929432b43b59eda7d5c56a5b7764c
push id39295
push userrjesup@wgate.com
push dateTue, 04 Feb 2014 21:09:53 +0000
treeherdermozilla-inbound@326a283714a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs880419
milestone30.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,
     'arm_neon_optional': 1,
 
--- 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': [
@@ -115,32 +116,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': {