Skip to content

Commit

Permalink
[vm/sse41] Fix use of pextrd when sse41 is not available.
Browse files Browse the repository at this point in the history
BUG=#50640
TEST=ci

Change-Id: Ief12c270cb59dace99e3a2845cb44ed5085dbdaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274081
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
  • Loading branch information
aam authored and Commit Queue committed Dec 8, 2022
1 parent e382426 commit fb22336
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
21 changes: 18 additions & 3 deletions runtime/vm/compiler/backend/il_ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));

Expand Down
6 changes: 4 additions & 2 deletions tests/corelib/double_hash_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
6 changes: 4 additions & 2 deletions tests/corelib_2/double_hash_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit fb22336

Please sign in to comment.