From patchwork Tue Dec 10 15:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 848750 Delivered-To: patch@linaro.org Received: by 2002:adf:ec08:0:b0:385:e875:8a9e with SMTP id x8csp384014wrn; Tue, 10 Dec 2024 07:25:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXmXWrfqGJGXhyNC6at72wgAyMWQWUpxaAh/I5rjC1Fr9Cqc7clfSnp0/c6kze3yOlLaO/VDA==@linaro.org X-Google-Smtp-Source: AGHT+IGZEn/SnYw5Of499JCQqo7py+naDR75Gn2OasSVy2cMfVvu20p5qFHiHC6FPZ8seCEe7xsz X-Received: by 2002:a05:622a:199a:b0:466:9197:b4fb with SMTP id d75a77b69052e-46734f7ec91mr225943171cf.47.1733844341364; Tue, 10 Dec 2024 07:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733844341; cv=none; d=google.com; s=arc-20240605; b=c+X+xJM/oLfxRfyyz3uchMy/Q/jxVFcx4ysPBTUzYCcEvODAPrs58+SMIP6Kw0Hdz3 9KpIA7qGD5YbUIqGv+Me5hhR0bZFaV/SxFCb12Ad8uHqyLKA/7J0XO6eiLrCprd872ze 4SzIYV7d9R0dT1cqFBYomwdUMC7mOsCZA/bk3syYfZgu2TuNdFBWqc2w6JxJCP4UkSkC famkxeQkQgzNU6O+BzADqAxXsFuPyCC+54CkrPsIow9xpqemhL0Sx5r+oBkyP5tPNo14 hSp39ScCSJa/FGiqBMMmty4uQ1qybHqAcBTZzsjO4jqjWKWI3RmmNi54o7+B4viss/of fMaA== 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=lIaqwHIAjwY7azknBwNtOhCbYad08/pBvrAzkfqNf5k=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=RBVXXMib+qb4jAfCN1Maj9Rdnj7Rd92lX+UYvXrQS0zT2zMuf5yy9z2f16cPYNMqHT T2uZvKf1Y2z650Vvd4eDrNT2utG6T3JghKFeFHpK6kzRXxg12zpFhQfzBk45HcwMRBxx kJh8d4NIPTcdIJxmj0OZLZhH2RzvIYUKmOlA8ogddjk55ICGpzt8V1ci1o3CVh4a0aPV gxurZrR1ZnRfhXDxMe+fPnR2Lq5dU1oRfpR7I11AF7eNQTAWkqOKEPJHQb0J5MJUrITp ANaCt6ep2cDtNUqyaQ382KFBnQOF+OqGDthfPkf2qEiRDYl5wWqNqFOBRjHV/g1LDYXX mDwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tgn0h1KY; 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 d75a77b69052e-4672983c2d4si142804061cf.556.2024.12.10.07.25.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Dec 2024 07:25:41 -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=Tgn0h1KY; 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 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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); } -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, TCGOp *op, bool neg) op->opc = xor_opc; op->args[2] = arg_new_constant(ctx, 1); } - return false; + return -1; } } - - return false; + return 0; } 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); } - if (fold_setcond_zmask(ctx, op, false)) { + i = fold_setcond_zmask(ctx, op, false); + if (i > 0) { return true; } - fold_setcond_tst_pow2(ctx, op, false); + if (i == 0) { + fold_setcond_tst_pow2(ctx, op, false); + } ctx->z_mask = 1; ctx->s_mask = 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); } - if (fold_setcond_zmask(ctx, op, true)) { + i = fold_setcond_zmask(ctx, op, true); + if (i > 0) { return true; } - fold_setcond_tst_pow2(ctx, op, true); + if (i == 0) { + fold_setcond_tst_pow2(ctx, op, true); + } /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask = -1;