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

Unified Diff: src/compiler/dead-code-elimination.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/dead-code-elimination.cc
diff --git a/src/compiler/dead-code-elimination.cc b/src/compiler/dead-code-elimination.cc
index 697d7f870e8224b70bee06cb91e68be0088aa231..81bf2997e670262b8e6bf26955b86f0af3bc86ac 100644
--- a/src/compiler/dead-code-elimination.cc
+++ b/src/compiler/dead-code-elimination.cc
@@ -28,6 +28,8 @@ Reduction DeadCodeElimination::Reduce(Node* node) {
case IrOpcode::kLoop:
case IrOpcode::kMerge:
return ReduceLoopOrMerge(node);
+ case IrOpcode::kLoopExit:
+ return ReduceLoopExit(node);
default:
return ReduceNode(node);
}
@@ -96,6 +98,9 @@ Reduction DeadCodeElimination::ReduceLoopOrMerge(Node* node) {
for (Node* const use : node->uses()) {
if (NodeProperties::IsPhi(use)) {
Replace(use, use->InputAt(0));
+ } else if (use->opcode() == IrOpcode::kLoopExit &&
+ use->InputAt(1) == node) {
+ RemoveLoopExit(use);
} else if (use->opcode() == IrOpcode::kTerminate) {
DCHECK_EQ(IrOpcode::kLoop, node->opcode());
Replace(use, dead());
@@ -121,6 +126,18 @@ Reduction DeadCodeElimination::ReduceLoopOrMerge(Node* node) {
return NoChange();
}
+Reduction DeadCodeElimination::RemoveLoopExit(Node* node) {
+ DCHECK_EQ(IrOpcode::kLoopExit, node->opcode());
+ for (Node* const use : node->uses()) {
+ if (use->opcode() == IrOpcode::kLoopExitValue ||
+ use->opcode() == IrOpcode::kLoopExitEffect) {
+ Replace(use, use->InputAt(0));
+ }
+ }
+ Node* control = NodeProperties::GetControlInput(node, 0);
+ Replace(node, control);
+ return Replace(control);
+}
Reduction DeadCodeElimination::ReduceNode(Node* node) {
// If {node} has exactly one control input and this is {Dead},
@@ -133,6 +150,15 @@ Reduction DeadCodeElimination::ReduceNode(Node* node) {
return NoChange();
}
+Reduction DeadCodeElimination::ReduceLoopExit(Node* node) {
+ Node* control = NodeProperties::GetControlInput(node, 0);
+ Node* loop = NodeProperties::GetControlInput(node, 1);
+ if (control->opcode() == IrOpcode::kDead ||
+ loop->opcode() == IrOpcode::kDead) {
+ return RemoveLoopExit(node);
+ }
+ return NoChange();
+}
void DeadCodeElimination::TrimMergeOrPhi(Node* node, int size) {
const Operator* const op = common()->ResizeMergeOrPhi(node->op(), size);

Powered by Google App Engine
This is Rietveld 408576698