From patchwork Fri Dec 20 04:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852350 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1851947wrq; Thu, 19 Dec 2024 20:13:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXdcQqDXjAGXq15Qc4vT8zQMu7PTKMu9Dio17LjbuT24P59gB42EXELGXuCLm1pXuJh8LYCcQ==@linaro.org X-Google-Smtp-Source: AGHT+IE2WYh8py/z/QIucBl2grReVnpmh5yAkKEaGvyZbB95e6O1H+wF/ss2nC+rAtBoUyrASLhe X-Received: by 2002:ad4:5b83:0:b0:6d8:850a:4d6a with SMTP id 6a1803df08f44-6dd2332ee4dmr23068916d6.1.1734667990139; Thu, 19 Dec 2024 20:13:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734667990; cv=none; d=google.com; s=arc-20240605; b=ZHasG8n7zc71cDHRH6vfSmtZsbF0YvDrkENpoKokiPIhmDe7jjiZQnI7iguiBQrulf LZ7S6sah1KbEDt8aNxArBpQgsxZMtN9Hf+XT+jB+1yXq4KD5vKe66gxohCa2FTPnAUcz SzrXiGXKw4yhA7ZoLJIda6gCdZBXd1Fphz1BdeD2N5tWFvD9653QPenTk94IeMrTCBls co+ZsuhHDDb4CYcVAOioeYx6AWfe7bfdtTA/xYnEI4IvtNw3iOaxtrm39lqUVPsLZt1R mZlzltOTKvhFEdmzwcmN3EroKFmNNgLwf7JZBW5lljHKmcw4lXycOpcjP0BCqgHB2H+w UyjA== 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=C5r1sayG0Y/5s05OtCkYtZE41zRfSkyjZqixbgF1qiw=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=a92LeI9Io2kzNCbanvCLqOvG1KbjXg3wZMy48K03mlDc0gO682iZj7tmvOwMMppeUQ Xky4N7VISFQoSKxEZ35uXFFzNQi3rndm49Xtd99AviSzLhjeodkpyolaUhanKuOFinhE JlkQxtpBnbJweThjCSQuCWagZcW/eWjWCBeOSUtY64ho16IsodtF0s7ucbDOeFrUbb3P VmAxSuGgADd7W9eRkOE4cLPTpDVnDoAFCKP3n40Q8HGddmKCe7yZGziEItnyTXbaryi0 IHbNXWfzEUHGsNiluqw+E0OR252QP0xQxlOIwaG320Ebb6asl4P97RFDOzfNYx5vZIp1 dXsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zL+DdcsW; 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-6dd1835a6a4si30030346d6.459.2024.12.19.20.13.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 20:13:10 -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=zL+DdcsW; 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 1tOUMK-0008Pn-C8; Thu, 19 Dec 2024 23:11:30 -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 1tOUM9-0008Nk-5R for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:17 -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 1tOUM7-0006J1-3F for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:16 -0500 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2f43d17b0e3so1413250a91.0 for ; Thu, 19 Dec 2024 20:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734667873; x=1735272673; 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=C5r1sayG0Y/5s05OtCkYtZE41zRfSkyjZqixbgF1qiw=; b=zL+DdcsWJUbuHWxmCQQLBcjyQRLlc1NTgNZLrxcl0ZA2xmIyuL/6gRUuWzVtAVyd9G LByucI/7xi+pTrI4ayaPaM1hxBa0EJvqliheeKjUlyU0IwdFl0Sjfid3lvTg8XsF0cKh JEtedady+9fmxkTqeX9EltLHE0kfk9edKuBeqyj1T+T2cinaglGq2HCtFKd8YI/uzg0t 0RqEBAoZA/TTMKbTq3IxUuNEDqsFc9hvxfM2pHOQjgrAW/JgvXevULLAge0f7P1/i9Wq PhmA16a/vWB07EfdLJTtWgYpl9N6A5aiU7hTWPBn5S1CQVt78u0SvW4U0fmEjZxA96dp tFFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734667873; x=1735272673; 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=C5r1sayG0Y/5s05OtCkYtZE41zRfSkyjZqixbgF1qiw=; b=RJr4A9ttcUKHBW+2oxjR7NDIMqXYOYJWkBpt7USPvVSOaPvGIkIhP8xWaWQyqhetn6 98pXMAh3Xqz8BX5xvOtVk4fMBLntVajqwrCKVmEhsxeNK53/qKHbiB47v1BcHkC+ypUT 0MEG3o15H+7uirJQ/3Qhqwf0D6wpN4ylxFdGbzY25mha+Tys8uEBciM7RYLoK5E5hQT3 F4Spc3DkUaB1QcXcysWI8xe2YmX3HmTSGVfbfKYk2oGvnrprRlc8mV7P8R0twxXsMzXc c4C2Q1YISemKHNxsUf4VPkQCN4+SGvHQR549OTQfein8rl8GZrrL1VOmwPgmD1QtjtPG ZAqw== X-Gm-Message-State: AOJu0Yz8/quTRiY1bPONQaec9cHAjv+/bQI5+1UAfF+LuTuaQR6noWD+ 1pMgpo0rmLJ1K4YSU2xtvU6/rm/kcKxmB5gz8BjUci5briV8svAZ8s40EJOnkDCh5NdjZVXVims y X-Gm-Gg: ASbGnct22XFz297YYt62EzQPHH3+KBGUYqYuQhkRad1XFGFtHR6oW7xTm3Q2koxBMmJ HIK3ZZW8J+sDAfAWQgTR71goo3WRRBPwYPxFl75y1jCVBleev/gXkE/Ki2qjod5zL+IVj9w3Byd 1TrmFq48d3L35C/0VmNu7wSutVj+A783zWSAh0d1WJLK7owlLDtV+mSE9fYJ2Dooxe7WxTtOzw2 J677nD5hHkni4mOeg2l6m02cIfSxo+yjODZt6yn42fjZFkPhJYisuRD1YUgB/M= X-Received: by 2002:a17:90b:51c2:b0:2ee:9e06:7db0 with SMTP id 98e67ed59e1d1-2f452e1d3f9mr2311897a91.11.1734667873645; Thu, 19 Dec 2024 20:11:13 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ee26fc22sm4165260a91.51.2024.12.19.20.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:11:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 12/51] tcg/optimize: Use fold_and and fold_masks_z in fold_deposit Date: Thu, 19 Dec 2024 20:10:24 -0800 Message-ID: <20241220041104.53105-13-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 Avoid the use of the OptContext slots. Find TempOptInfo once. When we fold to and, use fold_and. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index af7111c98c..de32cc0323 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1642,14 +1642,16 @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op) static bool fold_deposit(OptContext *ctx, TCGOp *op) { + TempOptInfo *t1 = arg_info(op->args[1]); + TempOptInfo *t2 = arg_info(op->args[2]); + int ofs = op->args[3]; + int len = op->args[4]; TCGOpcode and_opc; + uint64_t z_mask; - if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { - uint64_t t1 = arg_info(op->args[1])->val; - uint64_t t2 = arg_info(op->args[2])->val; - - t1 = deposit64(t1, op->args[3], op->args[4], t2); - return tcg_opt_gen_movi(ctx, op, op->args[0], t1); + if (t1->is_const && t2->is_const) { + return tcg_opt_gen_movi(ctx, op, op->args[0], + deposit64(t1->val, ofs, len, t2->val)); } switch (ctx->type) { @@ -1664,30 +1666,26 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } /* Inserting a value into zero at offset 0. */ - if (arg_is_const_val(op->args[1], 0) && op->args[3] == 0) { - uint64_t mask = MAKE_64BIT_MASK(0, op->args[4]); + if (t1->is_const && t1->val == 0 && ofs == 0) { + uint64_t mask = MAKE_64BIT_MASK(0, len); op->opc = and_opc; op->args[1] = op->args[2]; op->args[2] = arg_new_constant(ctx, mask); - ctx->z_mask = mask & arg_info(op->args[1])->z_mask; - return false; + return fold_and(ctx, op); } /* Inserting zero into a value. */ - if (arg_is_const_val(op->args[2], 0)) { - uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0); + if (t2->is_const && t2->val == 0) { + uint64_t mask = deposit64(-1, ofs, len, 0); op->opc = and_opc; op->args[2] = arg_new_constant(ctx, mask); - ctx->z_mask = mask & arg_info(op->args[1])->z_mask; - return false; + return fold_and(ctx, op); } - ctx->z_mask = deposit64(arg_info(op->args[1])->z_mask, - op->args[3], op->args[4], - arg_info(op->args[2])->z_mask); - return false; + z_mask = deposit64(t1->z_mask, ofs, len, t2->z_mask); + return fold_masks_z(ctx, op, z_mask); } static bool fold_divide(OptContext *ctx, TCGOp *op)