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/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler/diamond.h" | 10 #include "src/compiler/diamond.h" |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 639 |
640 | 640 |
641 Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { | 641 Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { |
642 Float64Matcher m(node->InputAt(0)); | 642 Float64Matcher m(node->InputAt(0)); |
643 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); | 643 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); |
644 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); | 644 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); |
645 if (m.IsPhi()) { | 645 if (m.IsPhi()) { |
646 Node* const phi = m.node(); | 646 Node* const phi = m.node(); |
647 DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi))); | 647 DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi))); |
648 if (phi->OwnedBy(node)) { | 648 if (phi->OwnedBy(node)) { |
649 // TruncateFloat64ToInt32(Phi[Float64](x1,...,xn)) | 649 // TruncateFloat64ToInt32[mode](Phi[Float64](x1,...,xn)) |
650 // => Phi[Int32](TruncateFloat64ToInt32(x1), | 650 // => Phi[Int32](TruncateFloat64ToInt32[mode](x1), |
651 // ..., | 651 // ..., |
652 // TruncateFloat64ToInt32(xn)) | 652 // TruncateFloat64ToInt32[mode](xn)) |
653 const int value_input_count = phi->InputCount() - 1; | 653 const int value_input_count = phi->InputCount() - 1; |
654 for (int i = 0; i < value_input_count; ++i) { | 654 for (int i = 0; i < value_input_count; ++i) { |
655 Node* input = graph()->NewNode(machine()->TruncateFloat64ToInt32(), | 655 Node* input = graph()->NewNode(node->op(), phi->InputAt(i)); |
656 phi->InputAt(i)); | |
657 // TODO(bmeurer): Reschedule input for reduction once we have Revisit() | 656 // TODO(bmeurer): Reschedule input for reduction once we have Revisit() |
658 // instead of recursing into ReduceTruncateFloat64ToInt32() here. | 657 // instead of recursing into ReduceTruncateFloat64ToInt32() here. |
659 Reduction reduction = ReduceTruncateFloat64ToInt32(input); | 658 Reduction reduction = ReduceTruncateFloat64ToInt32(input); |
660 if (reduction.Changed()) input = reduction.replacement(); | 659 if (reduction.Changed()) input = reduction.replacement(); |
661 phi->ReplaceInput(i, input); | 660 phi->ReplaceInput(i, input); |
662 } | 661 } |
663 phi->set_op(common()->Phi(kMachInt32, value_input_count)); | 662 phi->set_op(common()->Phi(kMachInt32, value_input_count)); |
664 return Replace(phi); | 663 return Replace(phi); |
665 } | 664 } |
666 } | 665 } |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 1012 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
1014 return jsgraph()->machine(); | 1013 return jsgraph()->machine(); |
1015 } | 1014 } |
1016 | 1015 |
1017 | 1016 |
1018 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 1017 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
1019 | 1018 |
1020 } // namespace compiler | 1019 } // namespace compiler |
1021 } // namespace internal | 1020 } // namespace internal |
1022 } // namespace v8 | 1021 } // namespace v8 |
OLD | NEW |