From patchwork Fri Nov 23 14:45:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 151899 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2230513ljp; Fri, 23 Nov 2018 07:05:23 -0800 (PST) X-Google-Smtp-Source: AJdET5fDf7bq3XHzYg6Yl2cY/dI/wPU3xEmWvrwBZGrrGEmu1WumOaOkQhG5LQC5riVJZShgcNUg X-Received: by 2002:a81:a1c2:: with SMTP id y185mr16283218ywg.323.1542985523110; Fri, 23 Nov 2018 07:05:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542985523; cv=none; d=google.com; s=arc-20160816; b=H+a+KEUUTpvzBArQeP8VGUEasqbw00SoNm3nu8UBQugnGkMyXAAtCis5kYz3M97xOB ZXCpWI4J9AJ86+bhQu1oE+xMmpUiBDU4mhnJDuqFAj7iSPqDiDzWjxtrxngn+Q997Uq/ 6dueJ/JMqvXSCEjpMIxKGmyFQkvssowfX73Lryb5ZdmDbq3dH1atrdymS0HlGSW3mxpk InAKutKZ6IsSLMwGy8hloxVGrUAqTItTP1kczJVpQzPNbv8YxpukhHxptzx8h89tyGyk pehqkneEWLSm840nFnzI70d7oNMUsuOSfrfSBeMQLnrpNEJO6tS6rGQf2XnIrt4xJPSJ LKkQ== 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=U/S7zmMlyfjLiA6mFcj5+nW10ojCNetN9JvrDZkZZc8=; b=v2XZMJLTwJL2xZP/F3YBgPq+MggWle9LJd/MNVoP4NotJDoG012lN4/L4hhV2Vgfua 3P3WhTp2ZJjJhRLZQ0C9HZXtv+EmXHxIfG34ViCXAAA7MxbrFESSm5laRwSmHHnIYlKQ OCS4IRILse99hDDHFOMbrzcHVIhTQmy8J7rTGp6+3BfTPV9ZPv5C0FUgOBLd8oPhkNIU XcSqVFKQWspmcCrPr66DCv5lxCrFXp6EiUTWJkb/zyW6IP6RZ6WrAVA/vCuA7AX7IzT5 PTKlxe2OfaP9bKGlLHyGJdRfApgs3l7ib8X3EvAT61ujUPs77s+0YQrR4sgwJmxoG6N5 c+iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eVx5hERW; 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 s4-v6si10351405ywd.283.2018.11.23.07.05.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 23 Nov 2018 07:05:23 -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=eVx5hERW; 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]:52863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQD1G-0001M7-95 for patch@linaro.org; Fri, 23 Nov 2018 10:05:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQCj1-0000EH-Mb for qemu-devel@nongnu.org; Fri, 23 Nov 2018 09:46:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gQCiz-0003da-OJ for qemu-devel@nongnu.org; Fri, 23 Nov 2018 09:46:31 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gQCiy-0003ZO-0I for qemu-devel@nongnu.org; Fri, 23 Nov 2018 09:46:29 -0500 Received: by mail-wr1-x444.google.com with SMTP id z5so8281528wrt.11 for ; Fri, 23 Nov 2018 06:46:27 -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=U/S7zmMlyfjLiA6mFcj5+nW10ojCNetN9JvrDZkZZc8=; b=eVx5hERWeDN6cgl78AOSxjgjzuKL148atgXH5RpR62+L73c69Z2Zso0t9eoEJVHFph tSSq00gMokiBDw12PVrHktM4GMWvMdxebx5fe2YIjKB8nCeZ/CvtxcyTIxwN99TXhofj zmPoZzIa1YIBcxZOPMMXeo4SyPH30RUhU9pYY= 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=U/S7zmMlyfjLiA6mFcj5+nW10ojCNetN9JvrDZkZZc8=; b=OsYpC/3hG7GwMyfCxHmQi0YGF82B5iQNI3UP3DUw5Wqt451O//oZ4axC9OKq1WEYnZ 1xTCN1gc5m8iWU/BzUMfkYgvFz8BqzsmnNCYvpN9vLyQ4pXYvAb8fzomvjYsfLD42aZ6 bJ6UGNEusexIRkLcQPIkEudkPzI1UNVWTdgu2NMEskZu3cE2JDTi/6nqCTd/BcyvTOXf MQrw3ZLsDx/j6NAvrpDADcg4dnj/oPbWkRhxvjBhnRAm5VeMeA0EtyyFOzNuD+2Ss3Rl RmpOOs/pDIf6yfxiq9gyO3Jd1bbS0jHY2lhuYpodD2V1hwJzf2XNXKRUIa8kKqkc5pv/ ly9g== X-Gm-Message-State: AA+aEWbPSxSmfjEEhJDvgLKZEVEjaE2j6qLkKuX+g5qxI+b62tAQMgJn 8kK4lxiYuUun9CipwOpKeiv0/2HSV6Zj4g== X-Received: by 2002:adf:fa91:: with SMTP id h17mr15253153wrr.320.1542984386577; Fri, 23 Nov 2018 06:46:26 -0800 (PST) Received: from cloudburst.twiddle.net ([195.77.246.50]) by smtp.gmail.com with ESMTPSA id p74sm10339630wmd.29.2018.11.23.06.46.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 06:46:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 23 Nov 2018 15:45:48 +0100 Message-Id: <20181123144558.5048-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181123144558.5048-1-richard.henderson@linaro.org> References: <20181123144558.5048-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH for-4.0 v2 27/37] tcg: Clean up generic bswap64 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: Alistair.Francis@wdc.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Based on the only current user, Sparc: New code uses 2 constants that take 2 insns to load from constant pool, plus 13. Old code used 6 constants that took 1 or 2 insns to create, plus 21. The result is a new total of 17 vs an old total of 29. Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) -- 2.17.2 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index a956499e46..887b371a81 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1678,37 +1678,30 @@ void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) } else { TCGv_i64 t0 = tcg_temp_new_i64(); TCGv_i64 t1 = tcg_temp_new_i64(); + TCGv_i64 t2 = tcg_temp_new_i64(); - tcg_gen_shli_i64(t0, arg, 56); + /* arg = abcdefgh */ + tcg_gen_movi_i64(t2, 0x00ff00ff00ff00ffull); + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .abcdefg */ + tcg_gen_and_i64(t1, arg, t2); /* t1 = .b.d.f.h */ + tcg_gen_and_i64(t0, t0, t2); /* t0 = .a.c.e.g */ + tcg_gen_shli_i64(t1, t1, 8); /* t1 = b.d.f.h. */ + tcg_gen_or_i64(ret, t0, t1); /* ret = badcfehg */ - tcg_gen_andi_i64(t1, arg, 0x0000ff00); - tcg_gen_shli_i64(t1, t1, 40); - tcg_gen_or_i64(t0, t0, t1); + tcg_gen_movi_i64(t2, 0x0000ffff0000ffffull); + tcg_gen_shri_i64(t0, ret, 16); /* t0 = ..badcfe */ + tcg_gen_and_i64(t1, ret, t2); /* t1 = ..dc..hg */ + tcg_gen_and_i64(t0, t0, t2); /* t0 = ..ba..fe */ + tcg_gen_shli_i64(t1, t1, 16); /* t1 = dc..hg.. */ + tcg_gen_or_i64(ret, t0, t1); /* ret = dcbahgfe */ - tcg_gen_andi_i64(t1, arg, 0x00ff0000); - tcg_gen_shli_i64(t1, t1, 24); - tcg_gen_or_i64(t0, t0, t1); + tcg_gen_shri_i64(t0, ret, 32); /* t0 = ....dcba */ + tcg_gen_shli_i64(t1, ret, 32); /* t1 = hgfe.... */ + tcg_gen_or_i64(ret, t0, t1); /* ret = hgfedcba */ - tcg_gen_andi_i64(t1, arg, 0xff000000); - tcg_gen_shli_i64(t1, t1, 8); - tcg_gen_or_i64(t0, t0, t1); - - tcg_gen_shri_i64(t1, arg, 8); - tcg_gen_andi_i64(t1, t1, 0xff000000); - tcg_gen_or_i64(t0, t0, t1); - - tcg_gen_shri_i64(t1, arg, 24); - tcg_gen_andi_i64(t1, t1, 0x00ff0000); - tcg_gen_or_i64(t0, t0, t1); - - tcg_gen_shri_i64(t1, arg, 40); - tcg_gen_andi_i64(t1, t1, 0x0000ff00); - tcg_gen_or_i64(t0, t0, t1); - - tcg_gen_shri_i64(t1, arg, 56); - tcg_gen_or_i64(ret, t0, t1); tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); + tcg_temp_free_i64(t2); } }