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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10559072: Fuse Comparison->BooleanNegate->Branch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 | « no previous file | 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
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 8911)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -482,14 +482,33 @@
static void TryFuseComparisonWithBranch(ComparisonComp* comp) {
Instruction* instr = comp->instr();
Instruction* next_instr = instr->StraightLineSuccessor();
- if (next_instr != NULL && next_instr->IsBranch()) {
+ 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();
+ return;
}
}
+ if ((next_instr != NULL) && next_instr->IsBind()) {
+ Computation* next_comp = next_instr->AsBind()->computation();
+ if (next_comp->IsBooleanNegate()) {
+ Instruction* next_next_instr = next_instr->StraightLineSuccessor();
+ if ((next_next_instr != NULL) && next_next_instr->IsBranch()) {
+ BooleanNegateComp* negate = next_comp->AsBooleanNegate();
+ BranchInstr* branch = next_next_instr->AsBranch();
+ if ((branch->value()->AsUse()->definition() == negate->instr()) &&
+ (negate->value()->AsUse()->definition() == instr)) {
+ comp->MarkFusedWithBranch(branch);
+ branch->MarkFusedWithComparison();
+ branch->set_is_negated(true);
+ instr->SetSuccessor(next_next_instr);
+ return;
+ }
+ }
+ }
+ }
}
@@ -513,15 +532,11 @@
// 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);
}
@@ -535,8 +550,6 @@
comp->set_ic_data(&unary_checks);
}
- // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion
- // and a branch.
TryFuseComparisonWithBranch(comp);
}
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698