Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 5cc5e80e25e354d368c08cbe7594e6b0164c3431..52de326dbc329290f63dfe7aeb4d71d5e29bc2bf 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -40,6 +40,7 @@ |
#include "hydrogen-gvn.h" |
#include "hydrogen-osr.h" |
#include "hydrogen-range-analysis.h" |
+#include "hydrogen-redundant-phi.h" |
#include "hydrogen-sce.h" |
#include "hydrogen-uint32-analysis.h" |
#include "lithium-allocator.h" |
@@ -2523,53 +2524,6 @@ void HGraph::NullifyUnreachableInstructions() { |
} |
-// Replace all phis consisting of a single non-loop operand plus any number of |
-// loop operands by that single non-loop operand. |
-void HGraph::EliminateRedundantPhis() { |
- HPhase phase("H_Redundant phi elimination", this); |
- |
- // We do a simple fixed point iteration without any work list, because |
- // machine-generated JavaScript can lead to a very dense Hydrogen graph with |
- // an enormous work list and will consequently result in OOM. Experiments |
- // showed that this simple algorithm is good enough, and even e.g. tracking |
- // the set or range of blocks to consider is not a real improvement. |
- bool need_another_iteration; |
- ZoneList<HPhi*> redundant_phis(blocks_.length(), zone()); |
- do { |
- need_another_iteration = false; |
- for (int i = 0; i < blocks_.length(); ++i) { |
- HBasicBlock* block = blocks_[i]; |
- for (int j = 0; j < block->phis()->length(); j++) { |
- HPhi* phi = block->phis()->at(j); |
- HValue* replacement = phi->GetRedundantReplacement(); |
- if (replacement != NULL) { |
- // Remember phi to avoid concurrent modification of the block's phis. |
- redundant_phis.Add(phi, zone()); |
- for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { |
- HValue* value = it.value(); |
- value->SetOperandAt(it.index(), replacement); |
- need_another_iteration |= value->IsPhi(); |
- } |
- } |
- } |
- for (int i = 0; i < redundant_phis.length(); i++) { |
- block->RemovePhi(redundant_phis[i]); |
- } |
- redundant_phis.Clear(); |
- } |
- } while (need_another_iteration); |
- |
-#if DEBUG |
- // Make sure that we *really* removed all redundant phis. |
- for (int i = 0; i < blocks_.length(); ++i) { |
- for (int j = 0; j < blocks_[i]->phis()->length(); j++) { |
- ASSERT(blocks_[i]->phis()->at(j)->GetRedundantReplacement() == NULL); |
- } |
- } |
-#endif |
-} |
- |
- |
bool HGraph::CheckArgumentsPhiUses() { |
int block_count = blocks_.length(); |
for (int i = 0; i < block_count; ++i) { |
@@ -3417,7 +3371,7 @@ bool HGraph::Optimize(SmartArrayPointer<char>* bailout_reason) { |
"Unsupported phi use of const variable")); |
return false; |
} |
- EliminateRedundantPhis(); |
+ Run<HRedundantPhiEliminationPhase>(); |
if (!CheckArgumentsPhiUses()) { |
*bailout_reason = SmartArrayPointer<char>(StrDup( |
"Unsupported phi use of arguments")); |