Index: src/compiler/ia32/instruction-selector-ia32.cc |
diff --git a/src/compiler/ia32/instruction-selector-ia32.cc b/src/compiler/ia32/instruction-selector-ia32.cc |
index 93644a90be0b2f959bb39716ea92bb5c22430b1b..1eadc024f5c10817f939c669b024e0347a92b5e7 100644 |
--- a/src/compiler/ia32/instruction-selector-ia32.cc |
+++ b/src/compiler/ia32/instruction-selector-ia32.cc |
@@ -153,6 +153,18 @@ void VisitRROFloat(InstructionSelector* selector, Node* node, |
} |
} |
+ |
+void VisitFloatUnop(InstructionSelector* selector, Node* node, Node* input, |
+ ArchOpcode avx_opcode, ArchOpcode sse_opcode) { |
+ IA32OperandGenerator g(selector); |
+ if (selector->IsSupported(AVX)) { |
+ selector->Emit(avx_opcode, g.DefineAsRegister(node), g.Use(input)); |
+ } else { |
+ selector->Emit(sse_opcode, g.DefineSameAsFirst(node), g.UseRegister(input)); |
+ } |
+} |
+ |
+ |
} // namespace |
@@ -684,8 +696,8 @@ void InstructionSelector::VisitFloat32Sub(Node* node) { |
IA32OperandGenerator g(this); |
Float32BinopMatcher m(node); |
if (m.left().IsMinusZero()) { |
- Emit(kSSEFloat32Neg, g.DefineSameAsFirst(node), |
- g.UseRegister(m.right().node())); |
+ VisitFloatUnop(this, node, m.right().node(), kAVXFloat32Neg, |
+ kSSEFloat32Neg); |
return; |
} |
VisitRROFloat(this, node, kAVXFloat32Sub, kSSEFloat32Sub); |
@@ -708,8 +720,8 @@ void InstructionSelector::VisitFloat64Sub(Node* node) { |
} |
} |
} |
- Emit(kSSEFloat64Neg, g.DefineSameAsFirst(node), |
- g.UseRegister(m.right().node())); |
+ VisitFloatUnop(this, node, m.right().node(), kAVXFloat64Neg, |
+ kSSEFloat64Neg); |
return; |
} |
VisitRROFloat(this, node, kAVXFloat64Sub, kSSEFloat64Sub); |
@@ -767,13 +779,13 @@ void InstructionSelector::VisitFloat64Min(Node* node) { |
void InstructionSelector::VisitFloat32Abs(Node* node) { |
IA32OperandGenerator g(this); |
- Emit(kSSEFloat32Abs, g.DefineSameAsFirst(node), g.Use(node->InputAt(0))); |
+ VisitFloatUnop(this, node, node->InputAt(0), kAVXFloat32Abs, kSSEFloat32Abs); |
} |
void InstructionSelector::VisitFloat64Abs(Node* node) { |
IA32OperandGenerator g(this); |
- Emit(kSSEFloat64Abs, g.DefineSameAsFirst(node), g.Use(node->InputAt(0))); |
+ VisitFloatUnop(this, node, node->InputAt(0), kAVXFloat64Abs, kSSEFloat64Abs); |
} |