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-peeling.cc

Issue 2140673007: [turbofan] Introduce explicit loop exits markers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 4 years, 5 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
Index: src/compiler/loop-peeling.cc
diff --git a/src/compiler/loop-peeling.cc b/src/compiler/loop-peeling.cc
index 53795961b3a956720e4886e2f65349ec67317de3..a09f5060e0e24f2be5b2ba903b7a750855ece5ed 100644
--- a/src/compiler/loop-peeling.cc
+++ b/src/compiler/loop-peeling.cc
@@ -329,6 +329,60 @@ PeeledIteration* LoopPeeler::Peel(Graph* graph, CommonOperatorBuilder* common,
return iter;
}
+namespace {
+
+void EliminateLoopExit(Node* node) {
+ DCHECK_EQ(IrOpcode::kLoopExit, node->opcode());
+ // The exit markers take the loop exit as input. We iterate over uses
+ // and remove all the markers from the graph.
+ for (Edge edge : node->use_edges()) {
+ if (NodeProperties::IsControlEdge(edge)) {
+ Node* marker = edge.from();
+ if (marker->opcode() == IrOpcode::kLoopExitValue) {
+ NodeProperties::ReplaceUses(marker, marker->InputAt(0));
+ marker->Kill();
+ } else if (marker->opcode() == IrOpcode::kLoopExitEffect) {
+ NodeProperties::ReplaceUses(marker, nullptr,
+ NodeProperties::GetEffectInput(marker));
+ marker->Kill();
+ }
+ }
+ }
+ NodeProperties::ReplaceUses(node, nullptr, nullptr,
+ NodeProperties::GetControlInput(node, 0));
+ node->Kill();
+}
+
+} // namespace
+
+// static
+void LoopPeeler::EliminateLoopExits(Graph* graph, Zone* temp_zone) {
+ ZoneQueue<Node*> queue(temp_zone);
+ ZoneVector<bool> visited(graph->NodeCount(), false, temp_zone);
+ queue.push(graph->end());
+ while (!queue.empty()) {
+ Node* node = queue.front();
+ queue.pop();
+
+ if (node->opcode() == IrOpcode::kLoopExit) {
+ Node* control = NodeProperties::GetControlInput(node);
+ EliminateLoopExit(node);
+ if (!visited[control->id()]) {
+ visited[control->id()] = true;
+ queue.push(control);
+ }
+ } else {
+ for (int i = 0; i < node->op()->ControlInputCount(); i++) {
+ Node* control = NodeProperties::GetControlInput(node, i);
+ if (!visited[control->id()]) {
+ visited[control->id()] = true;
+ queue.push(control);
+ }
+ }
+ }
+ }
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698