From patchwork Sat Feb 25 08:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 656455 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1352597wrb; Sat, 25 Feb 2023 01:04:12 -0800 (PST) X-Google-Smtp-Source: AK7set/CZQi8QQjcE6EYFiNZtCE4qLEvu3mflxxvSW/Y/+cjgA/bn46TwM17/WlGlWmDeFXx76CE X-Received: by 2002:a05:622a:1048:b0:3bf:a7c1:46a3 with SMTP id f8-20020a05622a104800b003bfa7c146a3mr26361140qte.37.1677315852678; Sat, 25 Feb 2023 01:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677315852; cv=none; d=google.com; s=arc-20160816; b=0Blqchj0/pbpT7uIag9La8T7Ok7xXrwKidASquiRxzgUdYKbwqSYlb+EI3iaqfE2oM FXWtkk2jPLyYb+yTcEsuZYFHeQR1YRTKCuQRxJGyGTXgnWWtUASMkY0Mlmby6WK2CfMV 2zSHco/zbivcer0B+el546DRQQKs/Q+VJur/jeETVgQVecM91PHGAMUMzdS841Wfjw93 3wqQ5DyrNdun+EZpbQY0O1EbGCzwcRab0S0w3M+0XksoZ/RmFu3vFIBQv2sGIOovv+HF wepVBSD8BajMx67E3DvkLqFVPc0zYU6Mrs7vzpIUjl72ryckHUEg0mHMifApRqlEjpuk qDTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=z2yx2ICVs1zB6ngtjHL2Am0/1UDD6BkdCpu6nOfJ5a4=; b=S6YTO7gSvOOgNi5R7B9+J3A2Yn5h00Pt4rxpPxwrBIWfw2k8ihcUWPErUMBVFple4m wvWL8upZnuPhYz0g/7LkJkF2r6NFbnoS54vH/FwAqaO7XCtAjJuuieZ60O2OQnNY2vqF W6jv3IoFOMvsJLb/XVoQP/5xLICj+aB0g8R5+fwgcljqLPJ4550FToFB9M7lfzsiIS8D J6kHmQ+qzud0SB6cqULgWtzg9Rn1Ez8vnfyj/56lUI1k3fPJhXhtrFjisTJqkSLcjbkL p0X0AGZRO3oyR833C84tkF5SxwMuYYNwJa/mkw8YRxm/xmXTQZcqS02IZdqTJVroatUc G0pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v9lm36CY; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n128-20020a374086000000b00728578b7527si1231917qka.528.2023.02.25.01.04.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Feb 2023 01:04: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=v9lm36CY; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVqPV-0000Po-Ah; Sat, 25 Feb 2023 04:00:05 -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 1pVqPT-0000Ov-JI for qemu-devel@nongnu.org; Sat, 25 Feb 2023 04:00:03 -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 1pVqPR-0004py-Es for qemu-devel@nongnu.org; Sat, 25 Feb 2023 04:00:03 -0500 Received: by mail-pj1-x1036.google.com with SMTP id kb15so1419689pjb.1 for ; Sat, 25 Feb 2023 01:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=z2yx2ICVs1zB6ngtjHL2Am0/1UDD6BkdCpu6nOfJ5a4=; b=v9lm36CYsz0pY/5+dHGw+39kLu3Ovsl1a3EMjRflFYU8VOA3RKWqv7P/JdWh9iYV54 E6RuGa8URdsV9cXDFZc34xBhXAkSyzmcjmW4EojnLJADMRzIHuYh2uGGGLWi6M4tAMhq NdC6tvks5hK0ijVakH8Z8UUzPgWbia9bd83y2lPTn3aTyMwLrj50n7PA5SMqHGqbjgaL qwcTiSBAdkDBQMeEEn9TMXi6/YhVn4iNptgUlx+im6xt6wbusN1Nm903k8G1rf34+Zlw lgpFdL4nSkuuliQ2mi2fUH6QSGlZEhucqH458vQxI3OEWBwKSw5wpkkpeLyAKgFdds0W DTiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=z2yx2ICVs1zB6ngtjHL2Am0/1UDD6BkdCpu6nOfJ5a4=; b=z4VjHOAtWSOriqHp0TER255RdmWukCf/wwF4F81On+k3OH7V203kEAGy76lnu9Qk0P 7NOG6X9AyBh2jjIUFBp7jDHIZ8xPx6UC+NgJOdC3OKbQk/5dJj4V624Il1G3rTLSjZ01 0pKIhE0HHy1vDXFuCGtBDqUrn849p2uQFgOC3gQfegF1UfdtaqHlqbUUSy/Zif11O4IG Q+DEZYZiPDRKKxI8a2D+4RfZJ87SowmcG+6icVW+xb9jQ+ylIfjIIbb0/fUeM3+4aSVY jTtDhDIJtH78xQzGTSR/aKBfrcg2h33koDCMaLMj1lmj1DuSvV6KPw+hvHMD9DjP0spE G5xw== X-Gm-Message-State: AO0yUKXtVFcs3YbWZ/ooiDb3WcDhNJwpToQoIbJB/kXJe0UGFYr3fKG1 4VT+6+AUQPo109mJ2ZpGV7+4suJRtS1+IiAxgqE= X-Received: by 2002:a17:90b:3ec9:b0:237:ae7c:15b9 with SMTP id rm9-20020a17090b3ec900b00237ae7c15b9mr3292416pjb.36.1677315599868; Sat, 25 Feb 2023 00:59:59 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id s17-20020a639251000000b00502ecb91940sm715546pgn.55.2023.02.25.00.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Feb 2023 00:59:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH v3 07/30] tcg: Add liveness_pass_0 Date: Fri, 24 Feb 2023 22:59:22 -1000 Message-Id: <20230225085945.1798188-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230225085945.1798188-1-richard.henderson@linaro.org> References: <20230225085945.1798188-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 Attempt to reduce the lifetime of TEMP_TB. Signed-off-by: Richard Henderson --- tcg/tcg.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index 7ee935701a..6646770268 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2858,6 +2858,75 @@ static void la_cross_call(TCGContext *s, int nt) } } +/* + * Liveness analysis: Verify the lifetime of TEMP_TB, and reduce + * to TEMP_EBB, if possible. + */ +static void __attribute__((noinline)) +liveness_pass_0(TCGContext *s) +{ + void * const multiple_ebb = (void *)(uintptr_t)-1; + int nb_temps = s->nb_temps; + TCGOp *op, *ebb; + + for (int i = s->nb_globals; i < nb_temps; ++i) { + s->temps[i].state_ptr = NULL; + } + + /* + * Represent each EBB by the op at which it begins. In the case of + * the first EBB, this is the first op, otherwise it is a label. + * Collect the uses of each TEMP_TB: NULL for unused, EBB for use + * within a single EBB, else MULTIPLE_EBB. + */ + ebb = QTAILQ_FIRST(&s->ops); + QTAILQ_FOREACH(op, &s->ops, link) { + const TCGOpDef *def; + int nb_oargs, nb_iargs; + + switch (op->opc) { + case INDEX_op_set_label: + ebb = op; + continue; + case INDEX_op_discard: + continue; + case INDEX_op_call: + nb_oargs = TCGOP_CALLO(op); + nb_iargs = TCGOP_CALLI(op); + break; + default: + def = &tcg_op_defs[op->opc]; + nb_oargs = def->nb_oargs; + nb_iargs = def->nb_iargs; + break; + } + + for (int i = 0; i < nb_oargs + nb_iargs; ++i) { + TCGTemp *ts = arg_temp(op->args[i]); + + if (ts->kind != TEMP_TB) { + continue; + } + if (ts->state_ptr == NULL) { + ts->state_ptr = ebb; + } else if (ts->state_ptr != ebb) { + ts->state_ptr = multiple_ebb; + } + } + } + + /* + * For TEMP_TB that turned out not to be used beyond one EBB, + * reduce the liveness to TEMP_EBB. + */ + for (int i = s->nb_globals; i < nb_temps; ++i) { + TCGTemp *ts = &s->temps[i]; + if (ts->kind == TEMP_TB && ts->state_ptr != multiple_ebb) { + ts->kind = TEMP_EBB; + } + } +} + /* Liveness analysis : update the opc_arg_life array to tell if a given input arguments is dead. Instructions updating dead temporaries are removed. */ @@ -4873,6 +4942,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) #endif reachable_code_pass(s); + liveness_pass_0(s); liveness_pass_1(s); if (s->nb_indirects > 0) {