| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 case IrOpcode::kMerge: | 60 case IrOpcode::kMerge: |
| 61 return ReduceMerge(node); | 61 return ReduceMerge(node); |
| 62 case IrOpcode::kEffectPhi: | 62 case IrOpcode::kEffectPhi: |
| 63 return ReduceEffectPhi(node); | 63 return ReduceEffectPhi(node); |
| 64 case IrOpcode::kPhi: | 64 case IrOpcode::kPhi: |
| 65 return ReducePhi(node); | 65 return ReducePhi(node); |
| 66 case IrOpcode::kReturn: | 66 case IrOpcode::kReturn: |
| 67 return ReduceReturn(node); | 67 return ReduceReturn(node); |
| 68 case IrOpcode::kSelect: | 68 case IrOpcode::kSelect: |
| 69 return ReduceSelect(node); | 69 return ReduceSelect(node); |
| 70 case IrOpcode::kGuard: |
| 71 return ReduceGuard(node); |
| 70 default: | 72 default: |
| 71 break; | 73 break; |
| 72 } | 74 } |
| 73 return NoChange(); | 75 return NoChange(); |
| 74 } | 76 } |
| 75 | 77 |
| 76 | 78 |
| 77 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { | 79 Reduction CommonOperatorReducer::ReduceBranch(Node* node) { |
| 78 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); | 80 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); |
| 79 Node* const cond = node->InputAt(0); | 81 Node* const cond = node->InputAt(0); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 353 } |
| 352 break; | 354 break; |
| 353 } | 355 } |
| 354 default: | 356 default: |
| 355 break; | 357 break; |
| 356 } | 358 } |
| 357 return NoChange(); | 359 return NoChange(); |
| 358 } | 360 } |
| 359 | 361 |
| 360 | 362 |
| 363 Reduction CommonOperatorReducer::ReduceGuard(Node* node) { |
| 364 DCHECK_EQ(IrOpcode::kGuard, node->opcode()); |
| 365 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 366 Type* const input_type = NodeProperties::GetTypeOrAny(input); |
| 367 Type* const guard_type = OpParameter<Type*>(node); |
| 368 if (input_type->Is(guard_type)) return Replace(input); |
| 369 return NoChange(); |
| 370 } |
| 371 |
| 372 |
| 361 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, | 373 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, |
| 362 Node* a) { | 374 Node* a) { |
| 363 node->ReplaceInput(0, a); | 375 node->ReplaceInput(0, a); |
| 364 node->TrimInputCount(1); | 376 node->TrimInputCount(1); |
| 365 NodeProperties::ChangeOp(node, op); | 377 NodeProperties::ChangeOp(node, op); |
| 366 return Changed(node); | 378 return Changed(node); |
| 367 } | 379 } |
| 368 | 380 |
| 369 | 381 |
| 370 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, Node* a, | 382 Reduction CommonOperatorReducer::Change(Node* node, Operator const* op, Node* a, |
| 371 Node* b) { | 383 Node* b) { |
| 372 node->ReplaceInput(0, a); | 384 node->ReplaceInput(0, a); |
| 373 node->ReplaceInput(1, b); | 385 node->ReplaceInput(1, b); |
| 374 node->TrimInputCount(2); | 386 node->TrimInputCount(2); |
| 375 NodeProperties::ChangeOp(node, op); | 387 NodeProperties::ChangeOp(node, op); |
| 376 return Changed(node); | 388 return Changed(node); |
| 377 } | 389 } |
| 378 | 390 |
| 379 } // namespace compiler | 391 } // namespace compiler |
| 380 } // namespace internal | 392 } // namespace internal |
| 381 } // namespace v8 | 393 } // namespace v8 |
| OLD | NEW |