Skip to content

Commit

Permalink
don't fuse BB right after a guard op
Browse files Browse the repository at this point in the history
arguably the biggest beneficiary of fusing BBs
is the exprjit. However, it currently bails out
whenever it sees a sp_guard* op.
  • Loading branch information
timo committed Feb 28, 2018
1 parent 9233d85 commit 65e952b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/spesh/optimize.c
Expand Up @@ -2506,14 +2506,30 @@ static void eliminate_pointless_gotos(MVMThreadContext *tc, MVMSpeshGraph *g) {
}
}

static MVMuint8 ends_in_guard(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshBB *bb) {
MVMuint8 limit = 4;
MVMSpeshIns *ins = bb->last_ins;

while (ins && limit) {
if (ins->info->opcode == MVM_OP_sp_guardconc
|| ins->info->opcode == MVM_OP_sp_guardtype
|| ins->info->opcode == MVM_OP_sp_guardsf) {
return 1;
}

ins = ins->prev;
limit--;
}
return 0;
}
static void merge_bbs(MVMThreadContext *tc, MVMSpeshGraph *g) {
MVMSpeshBB *bb = g->entry;
MVMint32 orig_bbs = g->num_bbs;
if (!bb || !bb->linear_next) return; /* looks like there's only a single bb anyway */
bb = bb->linear_next;

while (bb->linear_next) {
if (bb->num_succ == 1 && bb->succ[0] == bb->linear_next && bb->linear_next->num_pred == 1 && !bb->inlined && !bb->linear_next->inlined) {
if (bb->num_succ == 1 && bb->succ[0] == bb->linear_next && bb->linear_next->num_pred == 1 && !bb->inlined && !bb->linear_next->inlined && !ends_in_guard(tc, g, bb)) {
if (bb->linear_next->first_ins) {
bb->linear_next->first_ins->prev = bb->last_ins;
if (bb->last_ins) {
Expand Down

0 comments on commit 65e952b

Please sign in to comment.