From patchwork Tue Dec 24 20:04:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 853213 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp4081255wrq; Tue, 24 Dec 2024 12:06:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVNvhDSOl8RzITGpDmm/w7sBfHEZTKV5dFFCjAg+PD8NjscAF5rt/uoY8DD/LLsAUnFg7FvgA==@linaro.org X-Google-Smtp-Source: AGHT+IGcISnScms9TkQS8W/wDTQgl/Oj8J9ClrmQK+06TLN9uj7GRrP6CE/btuI2G+VrADAFbU7V X-Received: by 2002:ac8:5a54:0:b0:467:8342:d0d5 with SMTP id d75a77b69052e-46a4a8c5db9mr269157051cf.2.1735070797484; Tue, 24 Dec 2024 12:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735070797; cv=none; d=google.com; s=arc-20240605; b=gi+DEwnxSJ8jNdWxCItO9x2xnhwTFmXn7pCtRp7U5qPEcCpB6yp5EV3xXRIa3RZhM8 mXoxuoh4QKi5gTicBXCvFJeKyOSO329a29lM5X4LQiBXRGXb0coDqwq92/h7Vr2NCTwt 1qMBKW8hNKdmX2OKdA7alRn1Bl/FD0eYr0K6pQQxuiH+AzYvsKxO3J95404Dp0bXv+bI ucxviN6AjKmpA87a5wFmY5lLzgrhsiQu1ZC/6gEyxhQEdjPjVMDyiT8YaNumdBrYborx jaXDNfWz2DfNdHX/+5QCcIOyFN0gwnU1xT2vm1SjAmX+rbNsZ9lFQR0giyYxE2+/t4Cr pO6g== 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=i8y2SP5gsVRd2DDyIzSjHzTbblUtHqyMo6MFtQTYJr0=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=Za4MPIgxOPVTFu8kPkVCK+WEr7RINH30W1I1HyFUiWYIzd2InTo5Pregbckzt3HgRF u/QUGLwBiWMYRzHTK8TSgFJjmmG2j2c7EIbtx5ozo6sU3vw7hPbnnQYXB2ylRQNOLIwB S76lxK2t40zRKYztk43KVJhBugL0zotc4M5zCrxgnZ4cYGRdcffHI29RhOwUbtDdN+d3 ok6/iUaW+M6eO9faftfbBOl0SlQ9RdbRnfsnvc0skpoeFizuQ995k8KcwOc0RYV9v7xr m1dyJPGXpQoO2I33cIkYkaXHPTXQRRPYF1djwbFstXFo+hej949cc1NKTad+BD+hHPZy E7Fg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W4nI2Ds2; 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-46a3eb990f2si157375551cf.270.2024.12.24.12.06.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Dec 2024 12:06:37 -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=W4nI2Ds2; 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 1tQBA1-0002oR-5z; Tue, 24 Dec 2024 15:05:46 -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 1tQB9k-0002jW-66 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9i-0002Vj-J5 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:27 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21644e6140cso59036495ad.1 for ; Tue, 24 Dec 2024 12:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070725; x=1735675525; 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=i8y2SP5gsVRd2DDyIzSjHzTbblUtHqyMo6MFtQTYJr0=; b=W4nI2Ds2quteX6Et2TlbzRKDIrAwJuQSnBaXNatDUIhhqPQoFfDusMKGmZWGQTs4L+ mtEZ1hyUvjQRxf5fOrDPFIz9tqZE4nJBLHs07cHJsEvl0+A68+ldn1NODh/gcg/Drryl ThpJI5d02hOg/2HnkGT1ZzGSycki8sVu3NyUsDIfWuUXKk9+bvmBWd2oQAo6s53pbtXP ha2S7IdAUnzXfnV+uEiahuvlwYCOdbDiKF9A5aK4bW1KhBtfpOnBQ2K795ihcNyXlLC/ 3RAf2loDnCUXCkmTAJbpjSQqpCFEKwrS7d+XZnXHAnUY1aVDzjbzMd3lRXnDkPrA3nm6 0paQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070725; x=1735675525; 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=i8y2SP5gsVRd2DDyIzSjHzTbblUtHqyMo6MFtQTYJr0=; b=HNBpa8q0zFQs0uIrR1aIO17hYpKefD3y3v2v48W4VkLvioh3ZXE37tMx6SHU0pKD9Q +naSc3bW8qHdV9HXqBstqFLs+qAi8z0g36+fTxUoA36QhCMs0mzKPdtZjtELk+7Tvhs3 FQj1TknknPtQh2XHmbO3aGG/0Oa9znGK+dXT33PHJy0hqRydGIeB9hU57gQW6SC60Ru3 9xspiP2xZl9j5Mh1epTGaU5Q6FBgIv8ckQgmSXmvU6BbNXldFfVyoePp8K+Nn19oTxKO cZ+D92ehnqopy9lni+17v+huzoYPE55VDPbGoSH3/mfOl+42+cMwEy6i9ZIrVuwpHFFy 9WmA== X-Gm-Message-State: AOJu0YzTTTqyuCG6nb1xu2Z0uCdcGYbIvnlyJkd0VipBUQyTzanr+YHU 3h0BqE4hCTsR9ZVF0ffbElJ2oF8uQqb5RXBtIow2YS2jcbep/rU7X4pN4P52FKlrP2DoIIPUxD5 wDkI= X-Gm-Gg: ASbGnctnlPvGmMOYxJWhc2LI1fOtyz6gIJrdn5vzx0K9i6bwY1j2hGQ4/XRqXjb3jn4 n4uhdbpnTwlHbq5vNY2aKQ+QQtWXPa75lJTr9LnmBTLtbQiFsIhv6gof1tN6cNXQbzbcEsaKt5x SLHPSERWeM7h47XzWKi33YZhGU1x5Qzi0QmTY+Ds0vpqicvSf8j0VWYwScy37cXGQGxklQ64OEd sMQ6gmRVuE+c5u4YuEvG7TfgkjgKZgaO/bNTdtuCw29FEAyeP0/rVvGaN/sYYd7ddeGbVEmBiPy yYLsoemopPKdmp3GaaIF0dAFtA== X-Received: by 2002:a05:6a00:3cc2:b0:71e:4cff:2654 with SMTP id d2e1a72fcca58-72abdd6eb8cmr21763038b3a.6.1735070725198; Tue, 24 Dec 2024 12:05:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 03/72] tcg/optimize: Split out finish_bb, finish_ebb Date: Tue, 24 Dec 2024 12:04:12 -0800 Message-ID: <20241224200521.310066-4-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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 Call them directly from the opcode switch statement in tcg_optimize, rather than in finish_folding based on opcode flags. Adjust folding of conditional branches to match. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e9ef16b3c6..453e8c43bd 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -964,24 +964,25 @@ static void copy_propagate(OptContext *ctx, TCGOp *op, } } +static void finish_bb(OptContext *ctx) +{ + /* We only optimize memory barriers across basic blocks. */ + ctx->prev_mb = NULL; +} + +static void finish_ebb(OptContext *ctx) +{ + finish_bb(ctx); + /* We only optimize across extended basic blocks. */ + memset(&ctx->temps_used, 0, sizeof(ctx->temps_used)); + remove_mem_copy_all(ctx); +} + static void finish_folding(OptContext *ctx, TCGOp *op) { const TCGOpDef *def = &tcg_op_defs[op->opc]; int i, nb_oargs; - /* - * We only optimize extended basic blocks. If the opcode ends a BB - * and is not a conditional branch, reset all temp data. - */ - if (def->flags & TCG_OPF_BB_END) { - ctx->prev_mb = NULL; - if (!(def->flags & TCG_OPF_COND_BRANCH)) { - memset(&ctx->temps_used, 0, sizeof(ctx->temps_used)); - remove_mem_copy_all(ctx); - } - return; - } - nb_oargs = def->nb_oargs; for (i = 0; i < nb_oargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); @@ -1351,8 +1352,11 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op) if (i > 0) { op->opc = INDEX_op_br; op->args[0] = op->args[3]; + finish_ebb(ctx); + } else { + finish_bb(ctx); } - return false; + return true; } static bool fold_brcond2(OptContext *ctx, TCGOp *op) @@ -1443,9 +1447,12 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) } op->opc = INDEX_op_br; op->args[0] = label; - break; + finish_ebb(ctx); + return true; } - return false; + + finish_bb(ctx); + return true; } static bool fold_bswap(OptContext *ctx, TCGOp *op) @@ -3037,6 +3044,14 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64_VEC(xor): done = fold_xor(&ctx, op); break; + case INDEX_op_set_label: + case INDEX_op_br: + case INDEX_op_exit_tb: + case INDEX_op_goto_tb: + case INDEX_op_goto_ptr: + finish_ebb(&ctx); + done = true; + break; default: break; }