From patchwork Tue Dec 24 20:04: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: 853236 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp4082118wrq; Tue, 24 Dec 2024 12:09:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUUNbVh5hncnNgRLjHSM/D+SDAzqqRiTWCmOlMobiKsLyOE6/4A+LZJlcCQPO3VHPHBmPBFcQ==@linaro.org X-Google-Smtp-Source: AGHT+IG5wOH16Gj0zr42ILrI1JjmLtSBbgOydXmsvdq+cEU9vF4ztdfGNSUqr+5vzSJz+gL7QIIz X-Received: by 2002:a05:6214:5298:b0:6d8:8a60:ef24 with SMTP id 6a1803df08f44-6dd2331e572mr284185456d6.9.1735070961716; Tue, 24 Dec 2024 12:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735070961; cv=none; d=google.com; s=arc-20240605; b=XewGCjpyk1pOAhvvPuP1qNmd0aMeR1sDjb9rcLYv0c3tgPqnMXHpT5SqmEQZpYvq+2 TJ2wQh0AV5vlPFt5/PGvrIXJof0YtxlMOjfxA7i5c12wbcAJUJjcQBK+4eEzGHke1xWI 5kBg0gWtwanWc4kWR8/Nl/OBjs4ZpJ3M1yecstCNdRpJ4woga9AwgQU0suCO2gssR9d8 m/1fEX65fNMpdL8GGDG11t9Fo11+yUwagrYMciDFVWLDM3QAJo7m18LH9ngI3NbZ/6Hl wPRc4/csr5WqH5vGUAT0xevT0LAC1bRpyxlIfcQMcAW/yaC3LLTCiMX3DQnFEH4g+lY/ qMpw== 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:cc:to :from:dkim-signature; bh=KTUO0uF94ggO8DLruNGc154B1KXBI7ow/g7ffKKGvr4=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=Wv61sWtji/RB8WDwFLa+aYZX7P0BgozTJIPR4rsTwof6ErxX/b0hQvXMDx9HYdGcUP WyWt3WIkHMNS3hph2ivpw/y5A6ah8IDoxFHu22yE8XZdA+bVxmFKf4wVqrBgUcJr35EC NWVP4drqHRuHtr7qTH3XwuTBvn8jgVpMF11eZyX2thrwCmGddeKrHSvezAG6IRky7L6B xSbbCrShpfKMBPo58wtWNYW7O1Lz479hBqocDoORk8p/4bsJV3fFbRcfObPj1Pr60NPB oqn8jlQhdqoQVmk7wZdiEgR9M4uBdffrvi9+VnYu/BoIaXBvE+4q36u+fmYKYKDUoIoz LVNw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aeDKKiBs; 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 6a1803df08f44-6dd18233555si150177466d6.238.2024.12.24.12.09.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Dec 2024 12:09:21 -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=aeDKKiBs; 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 1tQBAz-0004Iw-5U; Tue, 24 Dec 2024 15:06:45 -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 1tQBAE-0002yL-RV for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:59 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAD-0002e6-8r for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:58 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21634338cfdso79720935ad.2 for ; Tue, 24 Dec 2024 12:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070756; x=1735675556; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KTUO0uF94ggO8DLruNGc154B1KXBI7ow/g7ffKKGvr4=; b=aeDKKiBsClZ3Hfde1gVNPsU5MzqNr+Sbe29iQUDirxarUNVY7EEbpnjgRGu/g9Mdj6 Qu3AMohNY6S7piJ5j4jsLCH1vnpoQfCySit6B+dbVXlhSko8pAHLwVfHpaJGCjRTkoGM EN/Xyd41y6uCf5MW1hmRX97kHUXx74RfqsqPLQyUph8cLQa2aEdYQxfV+9kiFqXLTbdn JbEgyuPSOxHbh40kKK8is8eXilYNPp7XUPpkBxN2ol7h5B/jf70VXqAP/Vi9vq2tf0J1 65dwl9YDV2BGr1L3JUuicH5mLq3eX2YLH/SAojMMxfaQn+mBbTPLaYLnTDXXneXhWEbO 38gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070756; x=1735675556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KTUO0uF94ggO8DLruNGc154B1KXBI7ow/g7ffKKGvr4=; b=UbV9Vbee4u1zvsnyFLallbkmV1gKKIpeJk7oUUu9j05NKnHFmHBEejucG+LLq7SBhQ J939gWCda/mWevpRbl5eA+AmU/Zuk7zNKR2G68bojUPxSe2Xnrt5ciCOfjCKT/PeAmrR 0JS5Tynnvy8QzkerhNSFd5fiRJ9nTB27e6yCXvhdxVZhy/Qh1Yw4XIBXFa7h4P0vk88k 15cZ58E01L6eNOyka1fvNBYd3tFhRsZXO3ZIe4VJoOX391SvhMT7Ae6uWyFw/r91U+bQ ZEXO+DG21L7r/u4hd+b+Fk/9XUf6R7A3lj7WOdE0mhXm49as5dktMgD5HQUs68jF3CVr LUYw== X-Gm-Message-State: AOJu0YwQ7bF4iBJBGMiplS0tmBxP2S3ugqF+sK2+fMNhDDZTc0RSeo/M 3TkMA6uysmXmlRXRVPXnr2Wyp5Paf1S27z+fmxDo1ZGRUDpVUOsl4YmsIrNT2cE/6SShbP7HvPg pShA= X-Gm-Gg: ASbGncsgt8JHsAS6xa9lLro8Zmr8cqSN0fAInlTQQtpVmBXCjTZl1+L1seGN6H64lX1 lCiz88KSbm1Lk66lJHLkabEpu9q41i/oTkO+JrFNjiPMj3SSDpLZeyva2L7mmsNszVN6U1Fl3kF 8itnHnjmiq2dSDn7yYyy/JkBch6E5zSmyHDPMwlV78RxeDLHRz6h9PnqgSpvO+pEBC+xUR+npCh k29o5tD710C+8rUboj3YpLGk5U/FihUdJcx9ZHNX8i8F5KplWgH0TqKGlbKEi9z68AlwXBjIj0U bWnA/8ABsRtNhbtfNnx0BK0o1g== X-Received: by 2002:a05:6a20:c907:b0:1e0:e07f:2f01 with SMTP id adf61e73a8af0-1e5df939d84mr25801344637.0.1735070756035; Tue, 24 Dec 2024 12:05:56 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 36/72] tcg/optimize: Distinguish simplification in fold_setcond_zmask Date: Tue, 24 Dec 2024 12:04:45 -0800 Message-ID: <20241224200521.310066-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e78f5a79a3..678015a94a 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2155,7 +2155,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; @@ -2250,11 +2251,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) @@ -2359,10 +2359,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; return false; @@ -2376,10 +2379,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;