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

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

Issue 2222513002: [turbofan] Insert sigma nodes for loop variable backedge. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments 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/opcodes.h » ('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 9db42c907e5a0aa03f3fd842dd1fa47ee543d3db..39268f4303069a15a0bf586b7a395f7c1ee1ec6f 100644
--- a/src/compiler/loop-variable-optimizer.cc
+++ b/src/compiler/loop-variable-optimizer.cc
@@ -369,10 +369,11 @@ void LoopVariableOptimizer::ChangeToInductionVariablePhis() {
}
}
-void LoopVariableOptimizer::ChangeFromInductionVariablePhis() {
+void LoopVariableOptimizer::ChangeToPhisAndInsertGuards() {
for (auto entry : induction_vars_) {
InductionVariable* induction_var = entry.second;
if (induction_var->phi()->opcode() == IrOpcode::kInductionVariablePhi) {
+ // Turn the induction variable phi back to normal phi.
int value_count = 2;
Node* control = NodeProperties::GetControlInput(induction_var->phi());
DCHECK_EQ(value_count, control->op()->ControlInputCount());
@@ -381,6 +382,19 @@ void LoopVariableOptimizer::ChangeFromInductionVariablePhis() {
NodeProperties::ChangeOp(
induction_var->phi(),
common()->Phi(MachineRepresentation::kTagged, value_count));
+
+ // If the backedge is not a subtype of the phi's type, we insert a sigma
+ // to get the typing right.
+ Node* backedge_value = induction_var->phi()->InputAt(1);
+ Type* backedge_type = NodeProperties::GetType(backedge_value);
+ Type* phi_type = NodeProperties::GetType(induction_var->phi());
+ if (!backedge_type->Is(phi_type)) {
+ Node* backedge_control =
+ NodeProperties::GetControlInput(induction_var->phi())->InputAt(1);
+ Node* rename = graph()->NewNode(common()->TypeGuard(phi_type),
+ backedge_value, backedge_control);
+ induction_var->phi()->ReplaceInput(1, rename);
+ }
}
}
}
« no previous file with comments | « src/compiler/loop-variable-optimizer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698