Chromium Code Reviews| 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(); |