From patchwork Mon Aug 30 06:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 504314 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1521473jai; Sun, 29 Aug 2021 23:48:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw06aS2O09hKSRV96dNENN/LPsg2ylhxe5QxM6dAWAc4nno0Q2Y3SOvMSneNqoY4nsf5qsE X-Received: by 2002:a05:6602:3404:: with SMTP id n4mr16957001ioz.45.1630306099134; Sun, 29 Aug 2021 23:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630306099; cv=none; d=google.com; s=arc-20160816; b=TBNy/SX5WVfN+JrWTN7j+TaATHc81bOjQfNH1DWZI2eEZeLe4fscx8IDj6wvapZMBs p0aQQx2lUvVK7tsh9A/Q7eD5jcR9JbnIiOozHLUmN5C1yMz1XXhRc5wy87im5IPd9e6J DALYuEawkIKxxVqNX6gj49jCwquhhP+cH03fS/f5CwWaxeKcDW9bnjTKhxWFZLm235Cm ZOEOs3B+2g/EZma2SkmuIykDR4kvSRc2rrNu8Dsmnf1svTJ4L+IppccDPtMkJ6ZW4CzK R5TUQfnT4lgxiStRHRODnemWOwIcMgB1YcyJ31fqg+wVhGLjh8H2ApwdWuelK1W4yjHT fo7A== 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:to:from :dkim-signature; bh=Kn4VA0Gfiy2fMT/+j/7s6nwywXz5CecsdEcFGy7JPD8=; b=QRULG+t2PzjZLw6sA+jFdqEHe/aj1zUz8P869JdXtTKJaXHZhd9Q+NCCaJLdszbvse zXOP2RvfP8IKsKukGBSdZmeiYtjI3zAUTYZoc0seQfELLHZ98bbqbv/LPKwRN1UgACa2 ZFILWEXCqEbtvEnuUslyweqAX2AnqaH5bRjtQIW6GVDyZoQE6R8xLzDvRioJe4O8N6ku Bj1Uair8hDu/djixQuk4dHGTr/RLYEmHiuobKW3BDgmxEfuVkmVOlzNNmKWoDSQ9jlZm Bso2I10yH2sr5Rcarny5q73kBBuHTfG8KjJlNUhlXTRf/Wdp0Rfgs87zOOI4PG2o9SCP OLhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pVvsADB+; 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 s1si13861674jat.65.2021.08.29.23.48.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Aug 2021 23:48:19 -0700 (PDT) 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=pVvsADB+; 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]:33552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKb5e-0002T8-IT for patch@linaro.org; Mon, 30 Aug 2021 02:48:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKajJ-0004Hg-CW for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:13 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:53866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKajH-0007c7-MM for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:13 -0400 Received: by mail-pj1-x102c.google.com with SMTP id j1so8746262pjv.3 for ; Sun, 29 Aug 2021 23:25:11 -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=Kn4VA0Gfiy2fMT/+j/7s6nwywXz5CecsdEcFGy7JPD8=; b=pVvsADB+4ng/k7U6ZSCRxFCc8/tX16PDK5hV+bXfspy7y4PXq13aETxxjAcb3/v4+U W+gHYNgwWp2pxJ1/etvix+AYV3bUlxl4DZgZSrUoI3/LhFGZv7yEaSPu3g9zGpFJIy0v OukEv2fbgrw3lDgtmGCs9psOW5DRsMBaLyEGUjq1z0B0ZRX8DKLnkPTgMacnjR5acMi3 wF7zipIbVD1bgQ546dWAPWHglfub+BP2kvmQTyNEJeUbg0mV32i7OAaQcBd8vf7mr2h7 KhKR3eFCHO3Pl1pstFR7GzctF6SlPiJSlAYYmTL/dtC51NnfHiAxAvj7YaUZGioDSmnw hFkQ== 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=Kn4VA0Gfiy2fMT/+j/7s6nwywXz5CecsdEcFGy7JPD8=; b=QbR/jKQuz/CwjCn2IHuIqK4FDQGGP8OnaE1ci7WLYVnVyZ+7XyCP9cIZXqcnw5Z8go 0Eq6xQf0wQfCdknUMeOo0c3E2QXzUGJNpL2MKDs/UeULVIQpg7G9Bb58ceFK6NaN/NAR HDLDhNWeIPAJolGP6ee4aPUa701JTHsN5mzCG9SlPC+y9NfDIBoiSAD3zy0AlhdCtwQc OcABNSokR9Y0UOIoIAA7gVt+HYs5C+30ymDZ2T/VJ8P+/pJQTPIFGzpEBKaqTSZoUdLh x5LlMbge9304BovolU/+SQyKHz+8uZVSF8Odibgd8O7pqpzeFtRUDfjiSLWzf/dLS5Sm ebug== X-Gm-Message-State: AOAM5334bOQTv3jdvMIIR1S6MSzFmc29BycDLaRZS6hVDasBAGIwv/iQ 2yfS6t2IAz6h3pXjPec8Rf8Y4TZ9umNf8Q== X-Received: by 2002:a17:90a:4316:: with SMTP id q22mr37787512pjg.151.1630304710386; Sun, 29 Aug 2021 23:25:10 -0700 (PDT) Received: from localhost.localdomain (174-21-72-39.tukw.qwest.net. [174.21.72.39]) by smtp.gmail.com with ESMTPSA id b12sm13942084pff.63.2021.08.29.23.25.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 23:25:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 27/48] tcg/optimize: Split out fold_bswap Date: Sun, 29 Aug 2021 23:24:30 -0700 Message-Id: <20210830062451.639572-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830062451.639572-1-richard.henderson@linaro.org> References: <20210830062451.639572-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/optimize.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/optimize.c b/tcg/optimize.c index 79e46fec23..1366bbaa17 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -843,6 +843,17 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) return true; } +static bool fold_bswap(OptContext *ctx, TCGOp *op) +{ + if (arg_is_const(op->args[1])) { + uint64_t t = arg_info(op->args[1])->val; + + t = do_constant_folding(op->opc, t, op->args[2]); + return tcg_opt_gen_movi(ctx, op, op->args[0], t); + } + return false; +} + static bool fold_call(OptContext *ctx, TCGOp *op) { TCGContext *s = ctx->tcg; @@ -1729,17 +1740,6 @@ void tcg_optimize(TCGContext *s) } break; - CASE_OP_32_64(bswap16): - CASE_OP_32_64(bswap32): - case INDEX_op_bswap64_i64: - if (arg_is_const(op->args[1])) { - tmp = do_constant_folding(opc, arg_info(op->args[1])->val, - op->args[2]); - tcg_opt_gen_movi(&ctx, op, op->args[0], tmp); - continue; - } - break; - default: break; @@ -1764,6 +1764,11 @@ void tcg_optimize(TCGContext *s) case INDEX_op_brcond2_i32: done = fold_brcond2(&ctx, op); break; + CASE_OP_32_64(bswap16): + CASE_OP_32_64(bswap32): + case INDEX_op_bswap64_i64: + done = fold_bswap(&ctx, op); + break; CASE_OP_32_64(clz): CASE_OP_32_64(ctz): done = fold_count_zeros(&ctx, op);