OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/compiler/common-operator-reducer.h" |
| 6 |
| 7 #include "src/compiler/common-operator.h" |
| 8 |
| 9 namespace v8 { |
| 10 namespace internal { |
| 11 namespace compiler { |
| 12 |
| 13 Reduction CommonOperatorReducer::Reduce(Node* node) { |
| 14 switch (node->opcode()) { |
| 15 case IrOpcode::kEffectPhi: |
| 16 case IrOpcode::kPhi: { |
| 17 int const input_count = node->InputCount(); |
| 18 if (input_count > 1) { |
| 19 Node* const replacement = node->InputAt(0); |
| 20 for (int i = 1; i < input_count - 1; ++i) { |
| 21 if (node->InputAt(i) != replacement) return NoChange(); |
| 22 } |
| 23 return Replace(replacement); |
| 24 } |
| 25 break; |
| 26 } |
| 27 case IrOpcode::kSelect: { |
| 28 if (node->InputAt(1) == node->InputAt(2)) { |
| 29 return Replace(node->InputAt(1)); |
| 30 } |
| 31 break; |
| 32 } |
| 33 default: |
| 34 break; |
| 35 } |
| 36 return NoChange(); |
| 37 } |
| 38 |
| 39 } // namespace compiler |
| 40 } // namespace internal |
| 41 } // namespace v8 |
OLD | NEW |