From e9a3fc5b0059bbd158ef8bd14a40e9570707e26b Mon Sep 17 00:00:00 2001 From: Fabian Date: Sat, 5 Nov 2022 15:09:42 -0600 Subject: [PATCH] consider add/inc/dec; jbe optimised in its current form --- src/rust/codegen.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rust/codegen.rs b/src/rust/codegen.rs index 321c8bce..f03dd060 100644 --- a/src/rust/codegen.rs +++ b/src/rust/codegen.rs @@ -2044,7 +2044,17 @@ pub fn gen_test_be(ctx: &mut JitContext, negate: ConditionNegate) { gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED); gen_getzf(ctx, negate); }, - _ => { + &Instruction::Add { .. } | &Instruction::Sub { is_dec: true, .. } => { + gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_OPTIMISED); + // not the best code generation, but reasonable for this fairly uncommon case + gen_getcf(ctx, ConditionNegate::False); + gen_getzf(ctx, ConditionNegate::False); + ctx.builder.or_i32(); + if negate == ConditionNegate::True { + ctx.builder.eqz_i32(); + } + }, + &Instruction::Other => { gen_profiler_stat_increment(ctx.builder, profiler::stat::CONDITION_UNOPTIMISED); gen_getcf(ctx, ConditionNegate::False); gen_getzf(ctx, ConditionNegate::False);