Bug 1323027: IonMonkey - Remove empty blocks, r=jandem

This commit is contained in:
Hannes Verschore 2016-12-20 16:03:08 +01:00
parent 9b6d97a4be
commit ca59bc5ee1
4 changed files with 51 additions and 0 deletions

View File

@ -1521,6 +1521,17 @@ OptimizeMIR(MIRGenerator* mir)
return false;
}
{
AutoTraceLog log(logger, TraceLogger_FoldEmptyBlocks);
if (!FoldEmptyBlocks(graph))
return false;
gs.spewPass("Fold Empty Blocks");
AssertBasicGraphCoherency(graph);
if (mir->shouldCancel("Fold Empty Blocks"))
return false;
}
{
AutoTraceLog log(logger, TraceLogger_FoldTests);
if (!FoldTests(graph))

View File

@ -923,6 +923,42 @@ jit::FoldTests(MIRGraph& graph)
return true;
}
bool
jit::FoldEmptyBlocks(MIRGraph& graph)
{
for (MBasicBlockIterator iter(graph.begin()); iter != graph.end(); ) {
MBasicBlock* block = *iter;
iter++;
if (block->numPredecessors() != 1 || block->numSuccessors() != 1)
continue;
if (!block->phisEmpty())
continue;
if (block->outerResumePoint())
continue;
if (*block->begin() != *block->rbegin())
continue;
MBasicBlock* succ = block->getSuccessor(0);
MBasicBlock* pred = block->getPredecessor(0);
if (succ->numPredecessors() != 1)
continue;
size_t pos = pred->getSuccessorIndex(block);
pred->lastIns()->replaceSuccessor(pos, succ);
graph.removeBlock(block);
succ->addPredecessorSameInputsAs(pred, block);
succ->removePredecessor(block);
}
return true;
}
static void
EliminateTriviallyDeadResumePointOperands(MIRGraph& graph, MResumePoint* rp)
{

View File

@ -24,6 +24,9 @@ PruneUnusedBranches(MIRGenerator* mir, MIRGraph& graph);
MOZ_MUST_USE bool
FoldTests(MIRGraph& graph);
MOZ_MUST_USE bool
FoldEmptyBlocks(MIRGraph& graph);
MOZ_MUST_USE bool
SplitCriticalEdges(MIRGraph& graph);

View File

@ -42,6 +42,7 @@
/* Specific passes during ion compilation */ \
_(PruneUnusedBranches) \
_(FoldTests) \
_(FoldEmptyBlocks) \
_(SplitCriticalEdges) \
_(RenumberBlocks) \
_(ScalarReplacement) \