Commit 38efe3f497 for qemu.org
commit 38efe3f4978b9b5e90f88c3c6d0f44b84d3e03a3
Author: Ilya Leoshkevich <iii@linux.ibm.com>
Date: Mon Aug 3 14:38:34 2026 +0200
tests/tcg/s390x: Test LOAD and STORE REVERSED
Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20260803123928.1875606-1-iii@linux.ibm.com>
diff --git a/tests/tcg/s390x/load-store-reversed.c b/tests/tcg/s390x/load-store-reversed.c
new file mode 100644
index 0000000000..bcc6b98dd3
--- /dev/null
+++ b/tests/tcg/s390x/load-store-reversed.c
@@ -0,0 +1,46 @@
+/*
+ * Test the LOAD REVERSED and STORE REVERSED instructions.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ long i = 0x123456789abcdefULL, o;
+
+ o = i;
+ asm("lrvr %0,%1" : "+r" (o) : "r" (i));
+ assert(o == 0x1234567efcdab89ULL);
+
+ o = i;
+ asm("lrvgr %0,%1" : "+r" (o) : "r" (i));
+ assert(o == 0xefcdab8967452301ULL);
+
+ o = i;
+ asm("lrvh %0,%1" : "=r" (o) : "T" (i));
+ assert(o == 0x123456789ab2301ULL);
+
+ o = i;
+ asm("lrv %0,%1" : "=r" (o) : "T" (i));
+ assert(o == 0x123456767452301ULL);
+
+ o = i;
+ asm("lrvg %0,%1" : "=r" (o) : "T" (i));
+ assert(o == 0xefcdab8967452301ULL);
+
+ o = i;
+ asm("strvh %1,%0" : "=T" (o) : "r" (i));
+ assert(o == 0xefcd456789abcdefULL);
+
+ o = i;
+ asm("strv %1,%0" : "=T" (o) : "r" (i));
+ assert(o == 0xefcdab8989abcdefULL);
+
+ o = i;
+ asm("strvg %1,%0" : "=T" (o) : "r" (i));
+ assert(o == 0xefcdab8967452301ULL);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/tcg/s390x/meson.build b/tests/tcg/s390x/meson.build
index dc6271c7c7..c9af66aa1b 100644
--- a/tests/tcg/s390x/meson.build
+++ b/tests/tcg/s390x/meson.build
@@ -73,6 +73,7 @@ tests += {
'stckf.c': {},
'ts.c': {},
'ex-smc.c': {'cflags': ['-Wl,--no-warn-rwx-segments']},
+ 'load-store-reversed.c': {},
}
foreach src: tests_s390x_pgm