changeset 12326:92d1285e6bcb

8170039: Change UseAVX < 3 on SKX/KNL to not emit evex vector check Reviewed-by: kvn
author mcberg
date Tue, 22 Nov 2016 11:34:11 -0800
parents 1b7fd4c2f65e
children 873014e6ff3d
files src/cpu/x86/vm/vm_version_x86.cpp
diffstat 1 files changed, 49 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/vm_version_x86.cpp	Tue Nov 22 16:13:13 2016 +0300
+++ b/src/cpu/x86/vm/vm_version_x86.cpp	Tue Nov 22 11:34:11 2016 -0800
@@ -65,6 +65,7 @@
     const int      CPU_FAMILY_SHIFT = 8;
     const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT);
     const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT);
+    bool use_evex = FLAG_IS_DEFAULT(UseAVX) || (UseAVX > 2);
 
     Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4;
     Label sef_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7, done, wrapup;
@@ -358,36 +359,39 @@
     __ cmpl(rax, 0xE0);
     __ jccb(Assembler::notEqual, legacy_setup); // jump if EVEX is not supported
 
-    // EVEX setup: run in lowest evex mode
-    VM_Version::set_evex_cpuFeatures(); // Enable temporary to pass asserts
-    UseAVX = 3;
-    UseSSE = 2;
+    // If UseAVX is unitialized or is set by the user to include EVEX
+    if (use_evex) {
+      // EVEX setup: run in lowest evex mode
+      VM_Version::set_evex_cpuFeatures(); // Enable temporary to pass asserts
+      UseAVX = 3;
+      UseSSE = 2;
 #ifdef _WINDOWS
-    // xmm5-xmm15 are not preserved by caller on windows
-    // https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx
-    __ subptr(rsp, 64);
-    __ evmovdqul(Address(rsp, 0), xmm7, Assembler::AVX_512bit);
+      // xmm5-xmm15 are not preserved by caller on windows
+      // https://msdn.microsoft.com/en-us/library/9z1stfyw.aspx
+      __ subptr(rsp, 64);
+      __ evmovdqul(Address(rsp, 0), xmm7, Assembler::AVX_512bit);
 #ifdef _LP64
-    __ subptr(rsp, 64);
-    __ evmovdqul(Address(rsp, 0), xmm8, Assembler::AVX_512bit);
-    __ subptr(rsp, 64);
-    __ evmovdqul(Address(rsp, 0), xmm31, Assembler::AVX_512bit);
+      __ subptr(rsp, 64);
+      __ evmovdqul(Address(rsp, 0), xmm8, Assembler::AVX_512bit);
+      __ subptr(rsp, 64);
+      __ evmovdqul(Address(rsp, 0), xmm31, Assembler::AVX_512bit);
 #endif // _LP64
 #endif // _WINDOWS
 
-    // load value into all 64 bytes of zmm7 register
-    __ movl(rcx, VM_Version::ymm_test_value());
-    __ movdl(xmm0, rcx);
-    __ movl(rcx, 0xffff);
-    __ kmovwl(k1, rcx);
-    __ evpbroadcastd(xmm0, xmm0, Assembler::AVX_512bit);
-    __ evmovdqul(xmm7, xmm0, Assembler::AVX_512bit);
+      // load value into all 64 bytes of zmm7 register
+      __ movl(rcx, VM_Version::ymm_test_value());
+      __ movdl(xmm0, rcx);
+      __ movl(rcx, 0xffff);
+      __ kmovwl(k1, rcx);
+      __ evpbroadcastd(xmm0, xmm0, Assembler::AVX_512bit);
+      __ evmovdqul(xmm7, xmm0, Assembler::AVX_512bit);
 #ifdef _LP64
-    __ evmovdqul(xmm8, xmm0, Assembler::AVX_512bit);
-    __ evmovdqul(xmm31, xmm0, Assembler::AVX_512bit);
+      __ evmovdqul(xmm8, xmm0, Assembler::AVX_512bit);
+      __ evmovdqul(xmm31, xmm0, Assembler::AVX_512bit);
 #endif
-    VM_Version::clean_cpuFeatures();
-    __ jmp(save_restore_except);
+      VM_Version::clean_cpuFeatures();
+      __ jmp(save_restore_except);
+    }
 
     __ bind(legacy_setup);
     // AVX setup
@@ -441,32 +445,35 @@
     __ cmpl(rax, 0xE0);
     __ jccb(Assembler::notEqual, legacy_save_restore);
 
-    // EVEX check: run in lowest evex mode
-    VM_Version::set_evex_cpuFeatures(); // Enable temporary to pass asserts
-    UseAVX = 3;
-    UseSSE = 2;
-    __ lea(rsi, Address(rbp, in_bytes(VM_Version::zmm_save_offset())));
-    __ evmovdqul(Address(rsi, 0), xmm0, Assembler::AVX_512bit);
-    __ evmovdqul(Address(rsi, 64), xmm7, Assembler::AVX_512bit);
+    // If UseAVX is unitialized or is set by the user to include EVEX
+    if (use_evex) {
+      // EVEX check: run in lowest evex mode
+      VM_Version::set_evex_cpuFeatures(); // Enable temporary to pass asserts
+      UseAVX = 3;
+      UseSSE = 2;
+      __ lea(rsi, Address(rbp, in_bytes(VM_Version::zmm_save_offset())));
+      __ evmovdqul(Address(rsi, 0), xmm0, Assembler::AVX_512bit);
+      __ evmovdqul(Address(rsi, 64), xmm7, Assembler::AVX_512bit);
 #ifdef _LP64
-    __ evmovdqul(Address(rsi, 128), xmm8, Assembler::AVX_512bit);
-    __ evmovdqul(Address(rsi, 192), xmm31, Assembler::AVX_512bit);
+      __ evmovdqul(Address(rsi, 128), xmm8, Assembler::AVX_512bit);
+      __ evmovdqul(Address(rsi, 192), xmm31, Assembler::AVX_512bit);
 #endif
 
 #ifdef _WINDOWS
 #ifdef _LP64
-    __ evmovdqul(xmm31, Address(rsp, 0), Assembler::AVX_512bit);
-    __ addptr(rsp, 64);
-    __ evmovdqul(xmm8, Address(rsp, 0), Assembler::AVX_512bit);
-    __ addptr(rsp, 64);
+      __ evmovdqul(xmm31, Address(rsp, 0), Assembler::AVX_512bit);
+      __ addptr(rsp, 64);
+      __ evmovdqul(xmm8, Address(rsp, 0), Assembler::AVX_512bit);
+      __ addptr(rsp, 64);
 #endif // _LP64
-    __ evmovdqul(xmm7, Address(rsp, 0), Assembler::AVX_512bit);
-    __ addptr(rsp, 64);
+      __ evmovdqul(xmm7, Address(rsp, 0), Assembler::AVX_512bit);
+      __ addptr(rsp, 64);
 #endif // _WINDOWS
-    VM_Version::clean_cpuFeatures();
-    UseAVX = saved_useavx;
-    UseSSE = saved_usesse;
-    __ jmp(wrapup);
+      VM_Version::clean_cpuFeatures();
+      UseAVX = saved_useavx;
+      UseSSE = saved_usesse;
+      __ jmp(wrapup);
+    }
 
     __ bind(legacy_save_restore);
     // AVX check