optimise and/or/xor/test; jc/jo/jbe/jl/jle
This commit is contained in:
parent
da1c713252
commit
37841eb0c9
|
@ -350,7 +350,7 @@ fn gen_get_last_result(builder: &mut WasmBuilder, previous_instruction: &Instruc
|
|||
opsize: OPSIZE_32,
|
||||
..
|
||||
}
|
||||
| Instruction::Arithmetic {
|
||||
| Instruction::Bitwise {
|
||||
dest: InstructionOperandDest::WasmLocal(l),
|
||||
opsize: OPSIZE_32,
|
||||
} => builder.get_local(&l),
|
||||
|
@ -1642,7 +1642,7 @@ pub fn gen_getzf(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
ctx.builder.eqz_i32();
|
||||
}
|
||||
},
|
||||
Instruction::Arithmetic { opsize, .. } => {
|
||||
Instruction::Bitwise { opsize, .. } => {
|
||||
let &opsize = opsize;
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
// Note: Necessary because test{8,16} don't mask their neither last_result nor any of their operands
|
||||
|
@ -1662,7 +1662,7 @@ pub fn gen_getzf(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
ctx.builder.eqz_i32();
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
&Instruction::Other => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_get_flags_changed(ctx.builder);
|
||||
ctx.builder.const_i32(FLAG_ZERO);
|
||||
|
@ -1747,7 +1747,12 @@ pub fn gen_getcf(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
ctx.builder.eqz_i32();
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
Instruction::Bitwise { .. } => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
ctx.builder
|
||||
.const_i32(if negate == ConditionNegate::True { 1 } else { 0 });
|
||||
},
|
||||
&Instruction::Other => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_getcf_unoptimised(ctx);
|
||||
|
||||
|
@ -1795,7 +1800,7 @@ pub fn gen_getsf(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
Instruction::Cmp { opsize, .. }
|
||||
| Instruction::Sub { opsize, .. }
|
||||
| Instruction::Add { opsize, .. }
|
||||
| Instruction::Arithmetic { opsize, .. } => {
|
||||
| Instruction::Bitwise { opsize, .. } => {
|
||||
let &opsize = opsize;
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
gen_get_last_result(ctx.builder, &ctx.previous_instruction);
|
||||
|
@ -1818,7 +1823,7 @@ pub fn gen_getsf(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
}
|
||||
}
|
||||
},
|
||||
Instruction::Other => {
|
||||
&Instruction::Other => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_get_flags_changed(ctx.builder);
|
||||
ctx.builder.const_i32(FLAG_SIGN);
|
||||
|
@ -1899,7 +1904,11 @@ pub fn gen_getof(ctx: &mut JitContext) {
|
|||
});
|
||||
ctx.builder.and_i32();
|
||||
},
|
||||
Instruction::Arithmetic { .. } | Instruction::Other => {
|
||||
Instruction::Bitwise { .. } => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
ctx.builder.const_i32(0);
|
||||
},
|
||||
&Instruction::Other => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_get_flags_changed(ctx.builder);
|
||||
let flags_changed = ctx.builder.tee_new_local();
|
||||
|
@ -2031,6 +2040,10 @@ pub fn gen_test_be(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
ctx.builder.leu_i32();
|
||||
}
|
||||
},
|
||||
&Instruction::Bitwise { .. } => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
gen_getzf(ctx, negate);
|
||||
},
|
||||
_ => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_getcf(ctx, ConditionNegate::False);
|
||||
|
@ -2143,6 +2156,10 @@ pub fn gen_test_l(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
ctx.builder.lt_i32();
|
||||
}
|
||||
},
|
||||
&Instruction::Bitwise { .. } => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
gen_getsf(ctx, negate);
|
||||
},
|
||||
_ => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_getsf(ctx, ConditionNegate::False);
|
||||
|
@ -2257,6 +2274,16 @@ pub fn gen_test_le(ctx: &mut JitContext, negate: ConditionNegate) {
|
|||
ctx.builder.le_i32();
|
||||
}
|
||||
},
|
||||
&Instruction::Bitwise { .. } => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED);
|
||||
// TODO: Could probably be improved (<= 0)
|
||||
gen_test_l(ctx, ConditionNegate::False);
|
||||
gen_getzf(ctx, ConditionNegate::False);
|
||||
ctx.builder.or_i32();
|
||||
if negate == ConditionNegate::True {
|
||||
ctx.builder.eqz_i32();
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED);
|
||||
gen_test_l(ctx, ConditionNegate::False);
|
||||
|
|
|
@ -278,8 +278,7 @@ pub enum Instruction {
|
|||
opsize: i32,
|
||||
is_inc: bool,
|
||||
},
|
||||
// Any instruction that sets last_result
|
||||
Arithmetic {
|
||||
Bitwise {
|
||||
dest: InstructionOperandDest,
|
||||
opsize: i32,
|
||||
},
|
||||
|
|
|
@ -1268,7 +1268,7 @@ fn gen_sbb32(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &Lo
|
|||
}
|
||||
|
||||
fn gen_and8(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &LocalOrImmediate) {
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: OPSIZE_8,
|
||||
dest: local_to_instruction_operand(ctx, dest_operand),
|
||||
};
|
||||
|
@ -1290,7 +1290,7 @@ fn gen_and8(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &Loc
|
|||
.load_fixed_u8(global_pointers::last_result as u32);
|
||||
}
|
||||
fn gen_and32(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &LocalOrImmediate) {
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: OPSIZE_32,
|
||||
dest: local_to_instruction_operand(ctx, dest_operand),
|
||||
};
|
||||
|
@ -1316,7 +1316,7 @@ fn gen_test(
|
|||
size: i32,
|
||||
) {
|
||||
let is_self_test = source_operand.eq_local(dest_operand);
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: size,
|
||||
dest: if is_self_test {
|
||||
local_to_instruction_operand(ctx, dest_operand)
|
||||
|
@ -1355,7 +1355,7 @@ fn gen_test32(ctx: &mut JitContext, dest: &WasmLocal, source: &LocalOrImmediate)
|
|||
}
|
||||
|
||||
fn gen_or8(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &LocalOrImmediate) {
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: OPSIZE_8,
|
||||
dest: local_to_instruction_operand(ctx, dest_operand),
|
||||
};
|
||||
|
@ -1377,7 +1377,7 @@ fn gen_or8(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &Loca
|
|||
.load_fixed_u8(global_pointers::last_result as u32);
|
||||
}
|
||||
fn gen_or32(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &LocalOrImmediate) {
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: OPSIZE_32,
|
||||
dest: local_to_instruction_operand(ctx, dest_operand),
|
||||
};
|
||||
|
@ -1397,7 +1397,7 @@ fn gen_or32(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &Loc
|
|||
}
|
||||
|
||||
fn gen_xor8(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &LocalOrImmediate) {
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: OPSIZE_8,
|
||||
dest: local_to_instruction_operand(ctx, dest_operand),
|
||||
};
|
||||
|
@ -1419,7 +1419,7 @@ fn gen_xor8(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &Loc
|
|||
.load_fixed_u8(global_pointers::last_result as u32);
|
||||
}
|
||||
fn gen_xor32(ctx: &mut JitContext, dest_operand: &WasmLocal, source_operand: &LocalOrImmediate) {
|
||||
ctx.current_instruction = Instruction::Arithmetic {
|
||||
ctx.current_instruction = Instruction::Bitwise {
|
||||
opsize: OPSIZE_32,
|
||||
dest: local_to_instruction_operand(ctx, dest_operand),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue