From nobody Fri Dec 19 17:11:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1733844341; cv=none; d=zohomail.com; s=zohoarc; b=lWnt9riXD1xifVj9GKJB9gDZYTXFIeV5jEbQG+k4jgVM8Of3vvqFP9JQ+xxoypxgj7CfMzG5irbg2M3l009ELyXKk6CfbmRaWRyu/9EE4FV1BsjereBobeSRJwgrxpo5nKnkpteNiYcoTUFnZ4a49S0bM7ypZnWIiLQIypdd4X4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733844341; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=lIaqwHIAjwY7azknBwNtOhCbYad08/pBvrAzkfqNf5k=; b=WyoQVafT3EA9z/pzYzC1CQwP9bZu3zpkLW71K4M0NrihLBzILrYdD+7YChUtCtjI4y79wTC5FrqPuLtxp/GCP3e2o65innXdkNQIL232K40D11nWptl0UArySQl69fcusvuWRE1dLvHc/KDMVQK2nmXzpizzy3+h+gZYh/4FOPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733844341719488.01564260046473; Tue, 10 Dec 2024 07:25:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tL26h-0004rN-Lm; Tue, 10 Dec 2024 10:25:03 -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 1tL26T-0004PT-4r for qemu-devel@nongnu.org; Tue, 10 Dec 2024 10:24:49 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tL26R-0008Ok-JA for qemu-devel@nongnu.org; Tue, 10 Dec 2024 10:24:48 -0500 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3ea696c4dcaso2750952b6e.2 for ; Tue, 10 Dec 2024 07:24:47 -0800 (PST) Received: from stoup.. ([187.217.227.247]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3eb076b9168sm2776435b6e.14.2024.12.10.07.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 07:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733844286; x=1734449086; 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=lIaqwHIAjwY7azknBwNtOhCbYad08/pBvrAzkfqNf5k=; b=Tgn0h1KYizpzxPOuYhlxZYT44Jv+FIuANeC7NFgOdk9rfGN1KQqjziZeOvl/i9+rZH e39+0S/jIya8LrnImwhbarY9NlhclB1LKEsyoEVUDU5A8N40x3NBpxWah7BJrEU2HysS AC47LCYkAXzqwrAyH91ea+RLITbft7bopoyvEC6p+hm++FXv/gW1UCvUtyWYF8x34CGi wmzoRJpIhD72EWkQx5A12L4qYyN23jPNDEaiVUSZJEGcI4BFke3uZfH7nuizPjG9wOF0 MzS4bbEwW49DUOpDZ9AjbTSZdmygt1NKqg96jfaD9GB9gBXuLJVKettm2ec+YiC31eo7 3TbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733844286; x=1734449086; 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=lIaqwHIAjwY7azknBwNtOhCbYad08/pBvrAzkfqNf5k=; b=qoOwTR9AkuzL1FDXSj4vKBRakET2hgBuoaUpIAT2bZ9hgxsl1wfEQF1K4fHvh9wtKM hzWHWFGj3S/RIzVkEXo9SwL2hfvOYfZDSW6sKoSMEzj7PJR+pUbH1Qu41BNKyG5q8d7B 4gjEqF0PnIkGxEDi56rtoVhWKe+KxcmDykZIT9wUQSMgA0xuVN0CnJ0fP5v3+iGSJ15l 7N/cZmqizpVyVpl1zftGYJRhVJ3vkuIeioIIc6gF3I6yCmgoobgnqghZZ0eKeTIr6Ilc 8ug43c0KWvWm/75nDvsSSvm34aqyZ7E+YKiKLXYF2tzXgcip0TVCujgFxRhlqXPu6e9k FFOA== X-Gm-Message-State: AOJu0YxOk8DNlby/OuGVXX1GbZFLKD07sYVs2bo/xC3EHc6i07ai3n12 tMp+Ns2v4eUSQU3Mtbvm2P/gNzNhPkl3yes3quTRQ0xpyPga+3DRWAzMQthQa8spZyUu30pXy5P vgFoCNqCF X-Gm-Gg: ASbGncsoUuS93BPLNXpRl7VaGT0izlqQCOVI25dnQgLYUQybU5+AEZatmmt9ReTMPj+ YFwUD0u7AerFTqZM2MsnZZWMfiXEMrbEBaidtXdWlYFWo7u1QQaWvjXd8d+r4bxsXtflVyQuvv/ coSzHv3YYPcVqMNt/BT/UGwcsYpPtJnIiGZUr9n+qFFQPwhM9gI92kAwWpExT91jPaw/XPU027z HRbfP7ekDpW+784N4N6sp/O/6NGTgcbDg/CMf/+4uXkiPU39iAH5D45U2HFoQ== X-Google-Smtp-Source: AGHT+IEd7GcZzFyeQ+Ib9m/nDb8fv9RqIUtRVEvUHghNCA1sSjA6JRBGeEhOC8ks7IH0V8Vet8uOPw== X-Received: by 2002:a05:6808:1790:b0:3eb:7399:29d3 with SMTP id 5614622812f47-3eb73992f5fmr806183b6e.43.1733844286379; Tue, 10 Dec 2024 07:24:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 30/46] tcg/optimize: Distinguish simplification in fold_setcond_zmask Date: Tue, 10 Dec 2024 09:23:45 -0600 Message-ID: <20241210152401.1823648-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241210152401.1823648-1-richard.henderson@linaro.org> References: <20241210152401.1823648-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1733844343541116600 Content-Type: text/plain; charset="utf-8" Change return from bool to int; distinguish between complete folding, simplification, and no change. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tcg/optimize.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index eac5ef5eec..7b1d437c27 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2137,7 +2137,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) return finish_folding(ctx, op); } =20 -static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg) +/* Return 1 if finished, -1 if simplified, 0 if unchanged. */ +static int fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg) { uint64_t a_zmask, b_val; TCGCond cond; @@ -2232,11 +2233,10 @@ static bool fold_setcond_zmask(OptContext *ctx, TCG= Op *op, bool neg) op->opc =3D xor_opc; op->args[2] =3D arg_new_constant(ctx, 1); } - return false; + return -1; } } - - return false; + return 0; } =20 static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) @@ -2341,10 +2341,13 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) return tcg_opt_gen_movi(ctx, op, op->args[0], i); } =20 - if (fold_setcond_zmask(ctx, op, false)) { + i =3D fold_setcond_zmask(ctx, op, false); + if (i > 0) { return true; } - fold_setcond_tst_pow2(ctx, op, false); + if (i =3D=3D 0) { + fold_setcond_tst_pow2(ctx, op, false); + } =20 ctx->z_mask =3D 1; ctx->s_mask =3D smask_from_zmask(1); @@ -2359,10 +2362,13 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp = *op) return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } =20 - if (fold_setcond_zmask(ctx, op, true)) { + i =3D fold_setcond_zmask(ctx, op, true); + if (i > 0) { return true; } - fold_setcond_tst_pow2(ctx, op, true); + if (i =3D=3D 0) { + fold_setcond_tst_pow2(ctx, op, true); + } =20 /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask =3D -1; --=20 2.43.0