8f02ad408e
- Add the appropriate cpuid checks to detect AVX2 in base/cpu - Add FLAG_enable_avx2 AVX2 depends on AVX support, + a cpuid check with eax=7. This is similar to chromium/src/base/cpu.cc check for AVX2. Bug: v8:11258 Change-Id: Ia547c22e51b03fec823f5e48ebb055139632c942 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2589050 Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org> Commit-Queue: Zhi An Ng <zhin@chromium.org> Cr-Commit-Position: refs/heads/master@{#71821}
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "src/base/cpu.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace v8 {
|
|
namespace base {
|
|
|
|
TEST(CPUTest, FeatureImplications) {
|
|
CPU cpu;
|
|
|
|
// ia32 and x64 features
|
|
EXPECT_TRUE(!cpu.has_sse() || cpu.has_mmx());
|
|
EXPECT_TRUE(!cpu.has_sse2() || cpu.has_sse());
|
|
EXPECT_TRUE(!cpu.has_sse3() || cpu.has_sse2());
|
|
EXPECT_TRUE(!cpu.has_ssse3() || cpu.has_sse3());
|
|
EXPECT_TRUE(!cpu.has_sse41() || cpu.has_sse3());
|
|
EXPECT_TRUE(!cpu.has_sse42() || cpu.has_sse41());
|
|
EXPECT_TRUE(!cpu.has_avx() || cpu.has_sse2());
|
|
EXPECT_TRUE(!cpu.has_fma3() || cpu.has_avx());
|
|
EXPECT_TRUE(!cpu.has_avx2() || cpu.has_avx());
|
|
|
|
// arm features
|
|
EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3());
|
|
}
|
|
|
|
|
|
TEST(CPUTest, RequiredFeatures) {
|
|
CPU cpu;
|
|
|
|
#if V8_HOST_ARCH_ARM
|
|
EXPECT_TRUE(cpu.has_fpu());
|
|
#endif
|
|
|
|
#if V8_HOST_ARCH_IA32
|
|
EXPECT_TRUE(cpu.has_fpu());
|
|
EXPECT_TRUE(cpu.has_sahf());
|
|
#endif
|
|
|
|
#if V8_HOST_ARCH_X64
|
|
EXPECT_TRUE(cpu.has_fpu());
|
|
EXPECT_TRUE(cpu.has_cmov());
|
|
EXPECT_TRUE(cpu.has_mmx());
|
|
EXPECT_TRUE(cpu.has_sse());
|
|
EXPECT_TRUE(cpu.has_sse2());
|
|
#endif
|
|
}
|
|
|
|
} // namespace base
|
|
} // namespace v8
|