Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[mono][interp] Replace compare + brfalse/brtrue with single condition…
…al branch
  • Loading branch information
BrzVlad committed Nov 18, 2022
commit fe06a726462b2944300a287767f59135221419f4
29 changes: 28 additions & 1 deletion src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -9386,6 +9386,34 @@ interp_super_instructions (TransformData *td)
}
}
} else if (MINT_IS_UNOP_CONDITIONAL_BRANCH (opcode) && is_short_offset (noe, ins->info.target_bb->native_offset_estimate)) {
if (opcode == MINT_BRFALSE_I4 || opcode == MINT_BRTRUE_I4) {
gboolean negate = opcode == MINT_BRFALSE_I4;
int cond_sreg = ins->sregs [0];
InterpInst *def = td->locals [cond_sreg].def;
if (def != NULL) {
int replace_opcode = -1;
switch (def->opcode) {
case MINT_CEQ_I4: replace_opcode = negate ? MINT_BNE_UN_I4 : MINT_BEQ_I4; break;
case MINT_CEQ_I8: replace_opcode = negate ? MINT_BNE_UN_I8 : MINT_BEQ_I8; break;
// Add more opcodes
default:
break;
}
if (replace_opcode != -1) {
ins->opcode = replace_opcode;
ins->sregs [0] = def->sregs [0];
ins->sregs [1] = def->sregs [1];
interp_clear_ins (def);
if (td->verbose_level) {
g_print ("superins: ");
dump_interp_inst (ins);
}
// The newly added opcode could be part of further superinstructions. Retry
ins = ins->prev;
continue;
}
}
}
InterpInst *prev_ins = interp_prev_ins (ins);
if (prev_ins && prev_ins->opcode == MINT_SAFEPOINT) {
int condbr_op = get_unop_condbr_sp (opcode);
Expand All @@ -9397,7 +9425,6 @@ interp_super_instructions (TransformData *td)
dump_interp_inst (ins);
}
}

}
}
noe += get_inst_length (ins);
Expand Down