From patchwork Mon Aug 30 06:24:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 504311 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1520103jai; Sun, 29 Aug 2021 23:45:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoKxeVpYE4YYdVLJ4sqf9MnEtsel3elzolZ2gZjl/KpDK6OqY9JNlZjr4qolFXdsS/pDe0 X-Received: by 2002:a05:6638:2509:: with SMTP id v9mr7320132jat.95.1630305958406; Sun, 29 Aug 2021 23:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630305958; cv=none; d=google.com; s=arc-20160816; b=Wdm1c5NrGQbw65APEl2Js07yz1w+BBBzzArI+CVx1ije8rRggB5nJOjtO4gC0DsE2D LDpKpI/r5svW9y2qMLVgwFNCKsLLmmaFEiZ5ur+m+e/VLBN0AvZpylOlkT5eUIOaTs3a u1O6J0cAY79m3dh5LaE14RvCoCGH1fyKwRLFbzNbwbVXUVHLZdBgGdq8TibbvxUsFJBu 5ZJ6YTibajjRmMyepyfDOW+ruYAUvZQbjOOmb4mf3jSzoWN/KWZb9OksKsxPe2YNLyoa L/5D/QlOSKVMnd/Ne05Ot36wVx1cZ97S0EUkNrj8WViLjj1hqcDHyqALivAEidRbk4Bd WB/w== 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=qT3pJpxm/CMR3B4sc8UdNVvz1rKuoODGYwGab7PwTiE=; b=FdVMhvRwJGs+lqiLFrGuQV2EdNBdslpcNbs/6SevZuoFCrRmH7NSFXBSTe57R5VVfU M9rtKt9WUuolPIDwGm5VoTw9C2K66BhaMk7KgNwousEZblPjSrvOGZWOeI+GmdEusGT7 MnkE4+HmTbpLhkGhAUQCdajYktzHzduPq+7G/AvGYRmWXd2m4CVKyQ3xvjGlTX34ZvlS fQPxx+zMTTOep5hUGLdILtvR9hZJTanBTtAWiRqQXnd24VtdHeWmMachXtXnzgdfLWkq FinOKCJ2/lc14dJxB8fA++DrxtPp0wXS3ziKImdSgsmh3obJGJ8yWau5qp5WgLkxXunT roaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zrvJ0pS1; 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 y9si15117104ilu.22.2021.08.29.23.45.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Aug 2021 23:45:58 -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=zrvJ0pS1; 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]:53352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKb3N-0005Am-Rc for patch@linaro.org; Mon, 30 Aug 2021 02:45:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKajI-0004F8-KB for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:12 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:39770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKajH-0007bN-1I for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:25:12 -0400 Received: by mail-pl1-x62e.google.com with SMTP id m17so7933827plc.6 for ; Sun, 29 Aug 2021 23:25:10 -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=qT3pJpxm/CMR3B4sc8UdNVvz1rKuoODGYwGab7PwTiE=; b=zrvJ0pS1XyWGP7RZUGwQHdfP2rfh+DKezcq5NYoQKXLN8j9yolITAXSgOC1RqJi9e4 6r6vKFOcx27w+CqOOLMy7tBDU+HwHHLfh8rppQoI1B67+ZT9dkpDZ5nghEX567aNpoWk bYHaBQrD4vU9G5jIT3KignAScF+vLw7ywr7d47+erkMof/BLbWpaNynnid0HUI+1Wzau S7ZDfmGBi7GEH0UvKDu3y8KxiA0GlbeFMzULey70fOax/jO4XyCLsPT6Fa1Q7jGDsRS6 18N/No7yGCi6YSngxHxuH1FQr+vtnQfyq32px0Sq9IUZdgeKUHhHH7KHCQwpKYC0TDgM zpbw== 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=qT3pJpxm/CMR3B4sc8UdNVvz1rKuoODGYwGab7PwTiE=; b=CQ8aJBogIWOvFcdBgAG7VHCiN2jpgXuIfLuD/TMH+1/ytIhotkPt7vnMSnfbhY/UO2 9FCr2RkSX/x9VRQuAIAvT3M+zgpbo/ycF/ZjctrWgS84V804f4SM9bH2YwahsrHOejJQ fJR4kGgUmu9Z8jIIvjvcjjTHx3XUdXeJgC/VDUdTPLBHH4od5qyGpkk6qJibqTXmJoXy gllErxPOnrDKDJ0V7Iu1ZcK8BbSVjrUvQWCBe1chslfHtwCFbDVl4pylbHGxi/0vuGI+ kc3sJUjPJpyylUD86BJLU1h1OeVOQwrJxQ3SR+yZwN6kY3aHKHKwuk3oAieKkmS/UJSD wX8w== X-Gm-Message-State: AOAM530QmI+Ou+e0ZXTvEzOrCGWfEVxEgWdpwnfhk4zGiB+zw3qpGNv6 GdxAGLWYeMQTAjKWsKqwtjivVsVZa9PFgw== X-Received: by 2002:a17:90b:a48:: with SMTP id gw8mr38012348pjb.145.1630304709748; Sun, 29 Aug 2021 23:25:09 -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.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 23:25:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 26/48] tcg/optimize: Split out fold_count_zeros Date: Sun, 29 Aug 2021 23:24:29 -0700 Message-Id: <20210830062451.639572-27-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::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index 74c307951d..79e46fec23 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -875,6 +875,20 @@ static bool fold_call(OptContext *ctx, TCGOp *op) return true; } +static bool fold_count_zeros(OptContext *ctx, TCGOp *op) +{ + if (arg_is_const(op->args[1])) { + uint64_t t = arg_info(op->args[1])->val; + + if (t != 0) { + t = do_constant_folding(op->opc, t, 0); + return tcg_opt_gen_movi(ctx, op, op->args[0], t); + } + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]); + } + return false; +} + static bool fold_ctpop(OptContext *ctx, TCGOp *op) { return fold_const1(ctx, op); @@ -1726,20 +1740,6 @@ void tcg_optimize(TCGContext *s) } break; - CASE_OP_32_64(clz): - CASE_OP_32_64(ctz): - if (arg_is_const(op->args[1])) { - TCGArg v = arg_info(op->args[1])->val; - if (v != 0) { - tmp = do_constant_folding(opc, v, 0); - tcg_opt_gen_movi(&ctx, op, op->args[0], tmp); - } else { - tcg_opt_gen_mov(&ctx, op, op->args[0], op->args[2]); - } - continue; - } - break; - default: break; @@ -1764,6 +1764,10 @@ void tcg_optimize(TCGContext *s) case INDEX_op_brcond2_i32: done = fold_brcond2(&ctx, op); break; + CASE_OP_32_64(clz): + CASE_OP_32_64(ctz): + done = fold_count_zeros(&ctx, op); + break; CASE_OP_32_64(ctpop): done = fold_ctpop(&ctx, op); break;