From patchwork Fri Dec 20 04:10:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852376 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1852998wrq; Thu, 19 Dec 2024 20:16:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXA0vfoJZ8WLZAm6jDSD4mUSUJp7Qzlhauxin68m00a+9UewrXGsGEUMyNg6vUy9FPT0t6pCQ==@linaro.org X-Google-Smtp-Source: AGHT+IFbrcsmaBcuHuTESVh8Kgvumig/U60mEIXNOHfYE18CY/Xsji9JovMLUCruduW2gVTmyqtS X-Received: by 2002:a05:620a:4406:b0:7b6:668a:5a7 with SMTP id af79cd13be357-7b9ba83aa1fmr261444385a.62.1734668206174; Thu, 19 Dec 2024 20:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734668206; cv=none; d=google.com; s=arc-20240605; b=UatejYKWXu0/nI4sIfaQBVWc+HAKW6dN5qwsLJqzdRw7Urfng+UC7KX/WuVrDWR4rw NcuuLlXsZFIClz1850utzVR3ss7JueRufdphu2kHaEj1ONqCv67m9NWwbFaDfiP1KDh5 Pf1G8Z9Q07rPRK8JaIHBgzVWON2libi8KGYRLwb6nH1R580CDdyOE005QWktFHHzA2L5 7WBiN/kfcNZ3QRT7IWjySPAMBn2v5y8DnQi0z0dC6IxuSro/3PDqsmG5kebzvj4mc8iC e94exaxY3w19paeb7enN6t4Ll6VXheilICKQeDcJuhjTbOyoK1C3HQlMq1P+XjAeRIGC CM8g== 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=+TJ5IfnYTy94xBh6uHrxnvEXKZnmCMvGdvkeZvXUxGM=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=MMEs1FLRbJkq9wmNVSeQJHNlTN+TuvDqttgGY4K7Sui46r/eGngV4aTXrrPTYdyisP 2E2/R0xOOhUiPwgiiHLkN+UM4oZ8F/aFRYb2q9d55kCMB9ze38LSQfbXF/LNrCQpvThu BnY1wpxDKGEPbkXbA0N7PxXBWEmD/EEhMnTlWO9YupwYfYz3w1gJFv6qKRb2Og9tG0Kl uqpGwr59Za17p2Mbr4smjEED3jpm5WJtMZGAG1g1ytmRwSDJ5x5R47zw6DWYO4UmMhPN dMJbdehsrSNJgVtq11SVr3CNiIBeYKmZuLp0tDzv4lMg/5mr2VmFEfhKq0QVFuOHxhXg pv5g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3EaXDcG; 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-7b9ac2cc36dsi323216285a.149.2024.12.19.20.16.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 20:16:46 -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=L3EaXDcG; 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 1tOUM7-0008Mh-SU; Thu, 19 Dec 2024 23:11:15 -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 1tOUM4-0008KL-64 for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:12 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOUM2-0006GQ-7c for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:11 -0500 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2ee786b3277so984832a91.1 for ; Thu, 19 Dec 2024 20:11:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734667869; x=1735272669; 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=+TJ5IfnYTy94xBh6uHrxnvEXKZnmCMvGdvkeZvXUxGM=; b=L3EaXDcGu71FElBWglDSqRiBfD6ek4SopLanQzCV7mOSdiKOd94fw6NhYzVxF2+Eis +TsrQ9Qa4OHEjn11q4pKDrPNscqtb8rRqnyuilP7sjMjZlD5yU6bhScUihAYHUctVrh6 Tc34RAMoS3UGyVGRfLySU5MqXLXA/SwBzkrUXS7ZdHzHFMaDG3zrxskiwhp794LMROEp 9I2/Uq4n5Bm7f+XE1odEQLe1RjIlkQBW4XV9To4KGqHAdCIY2PERBna44V68JLdoJI+P ONteupoPkLY7CWB06xaWxa/9OzLxcwAS1eDS+HQI0/8CfX8gpxLjal/33VJk/dGc1zKM i4pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734667869; x=1735272669; 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=+TJ5IfnYTy94xBh6uHrxnvEXKZnmCMvGdvkeZvXUxGM=; b=KOgLotv4mzFgNSzqr9qEAu9Ym3UscTRX+Rk/vFU+XJED/zQDmMDyLY9pztV9ZzcJpS 9N1RAY/Z11H/OycHyJo1He03SqRHWy7QGUBrLgJxUdiKQDeQmL+4nk1qgv7xlBzcdYFw Cg2tLAMcAHqtOAny4cTZmVrStT4u1poEoNy/JZHkpeLHVREkMlouWsm/62DnLYtb/8DV 8y0OnLfZ1/IlcwY1b6g9/kyHYHsbVF1AhjJcxLhfK0sQdaqbH+TiFuCwXFOplYxMT9Ux XiVDgV0vxesCrsOFDZtLu1Kz8lXtbOnHLctRXWemTnLrGwjFlI4Ykbb5g+qRMhN3iZHL QgBg== X-Gm-Message-State: AOJu0Yz8dfxqaN6PYuOi7iDTiMIo8UlIOvfFEgCEx7AQ/iN5JI0eugYB OSkW8HgFlm6yc8+GdXaLJxNkLEtXWrcHpdgAcufJl6Z5W44yQ33RY5HBf8XdNgfWQuBfoohjC7q C X-Gm-Gg: ASbGnctNy63y1eRzrW12IgLidpxrUMMkt0dO3f2Ntw2bynpHDz3zCDAqVKoEbsEXz6G 5PnQK/8+QAT7+hA2/FMboyBuVxyyDeEBjN8ZdFO9QBxQ9ar4S+OY0wrAcW6pVx2pxWvq0P3sfII DhUlZAlOMLxiVmz6W7kfYg22AlzXLEWZr1WMfA2pm9kfCuZavDXPziaFJEEXmnydxor8JataiYP 71u4lzxVLr1STC0m+59ypv7GDLazUsIZi1ZOgFkCrxiau4BhpBATdZigo2/Bc8= X-Received: by 2002:a17:90b:5184:b0:2ee:d824:b594 with SMTP id 98e67ed59e1d1-2f452eeb56cmr1929180a91.31.1734667868786; Thu, 19 Dec 2024 20:11:08 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ee26fc22sm4165260a91.51.2024.12.19.20.11.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:11:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/51] tcg/optimize: Augment s_mask from z_mask in fold_masks_zs Date: Thu, 19 Dec 2024 20:10:17 -0800 Message-ID: <20241220041104.53105-6-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::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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 Consider the passed s_mask to be a minimum deduced from either existing s_mask or from a sign-extension operation. We may be able to deduce more from the set of known zeros. Remove identical logic from several opcode folders. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tcg/optimize.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index d70127b88d..17b72fe759 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1048,6 +1048,7 @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op) * Record "zero" and "sign" masks for the single output of @op. * See TempOptInfo definition of z_mask and s_mask. * If z_mask allows, fold the output to constant zero. + * The passed s_mask may be augmented by z_mask. */ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, uint64_t z_mask, uint64_t s_mask) @@ -1080,7 +1081,7 @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, ti = ts_info(ts); ti->z_mask = z_mask; - ti->s_mask = s_mask; + ti->s_mask = s_mask | smask_from_zmask(z_mask); return true; } @@ -1519,8 +1520,8 @@ static bool fold_bswap(OptContext *ctx, TCGOp *op) default: g_assert_not_reached(); } - s_mask = smask_from_zmask(z_mask); + s_mask = 0; switch (op->args[2] & (TCG_BSWAP_OZ | TCG_BSWAP_OS)) { case TCG_BSWAP_OZ: break; @@ -1534,7 +1535,6 @@ static bool fold_bswap(OptContext *ctx, TCGOp *op) default: /* The high bits are undefined: force all bits above the sign to 1. */ z_mask |= sign << 1; - s_mask = 0; break; } ctx->z_mask = z_mask; @@ -1605,7 +1605,6 @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op) g_assert_not_reached(); } ctx->z_mask = arg_info(op->args[2])->z_mask | z_mask; - ctx->s_mask = smask_from_zmask(ctx->z_mask); return false; } @@ -1625,7 +1624,6 @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op) default: g_assert_not_reached(); } - ctx->s_mask = smask_from_zmask(ctx->z_mask); return false; } @@ -1746,7 +1744,6 @@ static bool fold_extract(OptContext *ctx, TCGOp *op) return true; } ctx->z_mask = z_mask; - ctx->s_mask = smask_from_zmask(z_mask); return fold_masks(ctx, op); } @@ -1851,7 +1848,6 @@ static bool fold_extu(OptContext *ctx, TCGOp *op) } ctx->z_mask = z_mask; - ctx->s_mask = smask_from_zmask(z_mask); if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) { return true; } @@ -2354,7 +2350,6 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) fold_setcond_tst_pow2(ctx, op, false); ctx->z_mask = 1; - ctx->s_mask = smask_from_zmask(1); return false; } @@ -2455,7 +2450,6 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) } ctx->z_mask = 1; - ctx->s_mask = smask_from_zmask(1); return false; do_setcond_const: