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

Unified Diff: runtime/vm/flow_graph_optimizer.h

Issue 12540002: Implement a branch optimization pass. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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: runtime/vm/flow_graph_optimizer.h
diff --git a/runtime/vm/flow_graph_optimizer.h b/runtime/vm/flow_graph_optimizer.h
index 83515bc50105d19292b921e70f2119e2c59e790e..418dbdcce11c8934810e049362ba9911f51959c7 100644
--- a/runtime/vm/flow_graph_optimizer.h
+++ b/runtime/vm/flow_graph_optimizer.h
@@ -260,6 +260,35 @@ class ConstantPropagator : public FlowGraphVisitor {
};
+// Rewrite branches to eliminate materialization of boolean values after
+// inlining, and to expose other optimizations (e.g., constant folding of
+// branches, unreachable code elimination).
+class BranchSimplifier : public AllStatic {
+ public:
+ static void Simplify(FlowGraph* flow_graph);
+
+ private:
+ // Match an instance of the pattern to rewrite. See the implementation
+ // for the patterns that are handled by this pass.
+ static bool Match(JoinEntryInstr* block);
+
+ // Replace a target entry instruction with a join entry instruction. Does
+ // not update the original target's predecessors to point to the new block
+ // and does not replace the target in already computed block order lists.
+ static JoinEntryInstr* ToJoinEntry(TargetEntryInstr* target);
+
+ // Duplicate a constant, assigning it a new SSA name.
+ static ConstantInstr* CloneConstant(FlowGraph* flow_graph,
+ ConstantInstr* constant);
+
+ // Duplicate a branch while replacing its comparison's left and right
+ // inputs.
+ static BranchInstr* RewriteBranch(BranchInstr* branch,
+ Value* left,
+ Value* right);
+};
+
+
} // namespace dart
#endif // VM_FLOW_GRAPH_OPTIMIZER_H_

Powered by Google App Engine
This is Rietveld 408576698