1
0
Fork 0
mirror of https://github.com/yuzu-emu/unicorn.git synced 2025-01-11 18:55:27 +00:00

tcg: Fix do_nonatomic_op_* vs signed operations

The smin/smax/umin/umax operations require the operands to be
properly sign extended. Do not drop the MO_SIGN bit from the
load, and additionally extend the val input.

Backports commit 852f933e482518797f7785a2e017a215b88df815 from qemu
This commit is contained in:
Richard Henderson 2021-02-25 23:09:01 -05:00 committed by Lioncash
parent 57c66389c2
commit 65d5288563

View file

@ -3201,8 +3201,9 @@ static void do_nonatomic_op_i32(TCGContext *s,
memop = tcg_canonicalize_memop(memop, 0, 0);
tcg_gen_qemu_ld_i32(s->uc, t1, addr, idx, memop & ~MO_SIGN);
gen(s, t2, t1, val);
tcg_gen_qemu_ld_i32(s->uc, t1, addr, idx, memop);
tcg_gen_ext_i32(s, t2, val, memop);
gen(s, t2, t1, t2);
tcg_gen_qemu_st_i32(s->uc, t2, addr, idx, memop);
tcg_gen_ext_i32(s, ret, (new_val ? t2 : t1), memop);
@ -3246,8 +3247,9 @@ static void do_nonatomic_op_i64(TCGContext *s,
memop = tcg_canonicalize_memop(memop, 1, 0);
tcg_gen_qemu_ld_i64(s->uc, t1, addr, idx, memop & ~MO_SIGN);
gen(s, t2, t1, val);
tcg_gen_qemu_ld_i64(s->uc, t1, addr, idx, memop);
tcg_gen_ext_i64(s, t2, val, memop);
gen(s, t2, t1, t2);
tcg_gen_qemu_st_i64(s->uc, t2, addr, idx, memop);
tcg_gen_ext_i64(s, ret, (new_val ? t2 : t1), memop);