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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 case IrOpcode::kMerge: | 63 case IrOpcode::kMerge: |
64 return ReduceMerge(node); | 64 return ReduceMerge(node); |
65 case IrOpcode::kEffectPhi: | 65 case IrOpcode::kEffectPhi: |
66 return ReduceEffectPhi(node); | 66 return ReduceEffectPhi(node); |
67 case IrOpcode::kPhi: | 67 case IrOpcode::kPhi: |
68 return ReducePhi(node); | 68 return ReducePhi(node); |
69 case IrOpcode::kReturn: | 69 case IrOpcode::kReturn: |
70 return ReduceReturn(node); | 70 return ReduceReturn(node); |
71 case IrOpcode::kSelect: | 71 case IrOpcode::kSelect: |
72 return ReduceSelect(node); | 72 return ReduceSelect(node); |
73 case IrOpcode::kGuard: | |
74 return ReduceGuard(node); | |
75 default: | 73 default: |
76 break; | 74 break; |
77 } | 75 } |
78 return NoChange(); | 76 return NoChange(); |
79 } | 77 } |
80 | 78 |
81 | 79 |
82 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { | 80 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { |
83 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); | 81 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); |
84 Node* const cond = node->InputAt(0); | 82 Node* const cond = node->InputAt(0); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 387 } |
390 break; | 388 break; |
391 } | 389 } |
392 default: | 390 default: |
393 break; | 391 break; |
394 } | 392 } |
395 return NoChange(); | 393 return NoChange(); |
396 } | 394 } |
397 | 395 |
398 | 396 |
399 Reduction CommonOperatorReducer::ReduceGuard(Node* node) { | |
400 DCHECK_EQ(IrOpcode::kGuard, node->opcode()); | |
401 Node* const input = NodeProperties::GetValueInput(node, 0); | |
402 Type* const input_type = NodeProperties::GetTypeOrAny(input); | |
403 Type* const guard_type = OpParameter<Type*>(node); | |
404 if (input_type->Is(guard_type)) return Replace(input); | |
405 return NoChange(); | |
406 } | |
407 | |
408 | |
409 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, | 397 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, |
410 Node* a) { | 398 Node* a) { |
411 node->ReplaceInput(0, a); | 399 node->ReplaceInput(0, a); |
412 node->TrimInputCount(1); | 400 node->TrimInputCount(1); |
413 NodeProperties::ChangeOp(node, op); | 401 NodeProperties::ChangeOp(node, op); |
414 return Changed(node); | 402 return Changed(node); |
415 } | 403 } |
416 | 404 |
417 | 405 |
418 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, Node* a, | 406 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, Node* a, |
419 Node* b) { | 407 Node* b) { |
420 node->ReplaceInput(0, a); | 408 node->ReplaceInput(0, a); |
421 node->ReplaceInput(1, b); | 409 node->ReplaceInput(1, b); |
422 node->TrimInputCount(2); | 410 node->TrimInputCount(2); |
423 NodeProperties::ChangeOp(node, op); | 411 NodeProperties::ChangeOp(node, op); |
424 return Changed(node); | 412 return Changed(node); |
425 } | 413 } |
426 | 414 |
427 } // namespace compiler | 415 } // namespace compiler |
428 } // namespace internal | 416 } // namespace internal |
429 } // namespace v8 | 417 } // namespace v8 |
OLD | NEW |