| Index: src/compiler/control-reducer.cc
|
| diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc
|
| index 533fb23997614e8c2503a2f1959c77d4424257a5..b06076457e5e5ae723655486a1fde289dc0e3147 100644
|
| --- a/src/compiler/control-reducer.cc
|
| +++ b/src/compiler/control-reducer.cc
|
| @@ -322,6 +322,8 @@ class ControlReducerImpl {
|
| case IrOpcode::kLoop:
|
| case IrOpcode::kMerge:
|
| return ReduceMerge(node);
|
| + case IrOpcode::kSelect:
|
| + return ReduceSelect(node);
|
| case IrOpcode::kPhi:
|
| case IrOpcode::kEffectPhi:
|
| return ReducePhi(node);
|
| @@ -330,6 +332,32 @@ class ControlReducerImpl {
|
| }
|
| }
|
|
|
| + // Reduce redundant selects.
|
| + Node* ReduceSelect(Node* const node) {
|
| + Node* const cond = node->InputAt(0);
|
| + Node* const tvalue = node->InputAt(1);
|
| + Node* const fvalue = node->InputAt(2);
|
| + if (tvalue == fvalue) return tvalue;
|
| + switch (cond->opcode()) {
|
| + case IrOpcode::kInt32Constant:
|
| + return Int32Matcher(cond).Is(0) ? fvalue : tvalue;
|
| + case IrOpcode::kInt64Constant:
|
| + return Int64Matcher(cond).Is(0) ? fvalue : tvalue;
|
| + case IrOpcode::kNumberConstant:
|
| + return NumberMatcher(cond).Is(0) ? fvalue : tvalue;
|
| + case IrOpcode::kHeapConstant: {
|
| + Handle<Object> object =
|
| + HeapObjectMatcher<Object>(cond).Value().handle();
|
| + if (object->IsTrue()) return tvalue;
|
| + if (object->IsFalse()) return fvalue;
|
| + break;
|
| + }
|
| + default:
|
| + break;
|
| + }
|
| + return node;
|
| + }
|
| +
|
| // Reduce redundant phis.
|
| Node* ReducePhi(Node* node) {
|
| int n = node->InputCount();
|
| @@ -406,6 +434,9 @@ class ControlReducerImpl {
|
| case IrOpcode::kInt32Constant:
|
| is_true = !Int32Matcher(cond).Is(0);
|
| break;
|
| + case IrOpcode::kInt64Constant:
|
| + is_true = !Int64Matcher(cond).Is(0);
|
| + break;
|
| case IrOpcode::kNumberConstant:
|
| is_true = !NumberMatcher(cond).Is(0);
|
| break;
|
|
|