[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/33] target/s390x: Hoist some computation in access_memmove
From: |
Thomas Huth |
Subject: |
[PULL 16/33] target/s390x: Hoist some computation in access_memmove |
Date: |
Mon, 27 Feb 2023 12:36:04 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
Ensure that the total length is in a local variable
across the byte loop. Compute size1 difference once.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20230109201856.3916639-8-richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
target/s390x/tcg/mem_helper.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index f28126fde6..e51a0db0fe 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -299,16 +299,17 @@ static void access_set_byte(CPUS390XState *env,
S390Access *access,
static void access_memmove(CPUS390XState *env, S390Access *desta,
S390Access *srca, uintptr_t ra)
{
+ int len = desta->size1 + desta->size2;
int diff;
- g_assert(desta->size1 + desta->size2 == srca->size1 + srca->size2);
+ assert(len == srca->size1 + srca->size2);
/* Fallback to slow access in case we don't have access to all host pages
*/
if (unlikely(!desta->haddr1 || (desta->size2 && !desta->haddr2) ||
!srca->haddr1 || (srca->size2 && !srca->haddr2))) {
int i;
- for (i = 0; i < desta->size1 + desta->size2; i++) {
+ for (i = 0; i < len; i++) {
uint8_t byte = access_get_byte(env, srca, i, ra);
access_set_byte(env, desta, i, byte, ra);
@@ -316,20 +317,20 @@ static void access_memmove(CPUS390XState *env, S390Access
*desta,
return;
}
- if (srca->size1 == desta->size1) {
+ diff = desta->size1 - srca->size1;
+ if (likely(diff == 0)) {
memmove(desta->haddr1, srca->haddr1, srca->size1);
if (unlikely(srca->size2)) {
memmove(desta->haddr2, srca->haddr2, srca->size2);
}
- } else if (srca->size1 < desta->size1) {
- diff = desta->size1 - srca->size1;
+ } else if (diff > 0) {
memmove(desta->haddr1, srca->haddr1, srca->size1);
memmove(desta->haddr1 + srca->size1, srca->haddr2, diff);
if (likely(desta->size2)) {
memmove(desta->haddr2, srca->haddr2 + diff, desta->size2);
}
} else {
- diff = srca->size1 - desta->size1;
+ diff = -diff;
memmove(desta->haddr1, srca->haddr1, desta->size1);
memmove(desta->haddr2, srca->haddr1 + desta->size1, diff);
if (likely(srca->size2)) {
--
2.31.1
- [PULL 01/33] tests/qtest/rtl8139-test: Make the test less verbose by default, (continued)
- [PULL 01/33] tests/qtest/rtl8139-test: Make the test less verbose by default, Thomas Huth, 2023/02/27
- [PULL 07/33] hw/vfio/ccw: Replace DO_UPCAST(VFIOCCWDevice) by VFIO_CCW(), Thomas Huth, 2023/02/27
- [PULL 08/33] target/s390x/arch_dump: Fix memory corruption in s390x_write_elf64_notes(), Thomas Huth, 2023/02/27
- [PULL 09/33] target/s390x/arch_dump: Simplify memory allocation in s390x_write_elf64_notes(), Thomas Huth, 2023/02/27
- [PULL 12/33] target/s390x: Use void* for haddr in S390Access, Thomas Huth, 2023/02/27
- [PULL 14/33] target/s390x: Remove TLB_NOTDIRTY workarounds, Thomas Huth, 2023/02/27
- [PULL 13/33] target/s390x: Tidy access_prepare_nf, Thomas Huth, 2023/02/27
- [PULL 10/33] target/s390x: Fix s390_probe_access for user-only, Thomas Huth, 2023/02/27
- [PULL 11/33] target/s390x: Pass S390Access pointer into access_prepare, Thomas Huth, 2023/02/27
- [PULL 15/33] target/s390x: Inline do_access_{get,set}_byte, Thomas Huth, 2023/02/27
- [PULL 16/33] target/s390x: Hoist some computation in access_memmove,
Thomas Huth <=
- [PULL 22/33] tests/tcg/s390x: Add bal.S, Thomas Huth, 2023/02/27
- [PULL 29/33] gitlab-ci.d/buildtest: Disintegrate the build-coroutine-sigaltstack job, Thomas Huth, 2023/02/27
- [PULL 19/33] target/s390x: Use tcg_constant_* for DisasCompare, Thomas Huth, 2023/02/27
- [PULL 20/33] target/s390x: Use tcg_constant_i32 for fpinst_extract_m34, Thomas Huth, 2023/02/27
- [PULL 24/33] configure: Add 'mkdir build' check, Thomas Huth, 2023/02/27
- [PULL 33/33] Deprecate the "-no-acpi" command line switch, Thomas Huth, 2023/02/27
- [PULL 32/33] gitlab-ci.d/base: Mark jobs as interruptible by default, Thomas Huth, 2023/02/27
- [PULL 21/33] target/s390x: Use tcg_constant_* in translate_vx.c.inc, Thomas Huth, 2023/02/27
- [PULL 17/33] s390x/pv: Add support for asynchronous teardown for reboot, Thomas Huth, 2023/02/27
- [PULL 23/33] tests/tcg/s390x: Add sam.S, Thomas Huth, 2023/02/27