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.
5 #include "src/compiler/common-operator-reducer.h"
7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/node.h"
14 Reduction CommonOperatorReducer::Reduce(Node* node) {
15 switch (node->opcode()) {
16 case IrOpcode::kEffectPhi:
17 case IrOpcode::kPhi: {
18 int const input_count = node->InputCount();
19 if (input_count > 1) {
20 Node* const replacement = node->InputAt(0);
21 for (int i = 1; i < input_count - 1; ++i) {
22 if (node->InputAt(i) != replacement) return NoChange();
24 return Replace(replacement);
28 case IrOpcode::kSelect: {
29 if (node->InputAt(1) == node->InputAt(2)) {
30 return Replace(node->InputAt(1));
40 } // namespace compiler
41 } // namespace internal