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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 11819031: Add canonicalize optimization for branches. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
« runtime/vm/compiler.cc ('K') | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 16846)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -26,6 +26,7 @@
"Propagate IC data from unoptimized to optimized IC calls.");
DECLARE_FLAG(bool, enable_type_checks);
DECLARE_FLAG(int, max_polymorphic_checks);
+DECLARE_FLAG(bool, trace_optimization);
Definition::Definition()
: range_(NULL),
@@ -1686,6 +1687,34 @@
return this;
}
+
+Instruction* BranchInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
+ if (comparison()->IsStrictCompare()) {
+ Definition* replacement = comparison()->Canonicalize(optimizer);
Kevin Millikin (Google) 2013/01/10 10:35:00 It might be simpler with an early return, and I li
Florian Schneider 2013/01/10 13:18:41 Done.
+ if ((replacement != comparison()) &&
+ replacement->IsComparison()) {
+ ComparisonInstr* comp = replacement->AsComparison();
+ if ((comp->input_use_list()->instruction() == this) &&
+ (comp->input_use_list()->next_use() == NULL) &&
+ (comp->env_use_list() == NULL)) {
+ // Replace the comparison if the replacement is used at this branch,
+ // and has exactly one use.
+ comp->RemoveFromGraph();
+ ReplaceWith(comp, NULL /* ignored */);
Kevin Millikin (Google) 2013/01/10 10:35:00 You should expand the comment about NULL so the re
Florian Schneider 2013/01/10 13:18:41 Done.
+ for (intptr_t i = 0; i < comp->InputCount(); ++i) {
+ Value* operand = comp->InputAt(i);
+ operand->set_instruction(this);
+ }
+ if (FLAG_trace_optimization) {
+ OS::Print("Merging comparison v%"Pd"\n", comp->ssa_temp_index());
+ }
+ }
+ }
+ }
+ return this;
+}
+
+
Definition* StrictCompareInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
if (!right()->BindsToConstant()) return this;
const Object& right_constant = right()->BoundConstant();
« runtime/vm/compiler.cc ('K') | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698