Commit f64edae0 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[assembler] Add scratch register to cvtui2sd SSE instruction

Change-Id: I861babb77f224626f6cdb88a7be08db75f5cf327
Bug: v8:6666
Reviewed-on: https://chromium-review.googlesource.com/c/1283089Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56698}
parent 8060b60f
...@@ -1476,7 +1476,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1476,7 +1476,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ cvtsi2sd(i.OutputDoubleRegister(), i.InputOperand(0)); __ cvtsi2sd(i.OutputDoubleRegister(), i.InputOperand(0));
break; break;
case kSSEUint32ToFloat64: case kSSEUint32ToFloat64:
__ Cvtui2sd(i.OutputDoubleRegister(), i.InputOperand(0)); __ Cvtui2sd(i.OutputDoubleRegister(), i.InputOperand(0),
i.TempRegister(0));
break; break;
case kSSEFloat64ExtractLowWord32: case kSSEFloat64ExtractLowWord32:
if (instr->InputAt(0)->IsFPStackSlot()) { if (instr->InputAt(0)->IsFPStackSlot()) {
......
...@@ -185,7 +185,9 @@ namespace { ...@@ -185,7 +185,9 @@ namespace {
void VisitRO(InstructionSelector* selector, Node* node, ArchOpcode opcode) { void VisitRO(InstructionSelector* selector, Node* node, ArchOpcode opcode) {
IA32OperandGenerator g(selector); IA32OperandGenerator g(selector);
selector->Emit(opcode, g.DefineAsRegister(node), g.Use(node->InputAt(0))); InstructionOperand temps[] = {g.TempRegister()};
selector->Emit(opcode, g.DefineAsRegister(node), g.Use(node->InputAt(0)),
arraysize(temps), temps);
} }
......
...@@ -590,13 +590,13 @@ void TurboAssembler::Cvttss2ui(Register dst, Operand src, XMMRegister tmp) { ...@@ -590,13 +590,13 @@ void TurboAssembler::Cvttss2ui(Register dst, Operand src, XMMRegister tmp) {
bind(&done); bind(&done);
} }
void TurboAssembler::Cvtui2sd(XMMRegister dst, Operand src) { void TurboAssembler::Cvtui2sd(XMMRegister dst, Operand src, Register scratch) {
Label done; Label done;
cmp(src, Immediate(0)); cmp(src, Immediate(0));
ExternalReference uint32_bias = ExternalReference::address_of_uint32_bias(); ExternalReference uint32_bias = ExternalReference::address_of_uint32_bias();
Cvtsi2sd(dst, src); Cvtsi2sd(dst, src);
j(not_sign, &done, Label::kNear); j(not_sign, &done, Label::kNear);
addsd(dst, StaticVariable(uint32_bias)); addsd(dst, ExternalReferenceAsOperand(uint32_bias, scratch));
bind(&done); bind(&done);
} }
......
...@@ -423,8 +423,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -423,8 +423,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
Cvttss2ui(dst, Operand(src), tmp); Cvttss2ui(dst, Operand(src), tmp);
} }
void Cvttss2ui(Register dst, Operand src, XMMRegister tmp); void Cvttss2ui(Register dst, Operand src, XMMRegister tmp);
void Cvtui2sd(XMMRegister dst, Register src) { Cvtui2sd(dst, Operand(src)); } void Cvtui2sd(XMMRegister dst, Register src, Register scratch) {
void Cvtui2sd(XMMRegister dst, Operand src); Cvtui2sd(dst, Operand(src), scratch);
}
void Cvtui2sd(XMMRegister dst, Operand src, Register scratch);
void Cvttsd2ui(Register dst, XMMRegister src, XMMRegister tmp) { void Cvttsd2ui(Register dst, XMMRegister src, XMMRegister tmp) {
Cvttsd2ui(dst, Operand(src), tmp); Cvttsd2ui(dst, Operand(src), tmp);
} }
......
...@@ -1242,7 +1242,8 @@ inline void ConvertFloatToIntAndBack(LiftoffAssembler* assm, Register dst, ...@@ -1242,7 +1242,8 @@ inline void ConvertFloatToIntAndBack(LiftoffAssembler* assm, Register dst,
assm->Cvtsi2sd(converted_back, dst); assm->Cvtsi2sd(converted_back, dst);
} else { // f64 -> u32 } else { // f64 -> u32
assm->Cvttsd2ui(dst, src, liftoff::kScratchDoubleReg); assm->Cvttsd2ui(dst, src, liftoff::kScratchDoubleReg);
assm->Cvtui2sd(converted_back, dst); assm->Cvtui2sd(converted_back, dst,
assm->GetUnusedRegister(kGpReg, pinned).gp());
} }
} else { // f32 } else { // f32
if (std::is_signed<dst_type>::value) { // f32 -> i32 if (std::is_signed<dst_type>::value) { // f32 -> i32
...@@ -1349,9 +1350,12 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, ...@@ -1349,9 +1350,12 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
case kExprF64SConvertI32: case kExprF64SConvertI32:
Cvtsi2sd(dst.fp(), src.gp()); Cvtsi2sd(dst.fp(), src.gp());
return true; return true;
case kExprF64UConvertI32: case kExprF64UConvertI32: {
Cvtui2sd(dst.fp(), src.gp()); LiftoffRegList pinned = LiftoffRegList::ForRegs(dst, src);
Register scratch = GetUnusedRegister(kGpReg, pinned).gp();
Cvtui2sd(dst.fp(), src.gp(), scratch);
return true; return true;
}
case kExprF64ConvertF32: case kExprF64ConvertF32:
cvtss2sd(dst.fp(), src.fp()); cvtss2sd(dst.fp(), src.fp());
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment