mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1323027: IonMonkey - Remove empty blocks, r=jandem
This commit is contained in:
parent
9b6d97a4be
commit
ca59bc5ee1
@ -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))
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
/* Specific passes during ion compilation */ \
|
||||
_(PruneUnusedBranches) \
|
||||
_(FoldTests) \
|
||||
_(FoldEmptyBlocks) \
|
||||
_(SplitCriticalEdges) \
|
||||
_(RenumberBlocks) \
|
||||
_(ScalarReplacement) \
|
||||
|
Loading…
Reference in New Issue
Block a user