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 cc952ecc49bc5fc4476666ba72c8a6e83d945f79..7b28dfbc2746041f31465e187aa80dbab4464a0d 100644 |
| --- a/src/compiler/machine-operator-reducer.cc |
| +++ b/src/compiler/machine-operator-reducer.cc |
| @@ -316,14 +316,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| } |
| case IrOpcode::kFloat32Sub: { |
| Float32BinopMatcher m(node); |
| - if (m.right().Is(0) && (copysign(1.0, m.right().Value()) > 0)) { |
| - return Replace(m.left().node()); // x - 0 => x |
| - } |
| if (m.right().IsNaN()) { // x - NaN => NaN |
| - return Replace(m.right().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat32(m.right().Value() - 0.0); |
| } |
| if (m.left().IsNaN()) { // NaN - x => NaN |
| - return Replace(m.left().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat32(m.left().Value() - 0.0); |
| } |
| if (m.IsFoldable()) { // L - R => (L - R) |
| return ReplaceFloat32(m.left().Value() - m.right().Value()); |
| @@ -350,7 +349,8 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| case IrOpcode::kFloat64Add: { |
| Float64BinopMatcher m(node); |
| if (m.right().IsNaN()) { // x + NaN => NaN |
| - return Replace(m.right().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat64(m.right().Value() - 0.0); |
| } |
| if (m.IsFoldable()) { // K + K => K |
| return ReplaceFloat64(m.left().Value() + m.right().Value()); |
| @@ -359,14 +359,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| } |
| case IrOpcode::kFloat64Sub: { |
| Float64BinopMatcher m(node); |
| - if (m.right().Is(0) && (Double(m.right().Value()).Sign() > 0)) { |
| - return Replace(m.left().node()); // x - 0 => x |
| - } |
| if (m.right().IsNaN()) { // x - NaN => NaN |
|
titzer
2017/01/25 13:28:57
Can you leave a TODO here that we could still do t
|
| - return Replace(m.right().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat64(m.right().Value() - 0.0); |
| } |
| if (m.left().IsNaN()) { // NaN - x => NaN |
| - return Replace(m.left().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat64(m.left().Value() - 0.0); |
| } |
| if (m.IsFoldable()) { // L - R => (L - R) |
| return ReplaceFloat64(m.left().Value() - m.right().Value()); |
| @@ -398,9 +397,9 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| NodeProperties::ChangeOp(node, machine()->Float64Sub()); |
| return Changed(node); |
| } |
| - if (m.right().Is(1)) return Replace(m.left().node()); // x * 1.0 => x |
| if (m.right().IsNaN()) { // x * NaN => NaN |
| - return Replace(m.right().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat64(m.right().Value() - 0.0); |
| } |
| if (m.IsFoldable()) { // K * K => K |
| return ReplaceFloat64(m.left().Value() * m.right().Value()); |
| @@ -414,12 +413,13 @@ 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().IsNaN()) { // x / NaN => NaN |
| - return Replace(m.right().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat64(m.right().Value() - 0.0); |
| } |
| if (m.left().IsNaN()) { // NaN / x => NaN |
| - return Replace(m.left().node()); |
| + // - 0.0 to make a signalling NaN quiet. |
| + return ReplaceFloat64(m.left().Value() - 0.0); |
| } |
| if (m.IsFoldable()) { // K / K => K |
| return ReplaceFloat64(m.left().Value() / m.right().Value()); |