diff options
| -rw-r--r-- | zjit/src/cruby_methods.rs | 6 | ||||
| -rw-r--r-- | zjit/src/hir.rs | 2 | ||||
| -rw-r--r-- | zjit/src/hir/opt_tests.rs | 17 |
3 files changed, 16 insertions, 9 deletions
diff --git a/zjit/src/cruby_methods.rs b/zjit/src/cruby_methods.rs index 2aea35cae8..5696e6c4d5 100644 --- a/zjit/src/cruby_methods.rs +++ b/zjit/src/cruby_methods.rs @@ -233,6 +233,7 @@ pub fn init() -> Annotations { annotate!(rb_cInteger, "/", inline_integer_div); annotate!(rb_cInteger, "%", inline_integer_mod); annotate!(rb_cInteger, ">", inline_integer_gt); + annotate!(rb_cInteger, ">=", inline_integer_ge); annotate!(rb_cInteger, "<", inline_integer_lt); annotate!(rb_cInteger, "<=", inline_integer_le); annotate!(rb_cString, "to_s", inline_string_to_s, types::StringExact); @@ -482,6 +483,11 @@ fn inline_integer_gt(fun: &mut hir::Function, block: hir::BlockId, recv: hir::In try_inline_fixnum_op(fun, block, &|left, right| hir::Insn::FixnumGt { left, right }, BOP_GT, recv, other, state) } +fn inline_integer_ge(fun: &mut hir::Function, block: hir::BlockId, recv: hir::InsnId, args: &[hir::InsnId], state: hir::InsnId) -> Option<hir::InsnId> { + let &[other] = args else { return None; }; + try_inline_fixnum_op(fun, block, &|left, right| hir::Insn::FixnumGe { left, right }, BOP_GE, recv, other, state) +} + fn inline_integer_lt(fun: &mut hir::Function, block: hir::BlockId, recv: hir::InsnId, args: &[hir::InsnId], state: hir::InsnId) -> Option<hir::InsnId> { let &[other] = args else { return None; }; try_inline_fixnum_op(fun, block, &|left, right| hir::Insn::FixnumLt { left, right }, BOP_LT, recv, other, state) diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index ead76bbeef..4b329ab374 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -2319,8 +2319,6 @@ impl Function { assert!(self.blocks[block.0].insns.is_empty()); for insn_id in old_insns { match self.find(insn_id) { - Insn::SendWithoutBlock { recv, args, state, cd, .. } if ruby_call_method_id(cd) == ID!(ge) && args.len() == 1 => - self.try_rewrite_fixnum_op(block, insn_id, &|left, right| Insn::FixnumGe { left, right }, BOP_GE, recv, args[0], state), Insn::SendWithoutBlock { recv, args, state, cd, .. } if ruby_call_method_id(cd) == ID!(and) && args.len() == 1 => self.try_rewrite_fixnum_op(block, insn_id, &|left, right| Insn::FixnumAnd { left, right }, BOP_AND, recv, args[0], state), Insn::SendWithoutBlock { recv, args, state, cd, .. } if ruby_call_method_id(cd) == ID!(or) && args.len() == 1 => diff --git a/zjit/src/hir/opt_tests.rs b/zjit/src/hir/opt_tests.rs index 0c0d1d7c0b..8c0e246f44 100644 --- a/zjit/src/hir/opt_tests.rs +++ b/zjit/src/hir/opt_tests.rs @@ -371,13 +371,15 @@ mod hir_opt_tests { bb2(v6:BasicObject): v10:Fixnum[2] = Const Value(2) v12:Fixnum[1] = Const Value(1) - PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_GE) - v51:TrueClass = Const Value(true) + PatchPoint MethodRedefined(Integer@0x1000, >=@0x1008, cme:0x1010) + v55:TrueClass = Const Value(true) + IncrCounter inline_cfunc_optimized_send_count CheckInterrupts v21:Fixnum[2] = Const Value(2) v23:Fixnum[2] = Const Value(2) - PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_GE) - v53:TrueClass = Const Value(true) + PatchPoint MethodRedefined(Integer@0x1000, >=@0x1008, cme:0x1010) + v57:TrueClass = Const Value(true) + IncrCounter inline_cfunc_optimized_send_count CheckInterrupts v33:Fixnum[3] = Const Value(3) CheckInterrupts @@ -1951,9 +1953,10 @@ mod hir_opt_tests { EntryPoint JIT(0) Jump bb2(v6, v7, v8) bb2(v10:BasicObject, v11:BasicObject, v12:BasicObject): - PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_GE) - v29:Fixnum = GuardType v11, Fixnum - v30:Fixnum = GuardType v12, Fixnum + PatchPoint MethodRedefined(Integer@0x1000, >=@0x1008, cme:0x1010) + v30:Fixnum = GuardType v11, Fixnum + v31:Fixnum = GuardType v12, Fixnum + IncrCounter inline_cfunc_optimized_send_count v23:Fixnum[5] = Const Value(5) CheckInterrupts Return v23 |
