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

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

Issue 2347573002: [turbofan] Reduce some Float64 division to multiplication (Closed)
Patch Set: Move power of two tests to matcher Created 4 years, 3 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
« no previous file with comments | « no previous file | src/compiler/node-matchers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index 18f96947cfe188a0129cca6cf5a74970a82a2ded..a4e58c6d98c13931b0b1f004453b9735868a87b9 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -418,6 +418,11 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
if (m.IsFoldable()) { // K * K => K
return ReplaceFloat64(m.left().Value() * m.right().Value());
}
+ if (m.right().Is(2)) { // x * 2.0 => x + x
+ node->ReplaceInput(1, m.left().node());
+ NodeProperties::ChangeOp(node, machine()->Float64Add());
+ return Changed(node);
+ }
break;
}
case IrOpcode::kFloat64Div: {
@@ -432,6 +437,19 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
if (m.IsFoldable()) { // K / K => K
return ReplaceFloat64(m.left().Value() / m.right().Value());
}
+ if (m.right().Is(-1)) { // x / -1.0 => -x
+ node->RemoveInput(1);
+ NodeProperties::ChangeOp(node, machine()->Float64Neg());
+ return Changed(node);
+ }
+ if (m.right().IsNormal() && m.right().IsPositiveOrNegativePowerOf2()) {
+ // All reciprocals of non-denormal powers of two can be represented
+ // exactly, so division by power of two can be reduced to
+ // multiplication by reciprocal, with the same result.
+ node->ReplaceInput(1, Float64Constant(1.0 / m.right().Value()));
+ NodeProperties::ChangeOp(node, machine()->Float64Mul());
+ return Changed(node);
+ }
break;
}
case IrOpcode::kFloat64Mod: {
« no previous file with comments | « no previous file | src/compiler/node-matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698