test xsave before calling xgetbv.

R=agl@chromium.org, harryjin@google.com
BUG=libyuv:497

Review URL: https://codereview.chromium.org/1382803002 .
This commit is contained in:
Frank Barchard 2015-09-30 17:25:41 -07:00
parent 2cc1a2b233
commit 3eefeaeb69
3 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1496
Version: 1497
License: BSD
License File: LICENSE

View File

@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1496
#define LIBYUV_VERSION 1497
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT

View File

@ -216,9 +216,8 @@ int InitCpuFlags(void) {
kCpuHasX86;
#ifdef HAS_XGETBV
// Avoid call to xgetbv if AVX disabled for drmemory.
// TODO(fbarchard): check xsave before calling xgetbv.
if ((cpu_info1[2] & 0x18000000) == 0x18000000 && // AVX and OSSave
// AVX requires CPU has AVX, XSAVE and OSXSave for xgetbv
if ((cpu_info1[2] & 0x1c000000) == 0x1c000000 && // AVX and OSXSave
!TestEnv("LIBYUV_DISABLE_AVX") && TestOsSaveYmm()) { // Saves YMM.
cpu_info_ |= ((cpu_info7[1] & 0x00000020) ? kCpuHasAVX2 : 0) |
kCpuHasAVX;