From patchwork Tue Dec 24 20:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 853217 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp4081432wrq; Tue, 24 Dec 2024 12:07:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXyZ0gDi/owaoD3lp4Ve9W0OkIbv2dNvezoDy8O+6PaMQm6k+hNY2KZNBGI0qh1fIG4W0oyrw==@linaro.org X-Google-Smtp-Source: AGHT+IHlwL8O71XuzdHTEo7ji49RHGgP/hsNFeqPiyu3zeqNcfepOmvebmu8JErQuyBki9Hqmo4U X-Received: by 2002:a05:620a:601b:b0:7b6:7909:5208 with SMTP id af79cd13be357-7b9ba716befmr3091812485a.5.1735070832510; Tue, 24 Dec 2024 12:07:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735070832; cv=none; d=google.com; s=arc-20240605; b=S92p8E1Enx8aTeqFpbRN8VeV6/0DBzuee4yJouLrBz1FESeuWXP7bc8MTmJvm03hOh PdXXFUMkIzNq6m9cY6avlPnyzitmwMj2JS8LCF8TU7mH9y3Gq6TfdjnvQySOoBu+H4Hi LSlNrS4BR6Io+InpClyDtnpp4t2jYv1IBXJLAR0bxpnfz2+Zfvnsj85tc7fDL1zPSmj2 fL9GwlacR20XeZf7oEnDT1Fdfobh4VHAO4fyPZh7w2HYAN1p5ee3rt9sYObMeh4Nvcvu k3MTpbB5cyKX/9WBYdd0xu27WB7Oem3I+Mx8edVcKAt27YoR4miyhy3vLY20kmOX/5Vk 0NvA== 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=sf5EKd0lXfaCbRbQXllEv2ceVywi3b3Vv26rFZxb6RY=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=RbihPVrP5rIu6xxHKJeICHZketbHfGoketA8rr8uq4fy+ljhAv1qfJM+ymJBdZ+bf/ rkSJgTILMl0RHT6vIJ15QZUQ9X2maiHzM1ZtE1fY/41Hcl6ZuQle/dkTK3AN7/FcVKAQ H1YEqoNmD+T23L+7jNK/d3T9w48b/6YFJrotD/01AVyzzQuGlc1dbgZswkABbWjUdh/A zPxNwi3TPDsfGvJsvgXiQWA2cXrfenbHIjRj9MNqt1I9l4v5FJHGpZ1AdncGgCM0pYB+ o3Q1GVi1azZyW74LNcScFer/blKH398tOkw+QmLlBaKaP1SigvARrh6Z2aewJ1vo+BjS 8D4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ng+ETRGZ; 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-7b9ac2ab601si1600902485a.69.2024.12.24.12.07.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Dec 2024 12:07:12 -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=ng+ETRGZ; 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 1tQBAN-00037W-UO; Tue, 24 Dec 2024 15:06:07 -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 1tQB9w-0002mF-3v for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:40 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9u-0002Z5-JL for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:39 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2163bd70069so55718015ad.0 for ; Tue, 24 Dec 2024 12:05:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070737; x=1735675537; 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=sf5EKd0lXfaCbRbQXllEv2ceVywi3b3Vv26rFZxb6RY=; b=ng+ETRGZ/vMlNpAxuI9FwL6DX0sIRSEJx8/dQvJOTTdbuoNwWNFQfluhS4W8Jl6RgO IrxZO+bLw9Zg1BUgeBOv3RvThsOwT/1t5DJIMFrYg5rk6wVZoFZNIbT2SJMeYZ72Jgtp r3RTX3Uhr3K6hzXFRhaje8ZmDvnfBHqfZKPee320FgtjlKmLIgWqaLCksoCvzxi02BJw qUClGQ9xryXzabw3HP524PQ2UPKSrSRuBlU23WAA3lS6TYHLuyB8vLbUeQUrTdwTSyaT 1vXgTeZjDbS91YfN3gPEg32rkW2xO7kBlsVSDNE+734xp3Wk8LDCgel3xU+Lve/kN8YW vyDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070737; x=1735675537; 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=sf5EKd0lXfaCbRbQXllEv2ceVywi3b3Vv26rFZxb6RY=; b=I0CHAlUHyOiCT/rCGOj4W76Hl/gAAbLXo7UNF8StQRwh93f12LjABsJzCAXO+kSRoA LPKN1iQWlF7KQz7xyqUqbGChkniP/5wMlzA2SPN2GBIk0uqW7pjDUeMxvkK/twC7bRrv 8sSPcHEfPDemXGK7jpq29oI7dSK2OTtgm0flD7+Kf94i4iOev5zUy90KzRcue6FJzcvK VEtTR2eOawWBMDu5gjc1nqIg9I2GF1WvJbMmcpXg3X/fFjL6sYTozbYTqRT1zx3Ymtfo YZqKrqAsBZ3hX9032SchappBBYL+SHSHPVOhVQLfNbLpxW6Cb9zrOpu/yPSQjqSCeNMc 3NwA== X-Gm-Message-State: AOJu0Yz796HbG6g8gloeMMI1Nu7CJhE9qMpdlFEYgiWcm1Yx2aHFLBij RFBXz6FoLasuhM0FEMvh1ph+Mg860QaW+cnQnStuPMItKqP47Q5m7byVdtXTiWYhji4pdJod9hI 6MeE= X-Gm-Gg: ASbGnctasYs1biBC1lqEuaoPBj0/9Sn3Tp/xCIcHWVVrJ2gOj7fS/j7ZVa0V4OhUX6a mCGc4IlGOpIbljqio8KCQz/6/x1tcqQ+JNqo5cJLYVmefNApPAnz/7QkiLcVxpe68erVXVIXaqU /WBnVzNssgTW6au4wROUyAmrL+EX2LS7qu2NTfFV64XVHzOmvmvMfgU4b0QQuAeprxm8MAQY2/P QP7UUhx9O4rNigXNiiFl/zVGaqUTxfjFzBC0pisSX5PCGvdi12KxIQxije3dIhs6Vi73kA7cnEx U9BNStSpGenf90ooHbAXEa/v0A== X-Received: by 2002:a05:6a20:c907:b0:1e1:a829:bfa2 with SMTP id adf61e73a8af0-1e5e05ac3bfmr27799976637.19.1735070737356; Tue, 24 Dec 2024 12:05:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 16/72] tcg/optimize: Use fold_and and fold_masks_z in fold_deposit Date: Tue, 24 Dec 2024 12:04:25 -0800 Message-ID: <20241224200521.310066-17-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2f5030c899..c0f0390431 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1625,14 +1625,17 @@ 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 (ti_is_const(t1) && ti_is_const(t2)) { + return tcg_opt_gen_movi(ctx, op, op->args[0], + deposit64(ti_const_val(t1), ofs, len, + ti_const_val(t2))); } switch (ctx->type) { @@ -1647,30 +1650,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 (ti_is_const_val(t1, 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 (ti_is_const_val(t2, 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)