From nobody Thu Oct 31 00:23:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1623660394; cv=none; d=zohomail.com; s=zohoarc; b=PtCsdM15aNL4v9mA5dXNGXQdJczDfk5kMpxXX3pdFIVwTwNVGMXB9CEDeXN67S3qkDNkQF9HXRIu9XKPD+IVRenu/NgzXShSDdZv7XY4yPRXeh+q5qb4mC9Sf/bWU0n0g0UQYETUKD0B24xhqsZ9wk9SPEyRSweoy4ZMGSmSJOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623660394; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RmJRRsSQCfFpzMnGvbeflLavjd8sak/ufPXwSJZUO4k=; b=AH4yvm1U00cZ2L2Dr4uXtBIjbQf9umkodiSNX0Z8NzuiYC3DmszjUVsYXzChNSspnaBwTsnt1900CJ6AUWoF0eO2Pd4/clgIuXEiDGEvVxim/GLSXdAgx20jw2KlBOjQiYhvNnswM4vRJLijMaCTl/1IYLq4fo3tBkpV7hB8/HI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623660394425943.6496768804966; Mon, 14 Jun 2021 01:46:34 -0700 (PDT) Received: from localhost ([::1]:34926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsiEr-0001oc-5a for importer@patchew.org; Mon, 14 Jun 2021 04:46:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsi6r-0002Cc-I4 for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:18 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:38423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsi6h-0003WA-7H for qemu-devel@nongnu.org; Mon, 14 Jun 2021 04:38:17 -0400 Received: by mail-pj1-x1030.google.com with SMTP id m13-20020a17090b068db02901656cc93a75so9600594pjz.3 for ; Mon, 14 Jun 2021 01:38:06 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id h20sm2242022pfh.24.2021.06.14.01.38.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 01:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RmJRRsSQCfFpzMnGvbeflLavjd8sak/ufPXwSJZUO4k=; b=e6NRlOWjJEoa0MCTC1H93fuvJ6hi19fzTMbTZa2kn6d/HnTvIyTvyLTzZcvOz8yArs FjLFTblo0JGUi7kg06Z5oKOFGDWeSWqBVHrzsY+Kwaq+PU8KkYoIK06epYL7/CrEBfOF fZFGG6oCv1IwujY8O+8fxrgNCN+Nl9fgfnT+xfOhINbBdx2juPGdl/Vn+EaBsFff0Fe0 Av4hluWFpawitsq5OlUwQC019bHUT4QV+jjKuj6B+pp/ANIJtYul1Gg7z2yL8SOrdwRk xGvUDmZhYssnW4I0gjFRIyrtLuuMcqm4oLnR/QmeekbKTTsXAUr6aiMK7suJNK5pjYu5 8R2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RmJRRsSQCfFpzMnGvbeflLavjd8sak/ufPXwSJZUO4k=; b=TbWF0I/VQPn8me2KqLElhsj2MUGSoTavL2FNQ+gdnupdWmEAritReLJPP42xX27BQp ZQDHDohgZP27QjhfHVLnuTfrEOOAlA9K0kBUzUl1FDzwUfyNZleMczmZrn0gy5RRV+m1 zN/2HnHwcY/cDvOVp10ROC0lFfFG8c8nu0Vu3oR2TdVbzIrmUlFOX1gX3ptpp+UalYV+ NX4hj+UPd7wTLQsASG+8UQwEfJYmOP15DBXlOTFws8+ORXpfs5IVEp8gMRYsxHzwF2Z9 uiMx/zbJdh00fetE4s/QAbnz4wSiNhF22seShSgkyg9H2PXZLNpgS7GPOkBtcdriXIgn bPjw== X-Gm-Message-State: AOAM531JoDWUQJbWneNRkR9zvPq9K0U5r5T4bdNCYxraKS8A0xtXoqE6 FfLKMejq7JEB1eozNJUxBk5kFq45vR+jcw== X-Google-Smtp-Source: ABdhPJwM6iG7hD9H01F1W8Y0NmPJcwQCxF4OyS8t2bQsKnH0TPnShwA5I0xuvuU0ZktbBwSIonWhpA== X-Received: by 2002:a17:90b:4f83:: with SMTP id qe3mr22611280pjb.32.1623659885654; Mon, 14 Jun 2021 01:38:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/28] tcg/ppc: Split out tcg_out_bswap16 Date: Mon, 14 Jun 2021 01:37:39 -0700 Message-Id: <20210614083800.1166166-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614083800.1166166-1-richard.henderson@linaro.org> References: <20210614083800.1166166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" With the use of a suitable temporary, we can use the same algorithm when src overlaps dst. The result is the same number of instructions either way. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- tcg/ppc/tcg-target.c.inc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index b49204f707..64c24382a8 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -788,6 +788,16 @@ static inline void tcg_out_sari64(TCGContext *s, TCGRe= g dst, TCGReg src, int c) tcg_out32(s, SRADI | RA(dst) | RS(src) | SH(c & 0x1f) | ((c >> 4) & 2)= ); } =20 +static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src) +{ + TCGReg tmp =3D dst =3D=3D src ? TCG_REG_R0 : dst; + + /* src =3D abcd */ + tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31); /* tmp =3D 000c */ + tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23); /* tmp =3D 00dc */ + tcg_out_mov(s, TCG_TYPE_REG, dst, tmp); +} + /* Emit a move into ret of arg, if it can be done in one insn. */ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long ar= g) { @@ -2779,21 +2789,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: - a0 =3D args[0], a1 =3D args[1]; - /* a1 =3D abcd */ - if (a0 !=3D a1) { - /* a0 =3D (a1 r<< 24) & 0xff # 000c */ - tcg_out_rlw(s, RLWINM, a0, a1, 24, 24, 31); - /* a0 =3D (a0 & ~0xff00) | (a1 r<< 8) & 0xff00 # 00dc */ - tcg_out_rlw(s, RLWIMI, a0, a1, 8, 16, 23); - } else { - /* r0 =3D (a1 r<< 8) & 0xff00 # 00d0 */ - tcg_out_rlw(s, RLWINM, TCG_REG_R0, a1, 8, 16, 23); - /* a0 =3D (a1 r<< 24) & 0xff # 000c */ - tcg_out_rlw(s, RLWINM, a0, a1, 24, 24, 31); - /* a0 =3D a0 | r0 # 00dc */ - tcg_out32(s, OR | SAB(TCG_REG_R0, a0, a0)); - } + tcg_out_bswap16(s, args[0], args[1]); break; =20 case INDEX_op_bswap32_i32: --=20 2.25.1