Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do dead instruction elim pass after usage setup
But before we do the deopt analysis. While it's of course possible that there was dead code in the input program, the main purpose of this is to trim away dead PHI nodes, recursively, so that they will not make extra work for the deopt analyzer nor cause things to be kept alive bogusly just because a PHI was used across a deopt point. This seems to have a positive effect on spectest time, probably due to the deopt usage algorithm having a bit less to do, as well as resulting in elimination of more instructions during optimization that were falsely retained.
- Loading branch information
Showing
9 changed files
with
62 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "moar.h" | ||
|
||
/* Eliminates any unused instructions. */ | ||
void MVM_spesh_eliminate_dead_ins(MVMThreadContext *tc, MVMSpeshGraph *g) { | ||
/* Keep eliminating to a fixed point. */ | ||
MVMint8 death = 1; | ||
while (death) { | ||
MVMSpeshBB *bb = g->entry; | ||
death = 0; | ||
while (bb) { | ||
if (!bb->inlined) { | ||
MVMSpeshIns *ins = bb->last_ins; | ||
while (ins) { | ||
MVMSpeshIns *prev = ins->prev; | ||
if (ins->info->opcode == MVM_SSA_PHI) { | ||
if (!MVM_spesh_usages_is_used(tc, g, ins->operands[0])) { | ||
/* Remove this phi. */ | ||
MVM_spesh_manipulate_delete_ins(tc, g, bb, ins); | ||
death = 1; | ||
} | ||
} | ||
else if (ins->info->pure) { | ||
/* Sanity check to make sure it's a write reg as first operand. */ | ||
if ((ins->info->operands[0] & MVM_operand_rw_mask) == MVM_operand_write_reg) { | ||
if (!MVM_spesh_usages_is_used(tc, g, ins->operands[0])) { | ||
/* Remove this instruction. */ | ||
MVM_spesh_manipulate_delete_ins(tc, g, bb, ins); | ||
death = 1; | ||
} | ||
} | ||
} | ||
ins = prev; | ||
} | ||
} | ||
bb = bb->linear_next; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void MVM_spesh_eliminate_dead_ins(MVMThreadContext *tc, MVMSpeshGraph *g); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters