Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: base/cpu_unittest.cc

Issue 1385093002: Enable CPU.RunExtendedInstructions test for win64 with clangcl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/cpu.h" 5 #include "base/cpu.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #if _MSC_VER >= 1700 10 #if _MSC_VER >= 1700
11 // C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX. 11 // C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX.
12 #pragma warning(disable: 4752) 12 #pragma warning(disable: 4752)
13 #endif 13 #endif
14 14
15 // Tests whether we can run extended instructions represented by the CPU 15 // Tests whether we can run extended instructions represented by the CPU
16 // information. This test actually executes some extended instructions (such as 16 // information. This test actually executes some extended instructions (such as
17 // MMX, SSE, etc.) supported by the CPU and sees we can run them without 17 // MMX, SSE, etc.) supported by the CPU and sees we can run them without
18 // "undefined instruction" exceptions. That is, this test succeeds when this 18 // "undefined instruction" exceptions. That is, this test succeeds when this
19 // test finishes without a crash. 19 // test finishes without a crash.
20 TEST(CPU, RunExtendedInstructions) { 20 TEST(CPU, RunExtendedInstructions) {
21 #if defined(ARCH_CPU_X86_FAMILY) 21 #if defined(ARCH_CPU_X86_FAMILY)
22 // Retrieve the CPU information. 22 // Retrieve the CPU information.
23 base::CPU cpu; 23 base::CPU cpu;
24 24
25 ASSERT_TRUE(cpu.has_mmx()); 25 ASSERT_TRUE(cpu.has_mmx());
26 ASSERT_TRUE(cpu.has_sse()); 26 ASSERT_TRUE(cpu.has_sse());
27 ASSERT_TRUE(cpu.has_sse2()); 27 ASSERT_TRUE(cpu.has_sse2());
28 28
29 // TODO(fbarchard): consider enabling for clangcl. 29 // GCC and clang instruction test.
30 #if defined(COMPILER_GCC) 30 #if defined(COMPILER_GCC)
31 // Execute an MMX instruction. 31 // Execute an MMX instruction.
32 __asm__ __volatile__("emms\n" : : : "mm0"); 32 __asm__ __volatile__("emms\n" : : : "mm0");
33 33
34 // Execute an SSE instruction. 34 // Execute an SSE instruction.
35 __asm__ __volatile__("xorps %%xmm0, %%xmm0\n" : : : "xmm0"); 35 __asm__ __volatile__("xorps %%xmm0, %%xmm0\n" : : : "xmm0");
36 36
37 // Execute an SSE 2 instruction. 37 // Execute an SSE 2 instruction.
38 __asm__ __volatile__("psrldq $0, %%xmm0\n" : : : "xmm0"); 38 __asm__ __volatile__("psrldq $0, %%xmm0\n" : : : "xmm0");
39 39
(...skipping 20 matching lines...) Expand all
60 if (cpu.has_avx()) { 60 if (cpu.has_avx()) {
61 // Execute an AVX instruction. 61 // Execute an AVX instruction.
62 __asm__ __volatile__("vzeroupper\n" : : : "xmm0"); 62 __asm__ __volatile__("vzeroupper\n" : : : "xmm0");
63 } 63 }
64 64
65 if (cpu.has_avx2()) { 65 if (cpu.has_avx2()) {
66 // Execute an AVX 2 instruction. 66 // Execute an AVX 2 instruction.
67 __asm__ __volatile__("vpunpcklbw %%ymm0, %%ymm0, %%ymm0\n" : : : "xmm0"); 67 __asm__ __volatile__("vpunpcklbw %%ymm0, %%ymm0, %%ymm0\n" : : : "xmm0");
68 } 68 }
69 69
70 // TODO(jschuh): crbug.com/168866 Find a way to enable this on Win64. 70 // Visual C 32 bit and ClangCL 32/64 bit test.
71 #elif defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS) 71 #elif defined(COMPILER_MSVC) && (defined(ARCH_CPU_32_BITS) || \
72 (defined(ARCH_CPU_64_BITS) && defined(__clang__)))
72 73
73 // Execute an MMX instruction. 74 // Execute an MMX instruction.
74 __asm emms; 75 __asm emms;
75 76
76 // Execute an SSE instruction. 77 // Execute an SSE instruction.
77 __asm xorps xmm0, xmm0; 78 __asm xorps xmm0, xmm0;
78 79
79 // Execute an SSE 2 instruction. 80 // Execute an SSE 2 instruction.
80 __asm psrldq xmm0, 0; 81 __asm psrldq xmm0, 0;
81 82
(...skipping 25 matching lines...) Expand all
107 } 108 }
108 109
109 if (cpu.has_avx2()) { 110 if (cpu.has_avx2()) {
110 // Execute an AVX 2 instruction. 111 // Execute an AVX 2 instruction.
111 __asm vpunpcklbw ymm0, ymm0, ymm0 112 __asm vpunpcklbw ymm0, ymm0, ymm0
112 } 113 }
113 #endif // _MSC_VER >= 1700 114 #endif // _MSC_VER >= 1700
114 #endif // defined(COMPILER_GCC) 115 #endif // defined(COMPILER_GCC)
115 #endif // defined(ARCH_CPU_X86_FAMILY) 116 #endif // defined(ARCH_CPU_X86_FAMILY)
116 } 117 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698