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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10536145: Fuse comparisons that are used by branches together. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 6 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 | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 461e9d28e7720f0411de329ce9eba6ee8bf2d9ec..0500cd149e736c5c4784c5b98fbb0b412c1d18f2 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -530,6 +530,20 @@ void FlowGraphOptimizer::VisitStoreIndexed(StoreIndexedComp* comp) {
}
+static void TryFuseComparisonWithBranch(ComparisonComp* comp) {
+ Instruction* instr = comp->instr();
+ Instruction* next_instr = instr->StraightLineSuccessor();
+ if (next_instr != NULL && next_instr->IsBranch()) {
+ BranchInstr* branch = next_instr->AsBranch();
+ UseVal* use = branch->value()->AsUse();
+ if (instr == use->definition()) {
+ comp->MarkFusedWithBranch(branch);
+ branch->MarkFusedWithComparison();
+ }
+ }
+}
+
+
void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp) {
if (!comp->HasICData()) return;
@@ -543,7 +557,30 @@ void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp) {
comp->set_operands_class_id(kSmi);
} else if (HasTwoDouble(ic_data)) {
comp->set_operands_class_id(kDouble);
+ } else {
+ return;
}
+
+ // For smi and double comparisons if the next instruction is a conditional
+ // branch that uses the value of this comparison mark them as fused together
+ // to avoid materializing a boolean value.
+ // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion
+ // and a branch.
+ TryFuseComparisonWithBranch(comp);
+}
+
+
+void FlowGraphOptimizer::VisitStrictCompareComp(StrictCompareComp* comp) {
+ // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion
+ // and a branch.
+ TryFuseComparisonWithBranch(comp);
+}
+
+
+void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp) {
+ // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion
+ // and a branch.
+ TryFuseComparisonWithBranch(comp);
}
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698