diff --git a/src/compiler/backend/x64/code-generator-x64.cc b/src/compiler/backend/x64/code-generator-x64.cc index b3cd722568..3ddac1721f 100644 --- a/src/compiler/backend/x64/code-generator-x64.cc +++ b/src/compiler/backend/x64/code-generator-x64.cc @@ -1339,16 +1339,18 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( break; case kSSEFloat32Abs: { // TODO(bmeurer): Use RIP relative 128-bit constants. - __ Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); - __ Psrlq(kScratchDoubleReg, 33); - __ Andps(i.OutputDoubleRegister(), kScratchDoubleReg); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ Pcmpeqd(tmp, tmp); + __ Psrlq(tmp, 33); + __ Andps(i.OutputDoubleRegister(), tmp); break; } case kSSEFloat32Neg: { // TODO(bmeurer): Use RIP relative 128-bit constants. - __ Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); - __ Psllq(kScratchDoubleReg, 31); - __ Xorps(i.OutputDoubleRegister(), kScratchDoubleReg); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ Pcmpeqd(tmp, tmp); + __ Psllq(tmp, 31); + __ Xorps(i.OutputDoubleRegister(), tmp); break; } case kSSEFloat32Sqrt: @@ -1550,17 +1552,19 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( case kX64F64x2Abs: case kSSEFloat64Abs: { // TODO(bmeurer): Use RIP relative 128-bit constants. - __ Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); - __ Psrlq(kScratchDoubleReg, 1); - __ Andpd(i.OutputDoubleRegister(), kScratchDoubleReg); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ Pcmpeqd(tmp, tmp); + __ Psrlq(tmp, 1); + __ Andpd(i.OutputDoubleRegister(), tmp); break; } case kX64F64x2Neg: case kSSEFloat64Neg: { // TODO(bmeurer): Use RIP relative 128-bit constants. - __ Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); - __ Psllq(kScratchDoubleReg, 63); - __ Xorpd(i.OutputDoubleRegister(), kScratchDoubleReg); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ Pcmpeqd(tmp, tmp); + __ Psllq(tmp, 63); + __ Xorpd(i.OutputDoubleRegister(), tmp); break; } case kSSEFloat64Sqrt: @@ -1818,56 +1822,52 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( case kAVXFloat32Abs: { // TODO(bmeurer): Use RIP relative 128-bit constants. CpuFeatureScope avx_scope(tasm(), AVX); - __ vpcmpeqd(kScratchDoubleReg, kScratchDoubleReg, kScratchDoubleReg); - __ vpsrlq(kScratchDoubleReg, kScratchDoubleReg, 33); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ vpcmpeqd(tmp, tmp, tmp); + __ vpsrlq(tmp, tmp, 33); if (instr->InputAt(0)->IsFPRegister()) { - __ vandps(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputDoubleRegister(0)); + __ vandps(i.OutputDoubleRegister(), tmp, i.InputDoubleRegister(0)); } else { - __ vandps(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputOperand(0)); + __ vandps(i.OutputDoubleRegister(), tmp, i.InputOperand(0)); } break; } case kAVXFloat32Neg: { // TODO(bmeurer): Use RIP relative 128-bit constants. CpuFeatureScope avx_scope(tasm(), AVX); - __ vpcmpeqd(kScratchDoubleReg, kScratchDoubleReg, kScratchDoubleReg); - __ vpsllq(kScratchDoubleReg, kScratchDoubleReg, 31); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ vpcmpeqd(tmp, tmp, tmp); + __ vpsllq(tmp, tmp, 31); if (instr->InputAt(0)->IsFPRegister()) { - __ vxorps(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputDoubleRegister(0)); + __ vxorps(i.OutputDoubleRegister(), tmp, i.InputDoubleRegister(0)); } else { - __ vxorps(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputOperand(0)); + __ vxorps(i.OutputDoubleRegister(), tmp, i.InputOperand(0)); } break; } case kAVXFloat64Abs: { // TODO(bmeurer): Use RIP relative 128-bit constants. CpuFeatureScope avx_scope(tasm(), AVX); - __ vpcmpeqd(kScratchDoubleReg, kScratchDoubleReg, kScratchDoubleReg); - __ vpsrlq(kScratchDoubleReg, kScratchDoubleReg, 1); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ vpcmpeqd(tmp, tmp, tmp); + __ vpsrlq(tmp, tmp, 1); if (instr->InputAt(0)->IsFPRegister()) { - __ vandpd(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputDoubleRegister(0)); + __ vandpd(i.OutputDoubleRegister(), tmp, i.InputDoubleRegister(0)); } else { - __ vandpd(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputOperand(0)); + __ vandpd(i.OutputDoubleRegister(), tmp, i.InputOperand(0)); } break; } case kAVXFloat64Neg: { // TODO(bmeurer): Use RIP relative 128-bit constants. CpuFeatureScope avx_scope(tasm(), AVX); - __ vpcmpeqd(kScratchDoubleReg, kScratchDoubleReg, kScratchDoubleReg); - __ vpsllq(kScratchDoubleReg, kScratchDoubleReg, 63); + XMMRegister tmp = i.ToDoubleRegister(instr->TempAt(0)); + __ vpcmpeqd(tmp, tmp, tmp); + __ vpsllq(tmp, tmp, 63); if (instr->InputAt(0)->IsFPRegister()) { - __ vxorpd(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputDoubleRegister(0)); + __ vxorpd(i.OutputDoubleRegister(), tmp, i.InputDoubleRegister(0)); } else { - __ vxorpd(i.OutputDoubleRegister(), kScratchDoubleReg, - i.InputOperand(0)); + __ vxorpd(i.OutputDoubleRegister(), tmp, i.InputOperand(0)); } break; } diff --git a/src/compiler/backend/x64/instruction-selector-x64.cc b/src/compiler/backend/x64/instruction-selector-x64.cc index 01315e4140..a4e5916708 100644 --- a/src/compiler/backend/x64/instruction-selector-x64.cc +++ b/src/compiler/backend/x64/instruction-selector-x64.cc @@ -1369,10 +1369,13 @@ void VisitFloatBinop(InstructionSelector* selector, Node* node, void VisitFloatUnop(InstructionSelector* selector, Node* node, Node* input, ArchOpcode avx_opcode, ArchOpcode sse_opcode) { X64OperandGenerator g(selector); + InstructionOperand temps[] = {g.TempDoubleRegister()}; if (selector->IsSupported(AVX)) { - selector->Emit(avx_opcode, g.DefineAsRegister(node), g.Use(input)); + selector->Emit(avx_opcode, g.DefineAsRegister(node), g.UseUnique(input), + arraysize(temps), temps); } else { - selector->Emit(sse_opcode, g.DefineSameAsFirst(node), g.UseRegister(input)); + selector->Emit(sse_opcode, g.DefineSameAsFirst(node), g.UseRegister(input), + arraysize(temps), temps); } } @@ -2850,14 +2853,16 @@ void InstructionSelector::VisitS128Select(Node* node) { void InstructionSelector::VisitF64x2Abs(Node* node) { X64OperandGenerator g(this); - Emit(kX64F64x2Abs, g.DefineSameAsFirst(node), - g.UseRegister(node->InputAt(0))); + InstructionOperand temps[] = {g.TempDoubleRegister()}; + Emit(kX64F64x2Abs, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), + arraysize(temps), temps); } void InstructionSelector::VisitF64x2Neg(Node* node) { X64OperandGenerator g(this); - Emit(kX64F64x2Neg, g.DefineSameAsFirst(node), - g.UseRegister(node->InputAt(0))); + InstructionOperand temps[] = {g.TempDoubleRegister()}; + Emit(kX64F64x2Neg, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), + arraysize(temps), temps); } void InstructionSelector::VisitF32x4UConvertI32x4(Node* node) {