Chromium Code Reviews| Index: src/compiler/loop-variable-optimizer.cc |
| diff --git a/src/compiler/loop-variable-optimizer.cc b/src/compiler/loop-variable-optimizer.cc |
| index 64a6409caf933d011f330a0b146f1b04e4d68e9c..8331963a7d8087b1b2d68c0e722f42507875d67b 100644 |
| --- a/src/compiler/loop-variable-optimizer.cc |
| +++ b/src/compiler/loop-variable-optimizer.cc |
| @@ -188,7 +188,7 @@ void LoopVariableOptimizer::VisitBackedge(Node* from, Node* loop) { |
| NodeProperties::GetControlInput(constraint->right()) == loop) { |
| auto var = induction_vars_.find(constraint->right()->id()); |
| if (var != induction_vars_.end()) { |
| - var->second->AddUpperBound(constraint->left(), constraint->kind()); |
| + var->second->AddLowerBound(constraint->left(), constraint->kind()); |
|
Jarin
2016/08/19 13:08:25
Awesome, thanks for the fix! After a bit of thinki
Franzi
2016/08/19 18:38:51
Done.
|
| } |
| } |
| } |
| @@ -303,10 +303,15 @@ InductionVariable* LoopVariableOptimizer::TryGetInductionVariable(Node* phi) { |
| DCHECK_EQ(IrOpcode::kLoop, NodeProperties::GetControlInput(phi)->opcode()); |
| Node* initial = phi->InputAt(0); |
| Node* arith = phi->InputAt(1); |
| - // TODO(jarin) Support subtraction. |
| - if (arith->opcode() != IrOpcode::kJSAdd) { |
| + InductionVariable::ArithmeticType arithmeticType; |
| + if (arith->opcode() == IrOpcode::kJSAdd) { |
| + arithmeticType = InductionVariable::ArithmeticType::kAddition; |
| + } else if (arith->opcode() == IrOpcode::kJSSubtract) { |
| + arithmeticType = InductionVariable::ArithmeticType::kSubtraction; |
| + } else { |
| return nullptr; |
| } |
| + |
| // TODO(jarin) Support both sides. |
| if (arith->InputAt(0) != phi) { |
| if (arith->InputAt(0)->opcode() != IrOpcode::kJSToNumber || |
| @@ -315,7 +320,8 @@ InductionVariable* LoopVariableOptimizer::TryGetInductionVariable(Node* phi) { |
| } |
| } |
| Node* incr = arith->InputAt(1); |
| - return new (zone()) InductionVariable(phi, arith, incr, initial, zone()); |
| + return new (zone()) |
| + InductionVariable(phi, arith, incr, initial, zone(), arithmeticType); |
| } |
| void LoopVariableOptimizer::DetectInductionVariables(Node* loop) { |