Fix fast jit issue of translating opcode i32.rem_s/i64.rem_s (#1731)

This commit is contained in:
Wenyong Huang 2022-11-21 16:37:10 +08:00 committed by GitHub
parent cf7b01ad82
commit 89f9d695ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -770,16 +770,21 @@ compile_int_div(JitCompContext *cc, IntArithmetic arith_op, bool is_i32,
}
case INT_REM_S:
{
JitReg left1 =
is_i32 ? jit_cc_new_reg_I32(cc) : jit_cc_new_reg_I64(cc);
GEN_INSN(CMP, cc->cmp_reg, right,
is_i32 ? NEW_CONST(I32, -1) : NEW_CONST(I64, -1LL));
/* Don't generate `SELECTEQ left, cmp_reg, 0, left` since
left might be const, use left1 instead */
if (is_i32)
GEN_INSN(SELECTEQ, left, cc->cmp_reg, NEW_CONST(I32, 0),
GEN_INSN(SELECTEQ, left1, cc->cmp_reg, NEW_CONST(I32, 0),
left);
else
GEN_INSN(SELECTEQ, left, cc->cmp_reg, NEW_CONST(I64, 0),
GEN_INSN(SELECTEQ, left1, cc->cmp_reg, NEW_CONST(I64, 0),
left);
/* Build default div and rem */
return compile_int_div_no_check(cc, arith_op, is_i32, left,
return compile_int_div_no_check(cc, arith_op, is_i32, left1,
right, res);
}
default: