Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: src/compiler/loop-variable-optimizer.cc

Issue 2260153002: [turbofan] Induction variable decrement bound analysis. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@DeleteUnusedVar
Patch Set: Simplify if-else loop Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/loop-variable-optimizer.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
}
}
@@ -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) {
« no previous file with comments | « src/compiler/loop-variable-optimizer.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698