| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
| 9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 if (m.HasValue()) return ReplaceFloat64(base::ieee754::log10(m.Value())); | 534 if (m.HasValue()) return ReplaceFloat64(base::ieee754::log10(m.Value())); |
| 535 break; | 535 break; |
| 536 } | 536 } |
| 537 case IrOpcode::kFloat64Log2: { | 537 case IrOpcode::kFloat64Log2: { |
| 538 Float64Matcher m(node->InputAt(0)); | 538 Float64Matcher m(node->InputAt(0)); |
| 539 if (m.HasValue()) return ReplaceFloat64(base::ieee754::log2(m.Value())); | 539 if (m.HasValue()) return ReplaceFloat64(base::ieee754::log2(m.Value())); |
| 540 break; | 540 break; |
| 541 } | 541 } |
| 542 case IrOpcode::kFloat64Pow: { | 542 case IrOpcode::kFloat64Pow: { |
| 543 Float64BinopMatcher m(node); | 543 Float64BinopMatcher m(node); |
| 544 // TODO(bmeurer): Constant fold once we have a unified pow implementation. | 544 if (m.IsFoldable()) { |
| 545 if (m.right().Is(0.0)) { // x ** +-0.0 => 1.0 | 545 return ReplaceFloat64(Pow(m.left().Value(), m.right().Value())); |
| 546 } else if (m.right().Is(0.0)) { // x ** +-0.0 => 1.0 |
| 546 return ReplaceFloat64(1.0); | 547 return ReplaceFloat64(1.0); |
| 547 } else if (m.right().Is(-2.0)) { // x ** -2.0 => 1 / (x * x) | 548 } else if (m.right().Is(-2.0)) { // x ** -2.0 => 1 / (x * x) |
| 548 node->ReplaceInput(0, Float64Constant(1.0)); | 549 node->ReplaceInput(0, Float64Constant(1.0)); |
| 549 node->ReplaceInput(1, Float64Mul(m.left().node(), m.left().node())); | 550 node->ReplaceInput(1, Float64Mul(m.left().node(), m.left().node())); |
| 550 NodeProperties::ChangeOp(node, machine()->Float64Div()); | 551 NodeProperties::ChangeOp(node, machine()->Float64Div()); |
| 551 return Changed(node); | 552 return Changed(node); |
| 552 } else if (m.right().Is(2.0)) { // x ** 2.0 => x * x | 553 } else if (m.right().Is(2.0)) { // x ** 2.0 => x * x |
| 553 node->ReplaceInput(1, m.left().node()); | 554 node->ReplaceInput(1, m.left().node()); |
| 554 NodeProperties::ChangeOp(node, machine()->Float64Mul()); | 555 NodeProperties::ChangeOp(node, machine()->Float64Mul()); |
| 555 return Changed(node); | 556 return Changed(node); |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 1371 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
| 1371 return jsgraph()->machine(); | 1372 return jsgraph()->machine(); |
| 1372 } | 1373 } |
| 1373 | 1374 |
| 1374 | 1375 |
| 1375 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 1376 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
| 1376 | 1377 |
| 1377 } // namespace compiler | 1378 } // namespace compiler |
| 1378 } // namespace internal | 1379 } // namespace internal |
| 1379 } // namespace v8 | 1380 } // namespace v8 |
| OLD | NEW |