From patchwork Thu Oct 21 21:05:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516090 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp341214imj; Thu, 21 Oct 2021 14:26:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr5PtB4eMxOjWuPh6pMgsq2Cyz3PnJXyB3uVGZgV04dAiZyzZ8pXe+jYThlnvl6Jh3ixFM X-Received: by 2002:ab0:4adc:: with SMTP id t28mr9518221uae.4.1634851587938; Thu, 21 Oct 2021 14:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634851587; cv=none; d=google.com; s=arc-20160816; b=Q8xiz9nCQj4UsrQyuWio7kkS2uxITDl5VFqkT112vdYBbgkkoKwfFcRi0921R4vROw 7XPKDOYc4eKEdWpSHERBhjttqgp78avxu3MBp84QqnYjN1yA5TO9TGOf3sjEAHq+JA0A vcYJLPsomt/luu7kE5E1KmEKEnZDNcpoWMVFXoFnGGh1L42aNcvCbhT9J6jJBOnb0sj7 nGIsB6YgAhnskiJINvix7sEljb65126gWf2IomF62AnMHNdf6tY9MAPPBvK0N72TVfSu /oGButWpzpDxUPygCjsuOHj4DktJV4TIaEil9KkC1iAePGpzMmAKWH8q8c8VO6RKY41q HgTg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=92C7m0Qw6lhImsxb8iBceS142UxxpCSN6cHa6VVF6VA=; b=wRdjyt3CcAU364bw80Ty5TH5MWkLLTywByFc7y8rDVTgOABYx6F6iCtfiFiY0wERi7 Jxk+cyJ7+cGCFNjAjpuX2ThUbHmtacBebpmZvN2HjOHGTyPWyGnk4fmgXOIKyhGYeGjQ M97rYI5TTGrG9mZPn9x8nEhYWjE/pKV5100VGdlRM31R6TNfsMqw/L5a+odINZR29GSL JYHLJVA44WLLwOhmMOWwTIysPJt3s/fPWnbKJEY9r/yuJyNvp8FwvHs8Fcf2H2/DQKQX ByLR5LuXGb7nkY44Ml8RrpfFnxbzMtbz5CBkvNB7x0JFVaNF1r2N1RzfCdrJI842Fsmb +ffg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MivuJ0Gx; 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=fail (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 v15si6965079vso.140.2021.10.21.14.26.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Oct 2021 14:26:27 -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=fail header.i=@linaro.org header.s=google header.b=MivuJ0Gx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdfZz-00065R-6F for patch@linaro.org; Thu, 21 Oct 2021 17:26:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdfGI-0007eA-8F for qemu-devel@nongnu.org; Thu, 21 Oct 2021 17:06:07 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:41983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdfGD-0004On-Mh for qemu-devel@nongnu.org; Thu, 21 Oct 2021 17:06:05 -0400 Received: by mail-pl1-x62c.google.com with SMTP id e10so1275677plh.8 for ; Thu, 21 Oct 2021 14:06:01 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=92C7m0Qw6lhImsxb8iBceS142UxxpCSN6cHa6VVF6VA=; b=MivuJ0GxTE6P4EqmoLtzgDHGTGoLemMz6Au2L14um892aZLfWaCiZf0FMvjJT+VcOs XyE73hsT/yoctWm7+jZpVYHtYrOoGnUF9hyoZbLgJPkS94F/ayrS2UgqpcayhBMRL89G pGNLXtR+fNjA9+XbeE8HvvfO2yVCMVPG5WpW2nbyqr8YIi+gsDuAi0unDgTyqKesbLVb vmexEtOrRGJ1eCOR8kRFGoRmOLrOna9LPMsCMlh7yNSdhyjX0N3fYDuknVBKpG7hTFIs 9yZldomPZX0mD7BcC+xqmVVCdBr9Zqbw7hzTPJ38ofZGj7rtqqtBPZ2jRCjKxp3uS6W5 uqFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=92C7m0Qw6lhImsxb8iBceS142UxxpCSN6cHa6VVF6VA=; b=LGyJ8cPx4NTm0+7u4YjXr7R3FddDiConAGXxeLe4DuZzhMxxWUJPZbrV6vk3dFh+d7 JfEa35tmCtJWyl7IRYQAN8wavEZ7bNyZz8YnjvF842synM8Liq6i/ZuyVCKrWRAA81i9 tJovchCuEL7PLeAKgHWoT/0ebE2bixypXF6+nMiT1dpfMocG/0X/QwnLbY4szuqHLdQQ K62mHVm1Ule+3dyM7W97djpAhifIozTDWo7spoELPWsU2MVsKRScsliwTKR0Z4FH+5mw kngtzBzO9ov1n8EEhdBDLw3mZ+GcKPDMaUKlFXdMVCSlQGmrSErU1r4JSdRokqio3ZaY XWGQ== X-Gm-Message-State: AOAM5322Li2CVdvzOv+CP3oVTwlt267JXsCFAKICLxP/b8L5WTI6aUO1 OZk9XfyI3R2xdbiVwF2W1ijG5xFV7UHs3A== X-Received: by 2002:a17:90b:110d:: with SMTP id gi13mr9442423pjb.1.1634850360398; Thu, 21 Oct 2021 14:06:00 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id g7sm5981670pgp.17.2021.10.21.14.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:06:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 27/48] tcg/optimize: Split out fold_bswap Date: Thu, 21 Oct 2021 14:05:18 -0700 Message-Id: <20211021210539.825582-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021210539.825582-1-richard.henderson@linaro.org> References: <20211021210539.825582-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: , Cc: luis.pires@eldorado.org.br, alex.bennee@linaro.org, =?utf-8?q?Philippe?= =?utf-8?q?_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) -- 2.25.1 Reviewed-by: Luis Pires diff --git a/tcg/optimize.c b/tcg/optimize.c index c54f839434..77b31680f1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -841,6 +841,17 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) return false; } +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; @@ -1727,17 +1738,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; @@ -1762,6 +1762,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);