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

Unified Diff: src/compiler/load-elimination.cc

Issue 782473002: [turbofan] Redundant load elimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: test case Created 6 years 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/load-elimination.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/load-elimination.cc
diff --git a/src/compiler/load-elimination.cc b/src/compiler/load-elimination.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fe0714ebc1aee4567b80f1a4a0ad3f93031ef8ea
--- /dev/null
+++ b/src/compiler/load-elimination.cc
@@ -0,0 +1,76 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/compiler/load-elimination.h"
+
+#include "src/compiler/node-properties-inl.h"
+#include "src/compiler/simplified-operator.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+LoadElimination::~LoadElimination() {}
+
+
+Reduction LoadElimination::Reduce(Node* node) {
+ switch (node->opcode()) {
+ case IrOpcode::kLoadField:
+ return ReduceLoadField(node);
+ default:
+ break;
+ }
+ return NoChange();
+}
+
+
+Reduction LoadElimination::ReduceLoadField(Node* node) {
+ DCHECK_EQ(IrOpcode::kLoadField, node->opcode());
+ FieldAccess const access = FieldAccessOf(node->op());
+ Node* const object = NodeProperties::GetValueInput(node, 0);
+ for (Node* effect = NodeProperties::GetEffectInput(node);;
+ effect = NodeProperties::GetEffectInput(effect)) {
+ switch (effect->opcode()) {
+ case IrOpcode::kLoadField: {
+ if (object == NodeProperties::GetValueInput(effect, 0) &&
+ access == FieldAccessOf(effect->op())) {
+ Node* const value = effect;
+ NodeProperties::ReplaceWithValue(node, value);
+ return Replace(value);
+ }
+ break;
+ }
+ case IrOpcode::kStoreField: {
+ if (access == FieldAccessOf(effect->op())) {
+ if (object == NodeProperties::GetValueInput(effect, 0)) {
+ Node* const value = NodeProperties::GetValueInput(effect, 1);
+ NodeProperties::ReplaceWithValue(node, value);
+ return Replace(value);
+ }
+ // TODO(turbofan): Alias analysis to the rescue?
+ return NoChange();
+ }
+ break;
+ }
+ case IrOpcode::kStoreBuffer:
+ case IrOpcode::kStoreElement: {
+ // These can never interfere with field loads.
+ break;
+ }
+ default: {
+ if (!effect->op()->HasProperty(Operator::kNoWrite) ||
+ effect->op()->EffectInputCount() != 1) {
+ return NoChange();
+ }
+ break;
+ }
+ }
+ }
+ UNREACHABLE();
+ return NoChange();
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/compiler/load-elimination.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698