From patchwork Fri Dec 14 03:19:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153728 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1605241ljp; Thu, 13 Dec 2018 19:37:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/XsrPy21cq/i8rrOzsF9SH7v9VRAt/7aRHvaL6W2qvWvJWwDQqHCllOpgZCMW3LJ8k2CDHS X-Received: by 2002:ac8:2ca9:: with SMTP id 38mr1310152qtw.338.1544758658053; Thu, 13 Dec 2018 19:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544758658; cv=none; d=google.com; s=arc-20160816; b=a0EbN4fS4JIa8aIjMS6f29b+zosruaF+Y5595ppg1UaOBA9eISslRHj/w7c9u5nxJo qhxZ6Z8HP8FvHkOfw8KG86GeTypQ+hNShGRFMRSgRuTQiNE9/a9Cg11f5RkcpcXYfJjw k1rqeh5U9CDN88Ef/i43tf301X8D3PF0ebXDfhQ/z3JuOHS7nXeEod685xev36n5/irf warrTSpiMy2Ri9s1Rh9mRuQhjmgcN9kUr4yniewLfu1/M+4kygVAtsurisZ25Po4Z025 BqRIUDISO1fuyiMvEZ8i0w0TAjrxpQObofzA8nV1SaKKMkWACFLM83wGECtSwgAWQnPy 25AQ== 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=t7t8Vgc4bfPxbw6BUTpqmuQGbw56/vmRzU1Z8OtQr3SWIw281P+9hmG0S15ntbcfQj XCO3iYJ24SjYSqOVRCb9aVrR4UTTyPUU3CEefaEFXDOO2veeGeJMYNcGD9kdRHDBZusa BFqNiWIMbdjSiEuNzREOhX1TcSaFhk6RL6hOXcTgyP8pOWtaS9eOw1my6UKQxeV5QAsP syzLIeiSwogUgJoJJ6puh/L6ssVmeLhxMv8r48B7+lg0LG17VwLoEhEMD2/1TZUATw1o +tv3UxFKI6Kn4lq306QVAmcBmpNS+5r3F/1pK2Bad9hEFutN8E+O+r8MgCTo/o/p5oAj lvpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Xx5AQVt/"; 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 r72si2173106qkl.162.2018.12.13.19.37.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Dec 2018 19:37:38 -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="Xx5AQVt/"; 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]:59144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXeID-0004Hx-H7 for patch@linaro.org; Thu, 13 Dec 2018 22:37:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXe1B-0006FR-1g for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:20:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXe18-0007YB-6Q for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:59 -0500 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]:37949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXe18-0007Mo-16 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:58 -0500 Received: by mail-ot1-x329.google.com with SMTP id e12so4121206otl.5 for ; Thu, 13 Dec 2018 19:19:54 -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=Xx5AQVt/vQ4LanDKHpHNiokfHeKWQmUBp+SODjI3xy7AjDzc09UjtdbZt6h/mS+kh9 RURZCbqM0SQG72GWaGfC4unDwI1PJXhCp2MsaZxB79ZPCr8rzQPwx5bgi13AWHdYZlWF i5/O69npJf25ZNK2Zw9j/FIMgCPkKyFdaN7Rw= 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=lbv7GnfWD+zq6XQYvxiduHSlHOYZzpw1MbJiARihBNPmW9WO51kI2bpVYAdRdZBtEz VAdJ+3pK59kwolZzzFkq1ndL7xXX186e+nErLJxD2WyzMq/rQSFnTZX70XvutBZ6pNYE DtL38Z3tPg/sfTnfORBpSV/jphFXajYf9UHVcKOo2X6KzhgqA+dJ/5s4hpSmGm9JImk6 5ZWVNkZcR1xpQyQsmo7S403s3nEssGaDHgQ+9RkWwaxwvPX+PccK5G9nasbz3P/PE5cr zzincr6H8n2akOyUJjkKzgaTw/dfpgRP3akw4z7XCsjqS3v/4G4eNdTDZg0cjT3kfzxB t3NA== X-Gm-Message-State: AA+aEWZV89jNZ521k0WA6ArvH+Cy+HZwr8v33jBsdOph1oOqZmKEYOxf tQGtRQ8kyc0+48agDQvSmKmNoUPkfgW0zQ== X-Received: by 2002:a9d:3ee4:: with SMTP id b91mr897407otc.79.1544757593188; Thu, 13 Dec 2018 19:19:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 19:19:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 21:19:15 -0600 Message-Id: <20181214031923.29527-26-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::329 Subject: [Qemu-devel] [PULL 24/32] 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: 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 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); } }