From patchwork Mon Jan 9 20:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640694 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2340356pvb; Mon, 9 Jan 2023 12:22:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXWmCjRaVS+nK87ExMlgNpUK7xgEmJpfVZBBwFgQzDpRam0rsdpkJ3VdZtLpzbvJ5uwJkh X-Received: by 2002:a05:622a:244a:b0:3a8:27b9:5e18 with SMTP id bl10-20020a05622a244a00b003a827b95e18mr105106791qtb.67.1673295778022; Mon, 09 Jan 2023 12:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295778; cv=none; d=google.com; s=arc-20160816; b=SKx85jpmtwb7Hz/dBnDtd4EIzrda63+5Cg4hRiOBVAMfLhada2BJZ1Kxv4z5/n4xmo T4EpvWIbBoCl2tKeaNfcZpWZjbbfqReyXrN8z1+AaxvPBSGVE0fXycOzJNoYSM5lG2hU Ds0CD7/E7NFnPnri3c7O0ww3vdZnA49ExGUcrr1sdtFQsIgRqVXOgJ2FfghXvvnOYFyp 5zsgZeq2sF5NxZkoCpIOYBtekWHOC6QqXh+NCcw6vkn9U5xrle6dgICwz6g+AAd9DppQ 7rtVESgwXgEUNu8YT3LNzM4ojsZWVdV8LoK5DnpxU32a7T5L0R3ApzIfh04TyMIRaUI/ 8VeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WTZIs1C/js8Say6SBQT3RKsZE9PwWeX+MiQ9FxoXnQk=; b=Wby8eFJ/PC4zyGPs/NjBTVKZ7faK1D0ZSvPmaXEt7FiDGkRZoYOIhT0TT7sp313wh7 pLsWb7DN949Wos6JKC2yMHPX4+rg5odS8GRxO9aMZ1QnwSZjFfYcrIjMg4H5j04ppYTs coZE8mUtZWnska+FYSAl1Ok5vPU9VBER+oks5ftEZZaORAZyg0VM4BXwYA6hwCiY0FAh c4eqTC8sBjfQ7BNREizV2qvbPIItaAzej+9g0Usugao0iIFjgNWbFh9RCKS5ZWSSsTNF 6VKHW9rOzFs3VMOwHt6gOTgVy/+P+9i1ICrJkl2r3A6FNoZodW8tPPPW5H5qXw3Urjfg ZHQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QoAvLcUU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id br24-20020a05622a1e1800b003a52fda7dd8si5123500qtb.17.2023.01.09.12.22.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:22:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QoAvLcUU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybt-0005DQ-8D; Mon, 09 Jan 2023 15:19:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybr-00057m-LU for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:07 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybp-00052q-Ir for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:07 -0500 Received: by mail-pf1-x430.google.com with SMTP id 20so1660722pfu.13 for ; Mon, 09 Jan 2023 12:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WTZIs1C/js8Say6SBQT3RKsZE9PwWeX+MiQ9FxoXnQk=; b=QoAvLcUU0KM0M9KB6AUycHl6EDECQje+gHbahYD2rjoCGhHYhDAK/YGldxmUH73ZCF gnU02XvmvorXl8kRX0jvI/nvoLxlmTVGDEK8eAzOY6yp0eH7Ut44S1HDHKxI2HWkoz8T KlKz8cyAgFR0GyT5WxeIcStFM19rxGMhuKWDt6EiKziYTmFGddEgfTNQ5rN4rk5WWmaK FWysQuNVAZ+jv+goc1snhfwLx2CF7DwZVkZAAwIH2JH3R6RY4E9DDw1IXrbCB6nOGXoM fkouwCZh0IBaW7n/TCMysJPCN8j8ak+OQFqAIvs4lYkZhPuWrNZ/dgywfKf6IILFrytz ieug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WTZIs1C/js8Say6SBQT3RKsZE9PwWeX+MiQ9FxoXnQk=; b=Pf7qoGvGPIlRvnZDdRMMfv6GvflP+AR7xfD20LLKIvyTW2qrnK/E/G7RbQcAHSqm63 Jvb5cXRlnlJ6ieV4ToyjJQTOsNJpael80fi56cy115+sKtbd4hQU8/NSSXYO3rHHgCpE rP+RsDg3PnPj2BK0QBNWfl4o/waipprp+z/7JQ8sjsWWTfWLp/4pTcjbtwRqUMTxFUBL 8cqwvmCitBuoOdTX/XToGAKJbUITBIQ5LQomuLqnAk/ypvliSbxWF8clETOQ7p6tgJjc U3txPksvWEklN0Bs7WO9sm58Pe07oM2jJ+o/w50qITiLJjgCW5GPlU5YISfm2ApwSDAY WW1w== X-Gm-Message-State: AFqh2kovVpw9zLffSQODCPpy55PLUJTAMmRxV7XdScElUwlcP3pqTDCu i9S+XTvNpqlNyo1kuCoZHE/wNjdI5vnGhvE9 X-Received: by 2002:a05:6a00:1346:b0:581:c216:1390 with SMTP id k6-20020a056a00134600b00581c2161390mr53365972pfu.34.1673295544825; Mon, 09 Jan 2023 12:19:04 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:19:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 7/7] target/s390x: Hoist some computation in access_memmove Date: Mon, 9 Jan 2023 12:18:56 -0800 Message-Id: <20230109201856.3916639-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Ensure that the total length is in a local variable across the byte loop. Compute size1 difference once. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- 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 92eb6564c3..5f0dd67985 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)) {