Skip to content

Commit 8285624

Browse files
vpaprotskpull[bot]
authored andcommitted
8319429: Resetting MXCSR flags degrades ecore
Reviewed-by: sviswanathan, thartmann
1 parent 71b42ef commit 8285624

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

src/hotspot/cpu/x86/globals_x86.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
214214
product(bool, UseLibmIntrinsic, true, DIAGNOSTIC, \
215215
"Use Libm Intrinsics") \
216216
\
217+
/* Autodetected, see vm_version_x86.cpp */ \
218+
product(bool, EnableX86ECoreOpts, false, DIAGNOSTIC, \
219+
"Perform Ecore Optimization") \
220+
\
217221
/* Minimum array size in bytes to use AVX512 intrinsics */ \
218222
/* for copy, inflate and fill which don't bail out early based on any */ \
219223
/* condition. When this value is set to zero compare operations like */ \

src/hotspot/cpu/x86/stubGenerator_x86_32.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,8 +3965,8 @@ class StubGenerator: public StubCodeGenerator {
39653965
StubRoutines::x86::_fpu_cntrl_wrd_trunc = 0x0D7F;
39663966
// Round to nearest, 24-bit mode, exceptions masked
39673967
StubRoutines::x86::_fpu_cntrl_wrd_24 = 0x007F;
3968-
// Round to nearest, 64-bit mode, exceptions masked
3969-
StubRoutines::x86::_mxcsr_std = 0x1F80;
3968+
// Round to nearest, 64-bit mode, exceptions masked, flags specialized
3969+
StubRoutines::x86::_mxcsr_std = EnableX86ECoreOpts ? 0x1FBF : 0x1F80;
39703970
// Note: the following two constants are 80-bit values
39713971
// layout is critical for correct loading by FPU.
39723972
// Bias for strict fp multiply/divide

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,10 +3907,10 @@ address StubGenerator::generate_upcall_stub_exception_handler() {
39073907
}
39083908

39093909
void StubGenerator::create_control_words() {
3910-
// Round to nearest, 64-bit mode, exceptions masked
3911-
StubRoutines::x86::_mxcsr_std = 0x1F80;
3912-
// Round to zero, 64-bit mode, exceptions masked
3913-
StubRoutines::x86::_mxcsr_rz = 0x7F80;
3910+
// Round to nearest, 64-bit mode, exceptions masked, flags specialized
3911+
StubRoutines::x86::_mxcsr_std = EnableX86ECoreOpts ? 0x1FBF : 0x1F80;
3912+
// Round to zero, 64-bit mode, exceptions masked, flags specialized
3913+
StubRoutines::x86::_mxcsr_rz = EnableX86ECoreOpts ? 0x7FBF : 0x7F80;
39143914
}
39153915

39163916
// Initialization

src/hotspot/cpu/x86/vm_version_x86.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,12 @@ void VM_Version::get_processor_features() {
857857
}
858858
#endif
859859

860+
// Check if processor has Intel Ecore
861+
if (FLAG_IS_DEFAULT(EnableX86ECoreOpts) && is_intel() && cpu_family() == 6 &&
862+
(_model == 0x97 || _model == 0xAC || _model == 0xAF)) {
863+
FLAG_SET_DEFAULT(EnableX86ECoreOpts, true);
864+
}
865+
860866
if (UseSSE < 4) {
861867
_features &= ~CPU_SSE4_1;
862868
_features &= ~CPU_SSE4_2;

src/hotspot/cpu/x86/x86.ad

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7423,7 +7423,7 @@ instruct vround_float_avx(vec dst, vec src, rRegP tmp, vec xtmp1, vec xtmp2, vec
74237423
format %{ "vector_round_float $dst,$src\t! using $tmp, $xtmp1, $xtmp2, $xtmp3, $xtmp4 as TEMP" %}
74247424
ins_encode %{
74257425
int vlen_enc = vector_length_encoding(this);
7426-
InternalAddress new_mxcsr = $constantaddress((jint)0x3F80);
7426+
InternalAddress new_mxcsr = $constantaddress((jint)(EnableX86ECoreOpts ? 0x3FBF : 0x3F80));
74277427
__ vector_round_float_avx($dst$$XMMRegister, $src$$XMMRegister,
74287428
ExternalAddress(StubRoutines::x86::vector_float_sign_flip()), new_mxcsr, vlen_enc,
74297429
$tmp$$Register, $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, $xtmp3$$XMMRegister, $xtmp4$$XMMRegister);
@@ -7440,7 +7440,7 @@ instruct vround_float_evex(vec dst, vec src, rRegP tmp, vec xtmp1, vec xtmp2, kR
74407440
format %{ "vector_round_float $dst,$src\t! using $tmp, $xtmp1, $xtmp2, $ktmp1, $ktmp2 as TEMP" %}
74417441
ins_encode %{
74427442
int vlen_enc = vector_length_encoding(this);
7443-
InternalAddress new_mxcsr = $constantaddress((jint)0x3F80);
7443+
InternalAddress new_mxcsr = $constantaddress((jint)(EnableX86ECoreOpts ? 0x3FBF : 0x3F80));
74447444
__ vector_round_float_evex($dst$$XMMRegister, $src$$XMMRegister,
74457445
ExternalAddress(StubRoutines::x86::vector_float_sign_flip()), new_mxcsr, vlen_enc,
74467446
$tmp$$Register, $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, $ktmp1$$KRegister, $ktmp2$$KRegister);
@@ -7455,7 +7455,7 @@ instruct vround_reg_evex(vec dst, vec src, rRegP tmp, vec xtmp1, vec xtmp2, kReg
74557455
format %{ "vector_round_long $dst,$src\t! using $tmp, $xtmp1, $xtmp2, $ktmp1, $ktmp2 as TEMP" %}
74567456
ins_encode %{
74577457
int vlen_enc = vector_length_encoding(this);
7458-
InternalAddress new_mxcsr = $constantaddress((jint)0x3F80);
7458+
InternalAddress new_mxcsr = $constantaddress((jint)(EnableX86ECoreOpts ? 0x3FBF : 0x3F80));
74597459
__ vector_round_double_evex($dst$$XMMRegister, $src$$XMMRegister,
74607460
ExternalAddress(StubRoutines::x86::vector_double_sign_flip()), new_mxcsr, vlen_enc,
74617461
$tmp$$Register, $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, $ktmp1$$KRegister, $ktmp2$$KRegister);

0 commit comments

Comments
 (0)