Chromium Code Reviews| 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..d663aeaaf70da004111c52193d0dc43d326a0bfa 100644 |
| --- a/src/compiler/machine-operator-reducer.cc |
| +++ b/src/compiler/machine-operator-reducer.cc |
| @@ -412,6 +412,11 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| return Changed(node); |
| } |
| if (m.right().Is(1)) return Replace(m.left().node()); // x * 1.0 => x |
| + if (m.right().Is(2)) { // x * 2.0 => x + x |
|
Benedikt Meurer
2016/09/15 17:20:52
This should come after the m.IsFoldable case below
|
| + node->ReplaceInput(1, m.left().node()); |
| + NodeProperties::ChangeOp(node, machine()->Float64Add()); |
| + return Changed(node); |
| + } |
| if (m.right().IsNaN()) { // x * NaN => NaN |
| return Replace(m.right().node()); |
| } |
| @@ -423,6 +428,11 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| case IrOpcode::kFloat64Div: { |
| Float64BinopMatcher m(node); |
| if (m.right().Is(1)) return Replace(m.left().node()); // x / 1.0 => x |
| + if (m.right().Is(-1)) { // x / -1.0 => -x |
|
Benedikt Meurer
2016/09/15 17:20:52
Move this below the m.IsFoldable case.
|
| + node->RemoveInput(1); |
| + NodeProperties::ChangeOp(node, machine()->Float64Neg()); |
| + return Changed(node); |
| + } |
| if (m.right().IsNaN()) { // x / NaN => NaN |
| return Replace(m.right().node()); |
| } |
| @@ -432,6 +442,16 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| if (m.IsFoldable()) { // K / K => K |
| return ReplaceFloat64(m.left().Value() / m.right().Value()); |
| } |
| + if (m.right().HasValue()) { |
| + Double k = Double(m.right().Value()); |
|
Benedikt Meurer
2016/09/15 17:20:52
Can you add this as a IsPowerOfTwo methd to the Fl
martyn.capewell
2016/09/15 17:41:19
The idea is that all reciprocals of non-denormal p
Benedikt Meurer
2016/09/15 18:20:05
Aye, thanks. Please add a comment.
|
| + if (!k.IsSpecial() && !k.IsDenormal() && |
| + ((k.AsUint64() & Double::kSignificandMask) == 0)) { |
| + // x / K => x * (1 / K) for power-of-two K |
| + node->ReplaceInput(1, Float64Constant(1.0 / k.value())); |
| + NodeProperties::ChangeOp(node, machine()->Float64Mul()); |
| + return Changed(node); |
| + } |
| + } |
| break; |
| } |
| case IrOpcode::kFloat64Mod: { |