diff --git a/erts/emulator/beam/jit/arm/instr_bs.cpp b/erts/emulator/beam/jit/arm/instr_bs.cpp index d164b03d1886..f06b9c162b80 100644 --- a/erts/emulator/beam/jit/arm/instr_bs.cpp +++ b/erts/emulator/beam/jit/arm/instr_bs.cpp @@ -351,23 +351,12 @@ void BeamModuleAssembler::emit_bs_get_integer2(const ArgLabel &Fail, void BeamModuleAssembler::emit_bs_test_tail2(const ArgLabel &Fail, const ArgRegister &Ctx, const ArgWord &Offset) { - const int start_offset = offsetof(ErlSubBits, start); - const int end_offset = offsetof(ErlSubBits, end); - - auto ctx_reg = load_source(Ctx, TMP1); - - ASSERT(Offset.isWord()); - - a.ldur(TMP2, emit_boxed_val(ctx_reg.reg, end_offset)); - a.ldur(TMP3, emit_boxed_val(ctx_reg.reg, start_offset)); - a.sub(TMP2, TMP2, TMP3); + /* This instruction is only found in unoptimized code and in code + * compiled for Erlang/OTP 25 and earlier. */ + const ArgVal match[] = {ArgAtom(am_ensure_exactly), Offset}; + const Span args(match, sizeof(match) / sizeof(match[0])); - if (Offset.get() != 0) { - cmp(TMP2, Offset.get()); - a.b_ne(resolve_beam_label(Fail, disp1MB)); - } else { - a.cbnz(TMP2, resolve_beam_label(Fail, disp1MB)); - } + emit_i_bs_match(Fail, Ctx, args); } void BeamModuleAssembler::emit_bs_set_position(const ArgRegister &Ctx, diff --git a/erts/emulator/beam/jit/x86/instr_bs.cpp b/erts/emulator/beam/jit/x86/instr_bs.cpp index 189dbee74058..d1fd5a0706c8 100644 --- a/erts/emulator/beam/jit/x86/instr_bs.cpp +++ b/erts/emulator/beam/jit/x86/instr_bs.cpp @@ -370,21 +370,12 @@ void BeamModuleAssembler::emit_bs_get_integer2(const ArgLabel &Fail, void BeamModuleAssembler::emit_bs_test_tail2(const ArgLabel &Fail, const ArgRegister &Ctx, const ArgWord &Offset) { - mov_arg(ARG1, Ctx); - - a.mov(ARG2, emit_boxed_val(ARG1, offsetof(ErlSubBits, end))); - a.sub(ARG2, emit_boxed_val(ARG1, offsetof(ErlSubBits, start))); - - if (Offset.get() != 0) { - if (Support::isInt32(Offset.get())) { - a.cmp(ARG2, imm(Offset.get())); - } else { - mov_imm(RET, Offset.get()); - a.cmp(ARG2, RET); - } - } + /* This instruction is only found in unoptimized code and in code + * compiled for Erlang/OTP 25 and earlier. */ + const ArgVal match[] = {ArgAtom(am_ensure_exactly), Offset}; + const Span args(match, sizeof(match) / sizeof(match[0])); - a.jne(resolve_beam_label(Fail)); + emit_i_bs_match(Fail, Ctx, args); } void BeamModuleAssembler::emit_bs_set_position(const ArgRegister &Ctx,