optimise test x, x followed by jz/js

This commit is contained in:
Fabian 2022-11-04 13:06:24 -06:00
parent 0ea7c7cd81
commit db65dd352d
2 changed files with 8 additions and 4 deletions

View file

@ -1745,7 +1745,6 @@ pub fn gen_getsf(ctx: &mut JitContext) {
let &opsize = opsize;
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
// TODO:
// use local for test x, x
// x >= 0 for ConditionNegate::True
gen_get_last_result(ctx.builder, &ctx.previous_instruction);
ctx.builder.const_i32(if opsize == OPSIZE_32 {

View file

@ -1288,14 +1288,19 @@ fn gen_test(
source_operand: &LocalOrImmediate,
size: i32,
) {
// TODO: Instruction::Test { dest: local_to_instruction_operand(ctx, dest_operand) }
let is_self_test = source_operand.eq_local(dest_operand);
ctx.current_instruction = Instruction::Arithmetic {
opsize: size,
dest: InstructionOperandDest::Other,
dest: if is_self_test {
local_to_instruction_operand(ctx, dest_operand)
}
else {
InstructionOperandDest::Other
},
};
ctx.builder.const_i32(global_pointers::last_result as i32);
if source_operand.eq_local(dest_operand) {
if is_self_test {
ctx.builder.get_local(&dest_operand);
}
else {