From patchwork Fri Dec 20 04:10:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852368 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1852780wrq; Thu, 19 Dec 2024 20:16:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUNNL+tF0lFnaWSLnMnzUhMyVPOP8BkRvN1HbGMqZhsDM6m14k/rJLJ2ya7zh0bnakuRiwkiQ==@linaro.org X-Google-Smtp-Source: AGHT+IGZYPXhkPYnKJYg8Wo9IV0+dzqLcS2p/DzU6ndluh29uY3EUyGUxFXjYxalva6RgknXAJsN X-Received: by 2002:a05:620a:191c:b0:7b6:dd9c:fac1 with SMTP id af79cd13be357-7b9ba7f562fmr228735785a.49.1734668173410; Thu, 19 Dec 2024 20:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734668173; cv=none; d=google.com; s=arc-20240605; b=PDOonkI6OEzobOQ2QAfQNHJIhvHSOk2QCVVUg0//SwQXrnP/Uxq7Ju0BTHlm66WAJT 0YgKb6DP4Y7QDpKloziicJzyQ1fy4Gu87429XHXBDIun9aAh6WWWxhkFEryJjKWBgtsV ukRK744/+3oYfMnVG59qS70a2/+Cxot7DCjCE6j1qVZJMWWn+L16maMC789QoGVCDf9/ bEiLilJ6SAZpFgZmuyAJ9zt78/MdYC38ZVc8SEuo721Ag94maY5fRUcd9T0DrX9n2czq iQd9jbbtrymg58WZjstgNKnJSAk3IAGNexE6h5CwMep9m7KHuq+nHECtlGrlTd55F2g8 lp4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=e83Kh8y33SsGtp3mBjjq9S+0kBQxVM7UcwxTwkf4goA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=Tif5Wul6JI/NaO1HmWG1Qefa9+Jdq4Fqq7gJOU0uKsxr1qC+gqe/ngKnvio+CpbXmO 6H/6/K582AaGU+POnFgII7vClopJwRf7TxdpW1cS+XQIj2SBkTEUFMjBYqQAyi9pddB8 evGaIA5yYMDIqdo7+os2Fctc374GloYp4qCHvBLs1wNXRhk1m3X5kolrWqK8Ft4lGhBs Y2xYubNR0MAqzGBZtLyiTuILILjIe8vqtLG8SGb+No7DTr3N8PXCLMKVRPOYKi58aE8z QIE0zIcmxXKeAfgG84yn84uKvJ+86OpDxA4VNb/NOpO4rLHPdBPMedotynp7IXZbdEIn ISag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FqGhC9IQ; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2adb3bsi320404585a.108.2024.12.19.20.16.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 20:16:13 -0800 (PST) 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=FqGhC9IQ; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOUMV-0008VJ-01; Thu, 19 Dec 2024 23:11:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOUM7-0008MS-GZ for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:15 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOUM6-0006IK-0f for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:15 -0500 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2ee74291415so1115334a91.3 for ; Thu, 19 Dec 2024 20:11:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734667872; x=1735272672; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=e83Kh8y33SsGtp3mBjjq9S+0kBQxVM7UcwxTwkf4goA=; b=FqGhC9IQTSb+lCy5X1v9uNYawfosSiIV4QhBMWwta49UW6817RzPkPvkoRenWAt/9n 2PplIaGL+sFF2AFdOE5vHLa8sO/EzT0qKhpfLArCNNv9GBfl+qqTlV1N69WboRTmcM39 IPrjUeb6NFqafXvVZP5kJR1Hsg0VDiJOSk+ME3wMNolOudK3c3PjmVDWOYFrx3FrrmWR PYB3W0AABbfC/T4o1ghtZ1VI1Up9dpq2LE98sR3tvRQGvK/QlE3NZiLQ3kaAuMyk9o/o rgyizQPEXCBqCy3efG54XrYKkbkpOmFnu6wRtGaFrI0Z59MOyExSKiWtLFlfqNiKHzBi VqOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734667872; x=1735272672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e83Kh8y33SsGtp3mBjjq9S+0kBQxVM7UcwxTwkf4goA=; b=RQRPdL5ZxYnDur3QtWNzywoTn/aCtng8FIQk/2mcE/dpesqT7jlUON14tUfg9BJ+00 /1x1R/Y4S1ojXA+eM+kqjflgo1UjkESTu4hbw8kak/X9fdmBwnCZuOmbpqjHuPNN/4Fx wPIAMZOrd4O4ZpE0t6cDfSDPGHW43EMERbSWRZLqxybaIMd1EQGjakLiHyuebN4kR4/b R0vEoquSsfr2dAe4fbhc2SKj+lUFLtV1ZcTgz2NIA4XYpx06iBRY0BhEyDJbXx34fcpR 29YiMVZmeUsdLKE6LdjGs9YWFR+rF6RLBtFZQPo4xm0AfP6aMR8hp9u0sJ4RdJ1LGJOO Zx/g== X-Gm-Message-State: AOJu0Yxg3cV3Rvtb9HwYlNojZ/yUJM3GgBo19LjBY3auKoWO8TEz2REr 89kGmfOS+ToVn04xdL9W8i4gLH5zQ05c12Rdss2PORnlUUOVc3xoyGor/+hs74Pjm32WmU2dzxY S X-Gm-Gg: ASbGncs469RgKAfKUsuM5SBlpqYmDdfTgnDxCzH2AmLpcSEt94+aKvoO6uspq2P778/ Go1kJ8mKBQBosm1e29M7ZinUgclUryPmVxeEu57W8y637xKmrY8nj4f8GEtHq0juOA2xd5YdArt 1z6jYcOZw5ttCay6lDa/mnThfynYukFq8s3qAIAj37o33rhm0WK28uM8PVPE9cEGarkySzedfZA NK7wrSmI/N0Ql/zJdugRhup2vyFxfbSHcD3eI+UvjZuThihvuUc1ZZJRSeQk8E= X-Received: by 2002:a17:90b:2b8e:b0:2ee:3cc1:793b with SMTP id 98e67ed59e1d1-2f452ec6ed2mr1985899a91.26.1734667872223; Thu, 19 Dec 2024 20:11:12 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ee26fc22sm4165260a91.51.2024.12.19.20.11.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:11:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/51] tcg/optimize: Use fold_masks_zs in fold_count_zeros Date: Thu, 19 Dec 2024 20:10:22 -0800 Message-ID: <20241220041104.53105-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220041104.53105-1-richard.henderson@linaro.org> References: <20241220041104.53105-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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.29 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-bounces+patch=linaro.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Compute s_mask from the union of the maximum count and the op2 fallback for op1 being zero. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tcg/optimize.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index b8e9ded821..270051acd1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1583,10 +1583,12 @@ static bool fold_call(OptContext *ctx, TCGOp *op) static bool fold_count_zeros(OptContext *ctx, TCGOp *op) { - uint64_t z_mask; + uint64_t z_mask, s_mask; + TempOptInfo *t1 = arg_info(op->args[1]); + TempOptInfo *t2 = arg_info(op->args[2]); - if (arg_is_const(op->args[1])) { - uint64_t t = arg_info(op->args[1])->val; + if (t1->is_const) { + uint64_t t = t1->val; if (t != 0) { t = do_constant_folding(op->opc, ctx->type, t, 0); @@ -1605,8 +1607,11 @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op) default: g_assert_not_reached(); } - ctx->z_mask = arg_info(op->args[2])->z_mask | z_mask; - return false; + s_mask = smask_from_zmask(z_mask); + z_mask |= t2->z_mask; + s_mask &= t2->s_mask; + + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_ctpop(OptContext *ctx, TCGOp *op)