From patchwork Fri Dec 20 04:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 852392 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1854010wrq; Thu, 19 Dec 2024 20:20:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW2axLV1HmA15iLOBKfzquV2G/bjLhVnQoC/yVJV1k3qtz++6wx7cbOpJJxUEikhAK+3HOWqg==@linaro.org X-Google-Smtp-Source: AGHT+IGplY4OQPD+Hn5BPCEycPVIYnF+IPTVHtCqiRr5MCeicEGslwzvCFGzzy7GuiSY+2u56d3s X-Received: by 2002:a05:620a:600e:b0:7b6:cb81:95d with SMTP id af79cd13be357-7b9ba770bdfmr295780985a.21.1734668423266; Thu, 19 Dec 2024 20:20:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734668423; cv=none; d=google.com; s=arc-20240605; b=iBK/CGCdNSttNq6mD2fDAghPIkwsbQpdiiYoAfffLxvQ28cgj2iIVTqoDRU99VB+PM BFcOHHhukMRUVntyD4b5fFy3hcYGaluU4E9yJTjYps7dhscuRAeD2mssX+Jvhz+2xv4L lLkE6z1rZee58xjC80XRA8C2//hTtPnCiaOdrAT7gkKtCi842kKBeTfvZlMRt0fqF2U1 /3FvmSDDzZDxIsGrcvEWi2rY5VNSK0HcMDqi4KL2pfZm8gb2CeOWquhHaFFTFuh/BYph jH46LrJgTVVBagTnRVo2G+KKpIUOB0BHO56Zvvld1ZuH56rBK2lGuDfBfd4y1ZPeZHdz lh7Q== 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=bsL1HVl1m6AcYyh/4STTfTdb7EjKpNyrTD8MQ/unmOo4Mf3XsqpeY/RpGbQEc2iRzV 6SeguQ+2ksIUVHS5xSWuzu5+dIvHh8zd143SabHLSso/sEv2/1JB6FCbBoBXURjB4w+i 2VJ/WG0mHLxqvDz/obEAyWM2+BsWz0zxJ5yHmej84uB7uU9xXMTPa9dEaxiUrYSmNR6j 8CgVwIMHsXjhH+R5e70Pw7VuHnH1Nx4IyE3nkG1SjkefN63ut1dPYRe4tTphZYSp5elK SpphTp/9ZPqCnSBacvoWaKv4a30O+vcpebvhOGemBvpiUSyM1sA404wjx6yTG7/cIlgt qbTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y9dOPg+J; 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-7b9ac4cc62csi310693685a.355.2024.12.19.20.20.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2024 20:20:23 -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=y9dOPg+J; 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 1tOUM5-0008Ko-2J; Thu, 19 Dec 2024 23:11:13 -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 1tOUM2-0008Jj-Vu for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:11 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOUM0-0006Fr-3Y for qemu-devel@nongnu.org; Thu, 19 Dec 2024 23:11:10 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2166022c5caso12521185ad.2 for ; Thu, 19 Dec 2024 20:11:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734667866; x=1735272666; 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=y9dOPg+Ji83v30rY70HGLg5/rEjIeA+YGg4GGS+6YhSRr3k1kkDrRiME7BSWw0q14n dy/xwiHrYyBL5Pbo3WFKoEJvJBfz5J4jE9yeE1InMnjmqgWRHvOF6q3f1OTcNqopRKA1 s8WQGUl1rdTMmi1ppwugeJrSCFbnQSUnkq/uXJjth/y+xuG9NmhFbaByLVkCvhS7jNf/ aVvBCN3HtDjcR0oSOOPJxaNWsc4KeydyqBH4CKS/k/8M3ufRBrCxPkJcdK42OcYwKTM1 Yi2ac11VQhX0qfOC4+acwIXBHajnTaEQe9YOuM/Ixnglj41eJZ+/VxyOqg+lxA0OM+DY +H8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734667866; x=1735272666; 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=NGH3pxFVgePta61xL94uPuy3LTQwAz8yZt973m1semMsmqLA8XMN/1MeMq11uiKDHJ Iw3L6uI3HuypDtDhg1RC4xMHfbVgaACPk5c1a4uoGudJdJRlveSR9HGI+DYF4u2bGvu+ 4QXqDULYgLiwezj4z7ALpKVGzGde3CT4KqTD3YWRpQ+3FCjBwGyyfh69J7VKk6Z9rVv8 fUUflUuEwPPnAtZC9Im+3xgsBECTbs6buS0RW5XX6fYK8cIhIEcwTeOW3wcfuOEuutlV CNl3N9qVgEuXrP5FR9g8j6KVywjDosJMXCKvxesM1Xeen+tKHQ6JuFR19+WjcBEj9162 p38w== X-Gm-Message-State: AOJu0YzG9c9zXvX+Ip5hK7uxigcgdgf4AYUROIbGDEnLh0OY1NYNYnJu Sf8OAfg4WdSqWQoX6E8+GcAwHpJH+Tn3u7xBGrZOh66e85ubYY+qF2Q947BGd490yNh+GoOqKTn O X-Gm-Gg: ASbGncviRD/W2WblnlEJ4oWmy6Ib0Hix+pYsBZcAkHymjTYDW5m1EFMtNuJltbi19F9 eR/HQyH1tNrDjcLDcsEGlsxUEZKZGuZ13R6A8XEA3NxpQn2X3CIGTozFQFGCoZvrCmOjkIJQxdg b8LBvM8cBcX4/M5vx0fZ3BmZlsESedl4mKrCdtLpm0Kb2zhDY8A3L6zfXs0OTCG6ZwjsvMeuYKf R8qkSF5VWD5/WXE43XsSv+FtEqqZmFlIAczz8PQv2p41KZpRXLbBo6n+kQMH4k= X-Received: by 2002:a17:90a:d448:b0:2f4:43ce:dcea with SMTP id 98e67ed59e1d1-2f452ee5e95mr2088579a91.25.1734667866161; Thu, 19 Dec 2024 20:11:06 -0800 (PST) Received: from stoup.. ([71.212.144.252]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ee26fc22sm4165260a91.51.2024.12.19.20.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:11:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 01/51] tcg/optimize: Split out finish_bb, finish_ebb Date: Thu, 19 Dec 2024 20:10:13 -0800 Message-ID: <20241220041104.53105-2-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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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; }