diff --git a/runtime/tests/vm/dart/double_hash_code_double_values_test.dart b/runtime/tests/vm/dart/double_hash_code_double_values_test.dart index ce9041bbb0d1..d095a4868c4a 100644 --- a/runtime/tests/vm/dart/double_hash_code_double_values_test.dart +++ b/runtime/tests/vm/dart/double_hash_code_double_values_test.dart @@ -4,6 +4,9 @@ // // This complements corelib/double_hash_code_test.dart and verifies hash code // values of doubles that are not representable as integers. +// +// VMOptions=--use_sse41 +// VMOptions=--no_use_sse41 import 'package:expect/expect.dart'; diff --git a/runtime/tests/vm/dart_2/double_hash_code_double_values_test.dart b/runtime/tests/vm/dart_2/double_hash_code_double_values_test.dart index 4d4e10fa1e7a..d3d0f30d2d05 100644 --- a/runtime/tests/vm/dart_2/double_hash_code_double_values_test.dart +++ b/runtime/tests/vm/dart_2/double_hash_code_double_values_test.dart @@ -6,6 +6,9 @@ // // This complements corelib/double_hash_code_test.dart and verifies hash code // values of doubles that are not representable as integers. +// +// VMOptions=--use_sse41 +// VMOptions=--no_use_sse41 import 'package:expect/expect.dart'; diff --git a/runtime/vm/compiler/backend/il_ia32.cc b/runtime/vm/compiler/backend/il_ia32.cc index 536c2e6c31d4..ca406359e12d 100644 --- a/runtime/vm/compiler/backend/il_ia32.cc +++ b/runtime/vm/compiler/backend/il_ia32.cc @@ -5097,7 +5097,14 @@ void HashDoubleOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { compiler::Label hash_double, try_convert; // extract high 32-bits out of double value. - __ pextrd(temp, value, compiler::Immediate(1)); + if (TargetCPUFeatures::sse4_1_supported()) { + __ pextrd(temp, value, compiler::Immediate(1)); + } else { + __ SubImmediate(ESP, compiler::Immediate(kDoubleSize)); + __ movsd(compiler::Address(ESP, 0), value); + __ movl(temp, compiler::Address(ESP, kWordSize)); + __ AddImmediate(ESP, compiler::Immediate(kDoubleSize)); + } __ andl(temp, compiler::Immediate(0x7FF00000)); __ cmpl(temp, compiler::Immediate(0x7FF00000)); __ j(EQUAL, &hash_double); // is infinity or nan @@ -5148,8 +5155,16 @@ void HashDoubleOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ jmp(&hash_integer); __ Bind(&hash_double); - __ pextrd(EAX, value, compiler::Immediate(0)); - __ pextrd(temp, value, compiler::Immediate(1)); + if (TargetCPUFeatures::sse4_1_supported()) { + __ pextrd(EAX, value, compiler::Immediate(0)); + __ pextrd(temp, value, compiler::Immediate(1)); + } else { + __ SubImmediate(ESP, compiler::Immediate(kDoubleSize)); + __ movsd(compiler::Address(ESP, 0), value); + __ movl(EAX, compiler::Address(ESP, 0)); + __ movl(temp, compiler::Address(ESP, kWordSize)); + __ AddImmediate(ESP, compiler::Immediate(kDoubleSize)); + } __ xorl(EAX, temp); __ andl(EAX, compiler::Immediate(compiler::target::kSmiMax)); diff --git a/tests/corelib/double_hash_code_test.dart b/tests/corelib/double_hash_code_test.dart index 30f37da5efc8..72fbb6ed7d29 100644 --- a/tests/corelib/double_hash_code_test.dart +++ b/tests/corelib/double_hash_code_test.dart @@ -2,8 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// VMOptions=--intrinsify -// VMOptions=--no_intrinsify +// VMOptions=--intrinsify --use_sse41 +// VMOptions=--no_intrinsify --use_sse41 +// VMOptions=--intrinsify --no_use_sse41 +// VMOptions=--no_intrinsify --no_use_sse41 import 'package:expect/expect.dart'; diff --git a/tests/corelib_2/double_hash_code_test.dart b/tests/corelib_2/double_hash_code_test.dart index 80b5b5d4c8e3..b85b8f7548f0 100644 --- a/tests/corelib_2/double_hash_code_test.dart +++ b/tests/corelib_2/double_hash_code_test.dart @@ -4,8 +4,10 @@ // @dart = 2.9 -// VMOptions=--intrinsify -// VMOptions=--no_intrinsify +// VMOptions=--intrinsify --use_sse41 +// VMOptions=--no_intrinsify --use_sse41 +// VMOptions=--intrinsify --no_use_sse41 +// VMOptions=--no_intrinsify --no_use_sse41 import 'package:expect/expect.dart';