Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: src/compiler/machine-operator-reducer.cc

Issue 1235663002: [turbofan] Reduce Float64 comparison to Float32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698