From patchwork Fri Dec 14 03:19:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153732 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1606800ljp; Thu, 13 Dec 2018 19:40:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xiv3sTdJftaj8o7QmYIh5RxWhoA8pfOb2KGqkZMjDuitjBo9XJq4M37Jnpvq5sz0E+WkI3 X-Received: by 2002:ae9:ed13:: with SMTP id c19mr1157286qkg.85.1544758825139; Thu, 13 Dec 2018 19:40:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544758825; cv=none; d=google.com; s=arc-20160816; b=fC6iWzOga6ruIptBJoJQTPltQxAYRjTlF9mSwsoUEcJu+pMrlYDZWoh4WhNrOnXToc ILpGFImhJ/wxtMxOk8UOGSu9BOM1Otr5myWXAjl4Vl692PPsVu2zHQFLUhcMB6H+3TsF u6njB751xvh2TLBYdwpi1QhKw36mALnKMIKVsFTr/A0LX+OSsW/7O7EzOR6WKlOxtSCO ZF6Ruj7S03A4sNkIBor9yjD6kBLZEWIdj4m3dZvjJ+GfNMYdl0skHQpYkcsCCUx2KPT1 aMvs1swx+KiZr7fa5bOus51uD44wa+IpwOjggjXbYNEKDBBrnIGe4cuwWRTeWaAtJZSl Fu6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZdFhnUufyrFc19z7ViZt8Wb0ZHqiPUdjffxN+QTai+8=; b=OQifk5fujkQIMu/PvhsSQASA+F6a//2Neog/gkDZVmA7DOgrE2ZKrzMCD/wz9IicOI Z2gK7XxEUvkk21RNntHIeO0qC32Ff5b4t0gKmXYHowUwJ1s/oAQZbTxSWHDwIZgARXTi 2n6CukO+smpK09OcYxs14317/fEv48PNc+c6V2mrizo8MZ0QzykyFU8zDS76UMmMXbrH uDGVyUF5vaVcboN6yVrzq5XszKh8qn73LJ2qw/Z7WpF426pRliYV5eT9lRpk//9KwAHK 87T2XSsIJ7CPRdsEFuLO5B+vq9QwNwtcZaAwHb8oOoNI0vyamYXz/7Zh6M5fs7si4K9v 1L9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ab0xZM5+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c198si2193264qke.267.2018.12.13.19.40.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Dec 2018 19:40:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ab0xZM5+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXeKu-0007Hw-Kh for patch@linaro.org; Thu, 13 Dec 2018 22:40:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXe1C-0006Gd-63 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:20:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXe1B-0007fY-1q for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:20:01 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]:37718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXe18-0007KD-O1 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:59 -0500 Received: by mail-ot1-x32c.google.com with SMTP id 40so4122092oth.4 for ; Thu, 13 Dec 2018 19:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZdFhnUufyrFc19z7ViZt8Wb0ZHqiPUdjffxN+QTai+8=; b=Ab0xZM5+p7jt2C1eY6xTAYgj/nyCM9kJ43gpeMnw+PGQtrjCveEnR2/NHhIwy8ro35 h9PQ2d0mZaU4kjX9GmWUfq0kY1MPNjm1ShF+1OBm0+zi9VG5PDrrDC2aG9ViUeU1lzwY 89xSsgQxMyMEWeJlKwzjiAq/eLJkfaPnG72p8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZdFhnUufyrFc19z7ViZt8Wb0ZHqiPUdjffxN+QTai+8=; b=KyOANR+T1dE54bud+YDnXGOq0dwJ8ycF9lc0+lT5npv21cEwBAdUJdX1WCiXMymriq mYRsRrf3u+qlDsdPIyEmdtCaLnHL2K1B+3rCVGNIsv6/rPZnc9Xor4Q1zc5dP+2uG4ip OrUXKEbiJ9jij4xAmOaUrJLAEHHEqtKl2GWyBIhpQr3HK1FRMbLREST/3WzXX0bxHNGs NPqRINn96i4yTd6UzAJ4Km+d63umNo+Dzx7UkhBW8hSpX+eE0CzWVRWBEadxXwB/YZAL HPoOtJOcp1TfVTlUWEDmdDfvHi1KPeAn6rJDZWuMROYz4HuUrzrdIIAx3ygEGGdRIQ3A nzAQ== X-Gm-Message-State: AA+aEWbMSqx9DOJANS+C+kjmHGS2W34aaAWvS0q5rpM8NS8oojW+CKIj OgeLJFpAhUMaYnD+gfar/OGECxNSthovHQ== X-Received: by 2002:a05:6830:1204:: with SMTP id r4mr1034296otp.101.1544757592168; Thu, 13 Dec 2018 19:19:52 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id g138sm2367537oib.26.2018.12.13.19.19.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 19:19:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 21:19:14 -0600 Message-Id: <20181214031923.29527-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181214031923.29527-1-richard.henderson@linaro.org> References: <20181214031923.29527-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::32c Subject: [Qemu-devel] [PULL 23/32] tcg: Clean up generic bswap32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Based on the only current user, Sparc: New code uses 1 constant that takes 2 insns to create, plus 8. Old code used 2 constants that took 2 insns to create, plus 9. The result is a new total of 10 vs an old total of 13. Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 54 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) -- 2.17.2 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 7a8015c5a9..a956499e46 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1012,22 +1012,22 @@ void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) if (TCG_TARGET_HAS_bswap32_i32) { tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg); } else { - TCGv_i32 t0, t1; - t0 = tcg_temp_new_i32(); - t1 = tcg_temp_new_i32(); + TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_const_i32(0x00ff00ff); - tcg_gen_shli_i32(t0, arg, 24); + /* arg = abcd */ + tcg_gen_shri_i32(t0, arg, 8); /* t0 = .abc */ + tcg_gen_and_i32(t1, arg, t2); /* t1 = .b.d */ + tcg_gen_and_i32(t0, t0, t2); /* t0 = .a.c */ + tcg_temp_free_i32(t2); + tcg_gen_shli_i32(t1, t1, 8); /* t1 = b.d. */ + tcg_gen_or_i32(ret, t0, t1); /* ret = badc */ - tcg_gen_andi_i32(t1, arg, 0x0000ff00); - tcg_gen_shli_i32(t1, t1, 8); - tcg_gen_or_i32(t0, t0, t1); + tcg_gen_shri_i32(t0, ret, 16); /* t0 = ..ba */ + tcg_gen_shli_i32(t1, ret, 16); /* t1 = dc.. */ + tcg_gen_or_i32(ret, t0, t1); /* ret = dcba */ - tcg_gen_shri_i32(t1, arg, 8); - tcg_gen_andi_i32(t1, t1, 0x0000ff00); - tcg_gen_or_i32(t0, t0, t1); - - tcg_gen_shri_i32(t1, arg, 24); - tcg_gen_or_i32(ret, t0, t1); tcg_temp_free_i32(t0); tcg_temp_free_i32(t1); } @@ -1638,23 +1638,23 @@ void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) } else if (TCG_TARGET_HAS_bswap32_i64) { tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg); } else { - TCGv_i64 t0, t1; - t0 = tcg_temp_new_i64(); - t1 = tcg_temp_new_i64(); + TCGv_i64 t0 = tcg_temp_new_i64(); + TCGv_i64 t1 = tcg_temp_new_i64(); + TCGv_i64 t2 = tcg_const_i64(0x00ff00ff); - tcg_gen_shli_i64(t0, arg, 24); - tcg_gen_ext32u_i64(t0, t0); + /* arg = ....abcd */ + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .....abc */ + tcg_gen_and_i64(t1, arg, t2); /* t1 = .....b.d */ + tcg_gen_and_i64(t0, t0, t2); /* t0 = .....a.c */ + tcg_temp_free_i64(t2); + tcg_gen_shli_i64(t1, t1, 8); /* t1 = ....b.d. */ + tcg_gen_or_i64(ret, t0, t1); /* ret = ....badc */ - tcg_gen_andi_i64(t1, arg, 0x0000ff00); - tcg_gen_shli_i64(t1, t1, 8); - tcg_gen_or_i64(t0, t0, t1); + tcg_gen_shli_i64(t1, ret, 48); /* t1 = dc...... */ + tcg_gen_shri_i64(t0, ret, 16); /* t0 = ......ba */ + tcg_gen_shri_i64(t1, ret, 32); /* t1 = ....dc.. */ + tcg_gen_or_i64(ret, t0, t1); /* ret = ....dcba */ - tcg_gen_shri_i64(t1, arg, 8); - tcg_gen_andi_i64(t1, t1, 0x0000ff00); - tcg_gen_or_i64(t0, t0, t1); - - tcg_gen_shri_i64(t1, arg, 24); - tcg_gen_or_i64(ret, t0, t1); tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); }