* [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts
@ 2024-03-18 20:27 Ilya Leoshkevich
2024-03-18 20:27 ` [PATCH v2 2/2] tests/tcg/s390x: Test TEST AND SET Ilya Leoshkevich
2024-03-18 22:03 ` [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts David Hildenbrand
0 siblings, 2 replies; 4+ messages in thread
From: Ilya Leoshkevich @ 2024-03-18 20:27 UTC (permalink / raw)
To: Richard Henderson, David Hildenbrand, Thomas Huth
Cc: qemu-s390x, qemu-devel, Ido Plat, qemu-stable, Ilya Leoshkevich
From: Ido Plat <ido.plat@ibm.com>
Otherwise TCG would assume the register that holds t1 would be constant
and reuse whenever it needs the value within it.
Cc: qemu-stable@nongnu.org
Fixes: f1ea739bd598 ("target/s390x: Use tcg_constant_* in local contexts")
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[iii: Adjust a newline and capitalization, add tags]
Signed-off-by: Ido Plat <ido.plat@ibm.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
target/s390x/tcg/translate.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index 0d0c672c959..57b7db1ee96 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -4781,9 +4781,10 @@ static DisasJumpType op_trXX(DisasContext *s, DisasOps *o)
static DisasJumpType op_ts(DisasContext *s, DisasOps *o)
{
- TCGv_i32 t1 = tcg_constant_i32(0xff);
+ TCGv_i32 ff = tcg_constant_i32(0xff);
+ TCGv_i32 t1 = tcg_temp_new_i32();
- tcg_gen_atomic_xchg_i32(t1, o->in2, t1, get_mem_index(s), MO_UB);
+ tcg_gen_atomic_xchg_i32(t1, o->in2, ff, get_mem_index(s), MO_UB);
tcg_gen_extract_i32(cc_op, t1, 7, 1);
set_cc_static(s);
return DISAS_NEXT;
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] tests/tcg/s390x: Test TEST AND SET
2024-03-18 20:27 [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts Ilya Leoshkevich
@ 2024-03-18 20:27 ` Ilya Leoshkevich
2024-03-18 21:53 ` Richard Henderson
2024-03-18 22:03 ` [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts David Hildenbrand
1 sibling, 1 reply; 4+ messages in thread
From: Ilya Leoshkevich @ 2024-03-18 20:27 UTC (permalink / raw)
To: Richard Henderson, David Hildenbrand, Thomas Huth
Cc: qemu-s390x, qemu-devel, Ilya Leoshkevich
Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
tests/tcg/s390x/Makefile.target | 1 +
tests/tcg/s390x/ts.c | 35 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
create mode 100644 tests/tcg/s390x/ts.c
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index e2aba2ec274..a8f86c94498 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -47,6 +47,7 @@ TESTS+=add-logical-with-carry
TESTS+=lae
TESTS+=cvd
TESTS+=cvb
+TESTS+=ts
cdsg: CFLAGS+=-pthread
cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/ts.c b/tests/tcg/s390x/ts.c
new file mode 100644
index 00000000000..441faf30d98
--- /dev/null
+++ b/tests/tcg/s390x/ts.c
@@ -0,0 +1,35 @@
+/*
+ * Test the TEST AND SET instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+static int ts(char *p)
+{
+ int cc;
+
+ asm("ts %[p]\n"
+ "ipm %[cc]"
+ : [cc] "=r" (cc)
+ , [p] "+Q" (*p)
+ : : "cc");
+
+ return (cc >> 28) & 3;
+}
+
+int main(void)
+{
+ char c;
+
+ c = 0x80;
+ assert(ts(&c) == 1);
+ assert(c == 0xff);
+
+ c = 0x7f;
+ assert(ts(&c) == 0);
+ assert(c == 0xff);
+
+ return EXIT_SUCCESS;
+}
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts
2024-03-18 20:27 [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts Ilya Leoshkevich
2024-03-18 20:27 ` [PATCH v2 2/2] tests/tcg/s390x: Test TEST AND SET Ilya Leoshkevich
@ 2024-03-18 22:03 ` David Hildenbrand
1 sibling, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-03-18 22:03 UTC (permalink / raw)
To: Ilya Leoshkevich, Richard Henderson, Thomas Huth
Cc: qemu-s390x, qemu-devel, Ido Plat, qemu-stable
On 18.03.24 21:27, Ilya Leoshkevich wrote:
> From: Ido Plat <ido.plat@ibm.com>
>
> Otherwise TCG would assume the register that holds t1 would be constant
> and reuse whenever it needs the value within it.
>
> Cc: qemu-stable@nongnu.org
> Fixes: f1ea739bd598 ("target/s390x: Use tcg_constant_* in local contexts")
> Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> [iii: Adjust a newline and capitalization, add tags]
> Signed-off-by: Ido Plat <ido.plat@ibm.com>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-18 22:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-18 20:27 [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts Ilya Leoshkevich
2024-03-18 20:27 ` [PATCH v2 2/2] tests/tcg/s390x: Test TEST AND SET Ilya Leoshkevich
2024-03-18 21:53 ` Richard Henderson
2024-03-18 22:03 ` [PATCH v2 1/2] target/s390x: Use mutable temporary value for op_ts David Hildenbrand
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).