Chromium Code Reviews| Index: src/hydrogen.cc |
| =================================================================== |
| --- src/hydrogen.cc (revision 11825) |
| +++ src/hydrogen.cc (working copy) |
| @@ -1512,6 +1512,7 @@ |
| GVNFlagSet loop_kills, |
| GVNFlagSet* accumulated_first_time_depends, |
| GVNFlagSet* accumulated_first_time_changes); |
| + void PostProcessLoopPreHeader(HBasicBlock* pre_header); |
| bool AllowCodeMotion(); |
| bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header); |
| @@ -1691,6 +1692,12 @@ |
| } |
| } |
| } |
| + for (int i = graph_->blocks()->length() - 1; i >= 0; --i) { |
| + HBasicBlock* block = graph_->blocks()->at(i); |
| + if (block->IsLoopHeader()) { |
| + PostProcessLoopPreHeader(block->predecessors()->at(0)); |
| + } |
| + } |
| } |
| @@ -1801,7 +1808,27 @@ |
| } |
| } |
| +void HGlobalValueNumberer::PostProcessLoopPreHeader(HBasicBlock* pre_header) { |
| + HInstruction* instr = pre_header->first(); |
| + while (instr != NULL) { |
| + HInstruction* next = instr->next(); |
| + if (instr->IsTransitionElementsKind()) { |
| + HValue* old_elems = instr->OperandAt(0), *new_elems = instr; |
| + HInstruction* current = next; |
| + while (current != NULL) { |
| + for (int i = 0; i < current->OperandCount(); ++i) { |
| + if (current->OperandAt(i) == old_elems) { |
| + current->SetOperandAt(i, new_elems); |
| + } |
| + } |
| + current = current->next(); |
| + } |
| + } |
|
danno
2012/06/19 15:45:05
This is potentially a n^2 algorithm with respect t
|
| + instr = next; |
| + } |
| +} |
| + |
| bool HGlobalValueNumberer::AllowCodeMotion() { |
| return info()->shared_info()->opt_count() + 1 < Compiler::kDefaultMaxOptCount; |
| } |