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

Unified Diff: src/compiler/phi-reducer.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 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
« no previous file with comments | « src/compiler/operator-properties-inl.h ('k') | src/compiler/pipeline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/phi-reducer.h
diff --git a/src/compiler/phi-reducer.h b/src/compiler/phi-reducer.h
new file mode 100644
index 0000000000000000000000000000000000000000..b6aa65e85119ccaa7149429aa19412497d29b9e2
--- /dev/null
+++ b/src/compiler/phi-reducer.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef V8_COMPILER_PHI_REDUCER_H_
+#define V8_COMPILER_PHI_REDUCER_H_
+
+#include "src/compiler/graph-reducer.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+// Replaces redundant phis if all the inputs are the same or the phi itself.
+class PhiReducer V8_FINAL : public Reducer {
+ public:
+ virtual Reduction Reduce(Node* node) V8_OVERRIDE {
+ if (node->opcode() != IrOpcode::kPhi &&
+ node->opcode() != IrOpcode::kEffectPhi)
+ return NoChange();
+
+ int n = node->op()->InputCount();
+ if (n == 1) return Replace(node->InputAt(0));
+
+ Node* replacement = NULL;
+ Node::Inputs inputs = node->inputs();
+ for (InputIter it = inputs.begin(); n > 0; --n, ++it) {
+ Node* input = *it;
+ if (input != node && input != replacement) {
+ if (replacement != NULL) return NoChange();
+ replacement = input;
+ }
+ }
+ ASSERT_NE(node, replacement);
+ return Replace(replacement);
+ }
+};
+}
+}
+} // namespace v8::internal::compiler
+
+#endif // V8_COMPILER_PHI_REDUCER_H_
« no previous file with comments | « src/compiler/operator-properties-inl.h ('k') | src/compiler/pipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698