Commit d1cf8dd8 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[turbofan] Visit reachable nodes at least once in loop analysis

Loop analysis never visited nodes whose marks happened to not change
when visiting their outputs in backwards propagation. This CL ensures
that each reachable node is visited at least once.

Change-Id: I70cd73737c0abe8151d5e23bc50525599fa3ea6a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2581538Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71938}
parent 8bebe4e9
...@@ -25,7 +25,8 @@ namespace compiler { ...@@ -25,7 +25,8 @@ namespace compiler {
// Temporary information for each node during marking. // Temporary information for each node during marking.
struct NodeInfo { struct NodeInfo {
Node* node; Node* node;
NodeInfo* next; // link in chaining loop members NodeInfo* next; // link in chaining loop members
bool backwards_visited;
}; };
...@@ -61,7 +62,7 @@ class LoopFinderImpl { ...@@ -61,7 +62,7 @@ class LoopFinderImpl {
end_(graph->end()), end_(graph->end()),
queue_(zone), queue_(zone),
queued_(graph, 2), queued_(graph, 2),
info_(graph->NodeCount(), {nullptr, nullptr}, zone), info_(graph->NodeCount(), {nullptr, nullptr, false}, zone),
loops_(zone), loops_(zone),
loop_num_(graph->NodeCount(), -1, zone), loop_num_(graph->NodeCount(), -1, zone),
loop_tree_(loop_tree), loop_tree_(loop_tree),
...@@ -192,7 +193,7 @@ class LoopFinderImpl { ...@@ -192,7 +193,7 @@ class LoopFinderImpl {
while (!queue_.empty()) { while (!queue_.empty()) {
tick_counter_->TickAndMaybeEnterSafepoint(); tick_counter_->TickAndMaybeEnterSafepoint();
Node* node = queue_.front(); Node* node = queue_.front();
info(node); info(node).backwards_visited = true;
queue_.pop_front(); queue_.pop_front();
queued_.Set(node, false); queued_.Set(node, false);
...@@ -224,10 +225,18 @@ class LoopFinderImpl { ...@@ -224,10 +225,18 @@ class LoopFinderImpl {
Node* input = node->InputAt(i); Node* input = node->InputAt(i);
if (IsBackedge(node, i)) { if (IsBackedge(node, i)) {
// Only propagate the loop mark on backedges. // Only propagate the loop mark on backedges.
if (SetBackwardMark(input, loop_num)) Queue(input); if (SetBackwardMark(input, loop_num) ||
!info(input).backwards_visited) {
Queue(input);
}
} else { } else {
// Entry or normal edge. Propagate all marks except loop_num. // Entry or normal edge. Propagate all marks except loop_num.
if (PropagateBackwardMarks(node, input, loop_num)) Queue(input); // TODO(manoskouk): Add test that needs backwards_visited to function
// correctly, probably using wasm loop unrolling when it is available.
if (PropagateBackwardMarks(node, input, loop_num) ||
!info(input).backwards_visited) {
Queue(input);
}
} }
} }
} }
......
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