diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2020-07-01 09:28:15 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2020-07-06 10:58:19 -0700 |
commit | 852f933e482518797f7785a2e017a215b88df815 (patch) | |
tree | 268e898809b41c5953ade7302d4c8cbd422902b9 /tcg/tcg-op.c | |
parent | 94248cfc04dfa08e43aacd9d5bbfba7a47bff671 (diff) | |
download | qemu-852f933e482518797f7785a2e017a215b88df815.zip qemu-852f933e482518797f7785a2e017a215b88df815.tar.gz qemu-852f933e482518797f7785a2e017a215b88df815.tar.bz2 |
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.
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
Reported-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200701165646.1901320-1-richard.henderson@linaro.org>
Diffstat (limited to 'tcg/tcg-op.c')
-rw-r--r-- | tcg/tcg-op.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index e60b74f..4b8a473 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -3189,8 +3189,9 @@ static void do_nonatomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, memop = tcg_canonicalize_memop(memop, 0, 0); - tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN); - gen(t2, t1, val); + tcg_gen_qemu_ld_i32(t1, addr, idx, memop); + tcg_gen_ext_i32(t2, val, memop); + gen(t2, t1, t2); tcg_gen_qemu_st_i32(t2, addr, idx, memop); tcg_gen_ext_i32(ret, (new_val ? t2 : t1), memop); @@ -3232,8 +3233,9 @@ static void do_nonatomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, memop = tcg_canonicalize_memop(memop, 1, 0); - tcg_gen_qemu_ld_i64(t1, addr, idx, memop & ~MO_SIGN); - gen(t2, t1, val); + tcg_gen_qemu_ld_i64(t1, addr, idx, memop); + tcg_gen_ext_i64(t2, val, memop); + gen(t2, t1, t2); tcg_gen_qemu_st_i64(t2, addr, idx, memop); tcg_gen_ext_i64(ret, (new_val ? t2 : t1), memop); |