From 2f620e18ed1640d722e23060d752ebab8d5683fb Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Wed, 3 Apr 2013 23:21:27 +0000 Subject: [PATCH] ERMS detect fix BUG=213 TEST=cpuid tool and unittest Review URL: https://webrtc-codereview.appspot.com/1201005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@639 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/cpu_id.cc | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.chromium b/README.chromium index 83cc88537..e8a06720e 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 638 +Version: 639 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index a32a9b7cb..9b349fa08 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 638 +#define LIBYUV_VERSION 639 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/cpu_id.cc b/source/cpu_id.cc index 235a04ec6..e2a0d0546 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -80,7 +80,9 @@ __declspec(naked) __declspec(align(16)) static uint32 XGetBV(unsigned int xcr) { __asm { mov ecx, [esp + 4] // xcr + push edx _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 // xgetbv for vs2005. + pop edx ret } } @@ -165,18 +167,14 @@ int InitCpuFlags(void) { ((cpu_info[2] & 0x00000200) ? kCpuHasSSSE3 : 0) | ((cpu_info[2] & 0x00080000) ? kCpuHasSSE41 : 0) | ((cpu_info[2] & 0x00100000) ? kCpuHasSSE42 : 0) | - (((cpu_info[2] & 0x18000000) == 0x18000000) ? kCpuHasAVX : 0) | kCpuHasX86; #ifdef HAS_XGETBV - if (cpu_info_ & kCpuHasAVX) { + if ((cpu_info[2] & 0x18000000) == 0x18000000 && // AVX and OSSave + (XGetBV(kXCR_XFEATURE_ENABLED_MASK) & 0x06) == 0x06) { // Save YMM __cpuid(cpu_info, 7); - if ((cpu_info[1] & 0x00000020) && - ((XGetBV(kXCR_XFEATURE_ENABLED_MASK) & 0x06) == 0x06)) { - cpu_info_ |= kCpuHasAVX2; - } - if (cpu_info[1] & 0x00000200) { - cpu_info_ |= kCpuHasERMS; - } + cpu_info_ |= ((cpu_info[1] & 0x00000020) ? kCpuHasAVX2 : 0) | + ((cpu_info[1] & 0x00000200) ? kCpuHasERMS : 0) | + kCpuHasAVX; } #endif // Environment variable overrides for testing.