From patchwork Wed Feb 22 23:26:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655705 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp36024wrb; Wed, 22 Feb 2023 15:28:41 -0800 (PST) X-Google-Smtp-Source: AK7set+T1DTDZC6x9hhbwjS/WbK6kk67PUaY8V8iVTRDQZ398ITmtf6bBphGMdC+zZiNh1suoQO5 X-Received: by 2002:ad4:5bef:0:b0:56b:f09e:9ab0 with SMTP id k15-20020ad45bef000000b0056bf09e9ab0mr17492725qvc.5.1677108520995; Wed, 22 Feb 2023 15:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677108520; cv=none; d=google.com; s=arc-20160816; b=nhvUqUlbOawYB4712qNxe6uuHTii9hgMP94jDMwkYwJ1lbfsDUkjhYh2PWdk504k64 8u4kCCOlEM/BUlrvQjfLDMGeOqej/kYSj7zHVdH28NNNcQDwR28qhJH5T+9BUe/ilzym npj+ZFLUFG7zjg3bZwzyrfWXD7WAdEwxtWME7k5rEz0Ku4WPwutSmKQBhl4sxQo7IFoY Lsn/5MZwZfN0BzwBPxQYLdChq+m3oOqVlSEKSG2M1UMZytsJAu17N+ZKxiBtTSD4tSnQ ymW5ic1QCituwcolR9ytHEjueVjtDg1O+X9aaNoi8Zfu8k762ZFQnUeu+99VsHFIY6DK mSbQ== 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:to:from :dkim-signature; bh=+N5bQjUnjMOfQ9Q0ZNUmrWXqHC77HMHd7kbnKb9ea14=; b=ewBhG6lSCuJCYB2C03GKiEGaRywYCwR55o+lG9cl/lf+xKQtVOY2F9ZdLgZlX9BM3U CWYkpx6rBhN4WoGaQ/9GWMzzeRTC+ip4luplHyua7Z/+p5V3fR6rOuO/RnaEV8Xojc48 GH3ely2d6ej0NYj+2cwDwIPg7sL341EpuZdDC9qnjAwoS5WVK5J9jTf0p5Hwt7VFWCz2 5fRxPq2HN/bCCUm6WWTuROyIzJ7nu0Ijkat8IUSKvyKehDZ1WtgLovD1c4xBKhPrShPS PGwNauSaJ5NAHonBBfqY9W0V8DxDHo6W3JExP3vDQrFW0cMLa39DEjJvQ19Ct2WbjEK7 MK/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p1gacrw8; 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 y26-20020a0ca91a000000b005376b3d80f8si717895qva.569.2023.02.22.15.28.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Feb 2023 15:28:40 -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=p1gacrw8; 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 1pUyWI-0000Pt-Kw; Wed, 22 Feb 2023 18:27: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 1pUyWH-0000Og-1R for qemu-devel@nongnu.org; Wed, 22 Feb 2023 18:27:29 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUyWF-0005JA-AA for qemu-devel@nongnu.org; Wed, 22 Feb 2023 18:27:28 -0500 Received: by mail-pj1-x1030.google.com with SMTP id x34so7424736pjj.0 for ; Wed, 22 Feb 2023 15:27:26 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+N5bQjUnjMOfQ9Q0ZNUmrWXqHC77HMHd7kbnKb9ea14=; b=p1gacrw8242h1JWdDCzX9jtB6QyDRoxRRYiKWEgVCFfbON58yAXOBfFQtxXpikQK7h ThU7xQ24U0x004dOHoysoBhmJkeC25ZvVhD6w3bKo+Z03cB/wDwr4Kz5P1yZ+IDKXwLr V1HvpAxiOr0CxT/XGHl88XVGRhsP3ygwZjrdxiKycc8+X/Uic3f7pkxL3ycfmM+NbJCC QPS2Q+A48jiaJQSTx/FF0XEviM3u/XrioRoAZobvuRHCfOzxa6UR7ThAKbdAggXjnKCr ca3AJM+r6b53JuOLqt3mKJu/L43HQX9/TBpP4jtrQk4pStpRhSWiZv56BCQKJBdexjQ4 Q3gw== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+N5bQjUnjMOfQ9Q0ZNUmrWXqHC77HMHd7kbnKb9ea14=; b=FvvbBxnjqV3H1okS0nUm7OlAdEHvR2EHK3IIJMWcNq0mtvsKTFzEvrc8bKRy61MhOp Dr/lWJeM9StQ9uiee7TefMOkKOlikPoVDAksgdWdsfS4Px4lOvsMByersqD8YgXiVGzH /ymre4SY5PdjSAlzGO2JoiaP5o4DL/FfoJ1fZtDYe8py3/FFwlYkNJKcQhAROSBL5PTd Kg5bFb8E4md3eS77J4vjKuCYRm4yKJ4EreIfd3uz+ivju+6EcFz+QnH43xxZy6+S3ydU YMLvHoPg5izIqADd4/n+ixPW4gaBv6Kz7P15RrZn4UocXKH5Xl7qO37wrCuJMGts59l3 qkOw== X-Gm-Message-State: AO0yUKXbyISOK71y0sIsEna14aHgRa0NptYZP/tlCTkYIrpJgV83AKax UG5bp1dYbJIP+DHkA0f4A8U4sIhGmcY4bK+YL2Q= X-Received: by 2002:a17:90b:3b4b:b0:233:d5a8:16 with SMTP id ot11-20020a17090b3b4b00b00233d5a80016mr12073229pjb.0.1677108445906; Wed, 22 Feb 2023 15:27:25 -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 s16-20020a17090ad49000b00234e6d2de3dsm5008918pju.11.2023.02.22.15.27.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 15:27:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 06/28] tcg: Add liveness_pass_0 Date: Wed, 22 Feb 2023 13:26:53 -1000 Message-Id: <20230222232715.15034-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222232715.15034-1-richard.henderson@linaro.org> References: <20230222232715.15034-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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 | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index bf2af8b0fe..8d4ce7bd1e 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2857,6 +2857,74 @@ 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 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. */ @@ -4870,6 +4938,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) {