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/common-operator-reducer.h" | 5 #include "src/compiler/common-operator-reducer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 Reduction CommonOperatorReducer::ReducePhi(Node* node) { | 47 Reduction CommonOperatorReducer::ReducePhi(Node* node) { |
48 DCHECK_EQ(IrOpcode::kPhi, node->opcode()); | 48 DCHECK_EQ(IrOpcode::kPhi, node->opcode()); |
49 int const input_count = node->InputCount(); | 49 int const input_count = node->InputCount(); |
50 if (input_count == 3) { | 50 if (input_count == 3) { |
51 Node* vtrue = NodeProperties::GetValueInput(node, 0); | 51 Node* vtrue = NodeProperties::GetValueInput(node, 0); |
52 Node* vfalse = NodeProperties::GetValueInput(node, 1); | 52 Node* vfalse = NodeProperties::GetValueInput(node, 1); |
53 Node* merge = NodeProperties::GetControlInput(node); | 53 Node* merge = NodeProperties::GetControlInput(node); |
54 Node* if_true = NodeProperties::GetControlInput(merge, 0); | 54 DiamondMatcher matcher(merge); |
55 Node* if_false = NodeProperties::GetControlInput(merge, 1); | 55 if (matcher.Matched()) { |
56 if (if_true->opcode() != IrOpcode::kIfTrue) { | 56 if (matcher.IfTrue() == merge->InputAt(1)) std::swap(vtrue, vfalse); |
57 std::swap(if_true, if_false); | 57 Node* cond = matcher.Branch()->InputAt(0); |
58 std::swap(vtrue, vfalse); | |
59 } | |
60 if (if_true->opcode() == IrOpcode::kIfTrue && | |
61 if_false->opcode() == IrOpcode::kIfFalse && | |
62 if_true->InputAt(0) == if_false->InputAt(0)) { | |
63 Node* branch = if_true->InputAt(0); | |
64 Node* cond = branch->InputAt(0); | |
65 if (cond->opcode() == IrOpcode::kFloat64LessThan) { | 58 if (cond->opcode() == IrOpcode::kFloat64LessThan) { |
66 if (cond->InputAt(0) == vtrue && cond->InputAt(1) == vfalse && | 59 if (cond->InputAt(0) == vtrue && cond->InputAt(1) == vfalse && |
67 machine()->HasFloat64Min()) { | 60 machine()->HasFloat64Min()) { |
68 node->set_op(machine()->Float64Min()); | 61 node->set_op(machine()->Float64Min()); |
69 node->ReplaceInput(0, vtrue); | 62 node->ReplaceInput(0, vtrue); |
70 node->ReplaceInput(1, vfalse); | 63 node->ReplaceInput(1, vfalse); |
71 node->TrimInputCount(2); | 64 node->TrimInputCount(2); |
72 return Changed(node); | 65 return Changed(node); |
73 } else if (cond->InputAt(0) == vfalse && cond->InputAt(1) == vtrue && | 66 } else if (cond->InputAt(0) == vfalse && cond->InputAt(1) == vtrue && |
74 machine()->HasFloat64Max()) { | 67 machine()->HasFloat64Max()) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 Graph* CommonOperatorReducer::graph() const { return jsgraph()->graph(); } | 120 Graph* CommonOperatorReducer::graph() const { return jsgraph()->graph(); } |
128 | 121 |
129 | 122 |
130 MachineOperatorBuilder* CommonOperatorReducer::machine() const { | 123 MachineOperatorBuilder* CommonOperatorReducer::machine() const { |
131 return jsgraph()->machine(); | 124 return jsgraph()->machine(); |
132 } | 125 } |
133 | 126 |
134 } // namespace compiler | 127 } // namespace compiler |
135 } // namespace internal | 128 } // namespace internal |
136 } // namespace v8 | 129 } // namespace v8 |
OLD | NEW |