Commit 020e2c8d authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Break a cycle with a loop node in the int64-lowering.

The control edges in a TurboFan graph can form a cycle. To break this cycle in the int64-lowering we add special handling for loop nodes. Similar handling already exists for phi nodes and effectphi nodes, which breaks cycles formed by value edges and effect edges, respectively.

Review-Url: https://codereview.chromium.org/2511503002
Cr-Commit-Position: refs/heads/master@{#41071}
parent ae3ca62b
......@@ -61,7 +61,8 @@ void Int64Lowering::LowerGraph() {
// that they are processed after all other nodes.
PreparePhiReplacement(input);
stack_.push_front({input, 0});
} else if (input->opcode() == IrOpcode::kEffectPhi) {
} else if (input->opcode() == IrOpcode::kEffectPhi ||
input->opcode() == IrOpcode::kLoop) {
stack_.push_front({input, 0});
} else {
stack_.push_back({input, 0});
......
......@@ -875,6 +875,25 @@ TEST_F(Int64LoweringTest, EffectPhiLoop) {
LowerGraph(load, MachineRepresentation::kWord64);
}
TEST_F(Int64LoweringTest, LoopCycle) {
// New node with two placeholders.
Node* compare = graph()->NewNode(machine()->Word64Equal(), Int64Constant(0),
Int64Constant(value(0)));
Node* load = graph()->NewNode(
machine()->Load(MachineType::Int64()), Int64Constant(value(1)),
Int64Constant(value(2)), graph()->start(),
graph()->NewNode(
common()->Loop(2), graph()->start(),
graph()->NewNode(common()->IfFalse(),
graph()->NewNode(common()->Branch(), compare,
graph()->start()))));
NodeProperties::ReplaceValueInput(compare, load, 0);
LowerGraph(load, MachineRepresentation::kWord64);
}
} // namespace compiler
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment