Index: src/compiler/machine-operator-reducer.cc |
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc |
index 3ce59733ebaea08485912703ea8b498e84e56686..86e677d8ee69e501218eee8f24a5806e590db84b 100644 |
--- a/src/compiler/machine-operator-reducer.cc |
+++ b/src/compiler/machine-operator-reducer.cc |
@@ -439,6 +439,10 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
return ReduceFloat64InsertHighWord32(node); |
case IrOpcode::kStore: |
return ReduceStore(node); |
+ case IrOpcode::kFloat64Equal: |
+ case IrOpcode::kFloat64LessThan: |
+ case IrOpcode::kFloat64LessThanOrEqual: |
+ return ReduceFloat64Compare(node); |
default: |
break; |
} |
@@ -1004,6 +1008,37 @@ Reduction MachineOperatorReducer::ReduceFloat64InsertHighWord32(Node* node) { |
} |
+Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) { |
+ DCHECK((IrOpcode::kFloat64Equal == node->opcode()) || |
+ (IrOpcode::kFloat64LessThan == node->opcode()) || |
+ (IrOpcode::kFloat64LessThanOrEqual == node->opcode())); |
+ // As all Float32 values have an exact representation in Float64, comparing |
+ // two Float64 values both converted from Float32 is equivalent to comparing |
+ // the original Float32s, so we can ignore the conversions. |
+ Float64BinopMatcher m(node); |
+ if (m.left().IsChangeFloat32ToFloat64() && |
+ m.right().IsChangeFloat32ToFloat64()) { |
+ switch (node->opcode()) { |
+ case IrOpcode::kFloat64Equal: |
+ node->set_op(machine()->Float32Equal()); |
+ break; |
+ case IrOpcode::kFloat64LessThan: |
+ node->set_op(machine()->Float32LessThan()); |
+ break; |
+ case IrOpcode::kFloat64LessThanOrEqual: |
+ node->set_op(machine()->Float32LessThanOrEqual()); |
+ break; |
+ default: |
+ return NoChange(); |
+ } |
+ node->ReplaceInput(0, m.left().InputAt(0)); |
+ node->ReplaceInput(1, m.right().InputAt(0)); |
+ return Changed(node); |
+ } |
+ return NoChange(); |
+} |
+ |
+ |
CommonOperatorBuilder* MachineOperatorReducer::common() const { |
return jsgraph()->common(); |
} |