fast-jit: Fix const shift and const i64 compare issues (#2969)

This commit is contained in:
Wenyong Huang 2024-01-02 17:56:34 +08:00 committed by GitHub
parent 286ea35508
commit 2ee013faf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -4379,13 +4379,18 @@ cmp_r_r_to_r_i32(x86::Assembler &a, int32 reg_no_dst, int32 reg_no1_src,
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
static bool static bool
cmp_imm_imm_to_r_i64(x86::Assembler &a, int32 reg_no_dst, int32 data1_src, cmp_imm_imm_to_r_i64(x86::Assembler &a, int32 reg_no_dst, int64 data1_src,
int32 data2_src) int64 data2_src)
{ {
Imm imm(data1_src); /* imm -> m64 */
a.mov(regs_i64[REG_I64_FREE_IDX], imm); const JitHardRegInfo *hreg_info = jit_codegen_get_hreg_info();
imm.setValue(data2_src); x86::Mem mem = x86::qword_ptr(regs_i64[hreg_info->exec_env_hreg_index],
a.cmp(regs_i64[REG_I64_FREE_IDX], imm); offsetof(WASMExecEnv, jit_cache));
Imm imm(data2_src);
mov_imm_to_m(a, mem, imm, 8);
a.mov(regs_i64[REG_I64_FREE_IDX], data1_src);
a.cmp(regs_i64[REG_I64_FREE_IDX], mem);
(void)reg_no_dst; (void)reg_no_dst;
return true; return true;
} }

View File

@ -1066,13 +1066,15 @@ DEF_UNI_INT_CONST_OPS(shru)
static int32 static int32
do_i32_const_shl(int32 lhs, int32 rhs) do_i32_const_shl(int32 lhs, int32 rhs)
{ {
rhs &= 31;
return (int32)((uint32)lhs << (uint32)rhs); return (int32)((uint32)lhs << (uint32)rhs);
} }
static int64 static int64
do_i64_const_shl(int64 lhs, int64 rhs) do_i64_const_shl(int64 lhs, int64 rhs)
{ {
return (int32)((uint64)lhs << (uint64)rhs); rhs &= 63LL;
return (uint64)lhs << (uint64)rhs;
} }
DEF_BI_INT_CONST_OPS(shrs, >>) DEF_BI_INT_CONST_OPS(shrs, >>)
@ -1080,12 +1082,14 @@ DEF_BI_INT_CONST_OPS(shrs, >>)
static int32 static int32
do_i32_const_shru(int32 lhs, int32 rhs) do_i32_const_shru(int32 lhs, int32 rhs)
{ {
rhs &= 31;
return (uint32)lhs >> rhs; return (uint32)lhs >> rhs;
} }
static int64 static int64
do_i64_const_shru(int64 lhs, int64 rhs) do_i64_const_shru(int64 lhs, int64 rhs)
{ {
rhs &= 63LL;
return (uint64)lhs >> rhs; return (uint64)lhs >> rhs;
} }