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/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return NoChange(); | 61 return NoChange(); |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { | 65 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { |
66 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); | 66 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); |
67 Node* const cond = node->InputAt(0); | 67 Node* const cond = node->InputAt(0); |
68 Decision const decision = DecideCondition(cond); | 68 Decision const decision = DecideCondition(cond); |
69 if (decision == Decision::kUnknown) return NoChange(); | 69 if (decision == Decision::kUnknown) return NoChange(); |
70 Node* const control = node->InputAt(1); | 70 Node* const control = node->InputAt(1); |
71 node->set_op(common()->Dead()); | 71 if (!dead_.is_set()) dead_.set(graph()->NewNode(common()->Dead())); |
72 node->TrimInputCount(0); | |
73 for (Node* const use : node->uses()) { | 72 for (Node* const use : node->uses()) { |
74 switch (use->opcode()) { | 73 switch (use->opcode()) { |
75 case IrOpcode::kIfTrue: | 74 case IrOpcode::kIfTrue: |
76 Replace(use, (decision == Decision::kTrue) ? control : node); | 75 Replace(use, (decision == Decision::kTrue) ? control : dead_.get()); |
77 break; | 76 break; |
78 case IrOpcode::kIfFalse: | 77 case IrOpcode::kIfFalse: |
79 Replace(use, (decision == Decision::kFalse) ? control : node); | 78 Replace(use, (decision == Decision::kFalse) ? control : dead_.get()); |
80 break; | 79 break; |
81 default: | 80 default: |
82 UNREACHABLE(); | 81 UNREACHABLE(); |
83 } | 82 } |
84 } | 83 } |
85 return Changed(node); | 84 return Replace(dead_.get()); |
86 } | 85 } |
87 | 86 |
88 | 87 |
89 Reduction CommonOperatorReducer::ReduceMerge(Node* node) { | 88 Reduction CommonOperatorReducer::ReduceMerge(Node* node) { |
90 DCHECK_EQ(IrOpcode::kMerge, node->opcode()); | 89 DCHECK_EQ(IrOpcode::kMerge, node->opcode()); |
91 // | 90 // |
92 // Check if this is a merge that belongs to an unused diamond, which means | 91 // Check if this is a merge that belongs to an unused diamond, which means |
93 // that: | 92 // that: |
94 // | 93 // |
95 // a) the {Merge} has no {Phi} or {EffectPhi} uses, and | 94 // a) the {Merge} has no {Phi} or {EffectPhi} uses, and |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 node->set_op(op); | 302 node->set_op(op); |
304 node->ReplaceInput(0, a); | 303 node->ReplaceInput(0, a); |
305 node->ReplaceInput(1, b); | 304 node->ReplaceInput(1, b); |
306 node->TrimInputCount(2); | 305 node->TrimInputCount(2); |
307 return Changed(node); | 306 return Changed(node); |
308 } | 307 } |
309 | 308 |
310 } // namespace compiler | 309 } // namespace compiler |
311 } // namespace internal | 310 } // namespace internal |
312 } // namespace v8 | 311 } // namespace v8 |
OLD | NEW |