qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] tcg/tcg-op: nonatomic_op should work with smaller memop
@ 2020-07-01 15:21 LIU Zhiwei
  2020-07-01 16:25 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: LIU Zhiwei @ 2020-07-01 15:21 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv
  Cc: richard.henderson, wxy194768, wenmeng_zhang, Alistair.Francis,
	palmer, LIU Zhiwei

Reserve MO_SIGN in load and extend another operator val according to memop.
Thus, we can call tcg_gen_atomic_*_tl with a smaller memop.

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 tcg/tcg-op.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index e60b74fb82..9a0870cb18 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -3189,7 +3189,8 @@ 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);
+    tcg_gen_qemu_ld_i32(t1, addr, idx, memop);
+    tcg_gen_ext_i32(val, val, memop);
     gen(t2, t1, val);
     tcg_gen_qemu_st_i32(t2, addr, idx, memop);
 
@@ -3232,7 +3233,8 @@ 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);
+    tcg_gen_qemu_ld_i64(t1, addr, idx, memop);
+    tcg_gen_ext_i64(val, val, memop);
     gen(t2, t1, val);
     tcg_gen_qemu_st_i64(t2, addr, idx, memop);
 
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] tcg/tcg-op: nonatomic_op should work with smaller memop
  2020-07-01 15:21 [PATCH 1/1] tcg/tcg-op: nonatomic_op should work with smaller memop LIU Zhiwei
@ 2020-07-01 16:25 ` Richard Henderson
  2020-07-01 23:44   ` LIU Zhiwei
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2020-07-01 16:25 UTC (permalink / raw)
  To: LIU Zhiwei, qemu-devel, qemu-riscv
  Cc: palmer, wenmeng_zhang, Alistair.Francis, wxy194768

On 7/1/20 8:21 AM, LIU Zhiwei wrote:
> -    tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN);
> +    tcg_gen_qemu_ld_i32(t1, addr, idx, memop);
> +    tcg_gen_ext_i32(val, val, memop);
>      gen(t2, t1, val);

I was just about to post a simiar patch.
The difference with mine is that I do not modify val:

-    gen(t2, t1, val);
+    tcg_gen_ext_i32(t2, val, memop);
+    gen(t2, t1, t2);


r~


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] tcg/tcg-op: nonatomic_op should work with smaller memop
  2020-07-01 16:25 ` Richard Henderson
@ 2020-07-01 23:44   ` LIU Zhiwei
  0 siblings, 0 replies; 3+ messages in thread
From: LIU Zhiwei @ 2020-07-01 23:44 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel, qemu-riscv
  Cc: palmer, wenmeng_zhang, Alistair.Francis, wxy194768



On 2020/7/2 0:25, Richard Henderson wrote:
> On 7/1/20 8:21 AM, LIU Zhiwei wrote:
>> -    tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN);
>> +    tcg_gen_qemu_ld_i32(t1, addr, idx, memop);
>> +    tcg_gen_ext_i32(val, val, memop);
>>       gen(t2, t1, val);
> I was just about to post a simiar patch.
> The difference with mine is that I do not modify val:
>
> -    gen(t2, t1, val);
> +    tcg_gen_ext_i32(t2, val, memop);
> +    gen(t2, t1, t2);
I see. So just ignore this patch.:-)

Zhiwei
>
> r~



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-01 23:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 15:21 [PATCH 1/1] tcg/tcg-op: nonatomic_op should work with smaller memop LIU Zhiwei
2020-07-01 16:25 ` Richard Henderson
2020-07-01 23:44   ` LIU Zhiwei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).