From patchwork Wed Mar 1 02:56:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 657739 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp3269291wrb; Tue, 28 Feb 2023 18:58:05 -0800 (PST) X-Google-Smtp-Source: AK7set9Wc/xyLKWpMHFgrWs/aMbSkv4yAnGWw976g7Z0GHpU2nNMHPMoCkmDKZZ4FzjPMdc+1rty X-Received: by 2002:a05:6214:c85:b0:572:6e81:ae9c with SMTP id r5-20020a0562140c8500b005726e81ae9cmr24302098qvr.1.1677639485627; Tue, 28 Feb 2023 18:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677639485; cv=none; d=google.com; s=arc-20160816; b=p9QxFRIYRtHIXcFeMllD146Gd/b9G1pxQb1pTnjqRn/fGqrBjBBsSCVVMtoA3Rbryo 0+GmdI62s2490EgTecKbiOrA5GXT2V+9rhOmKasZqSHwbsIZONAj509hSKvCYxoFgjXz T4uETFEMEYTZdQ+qmbptK45cfy8auXXMuFUwi1IvwjxC0yfZ64T5luB5bgdHa7jFTURa mx8dowmfAa6/SC2j7UnM59KvskOr6E66V2de3GbfTjeyZv4fIZoUEFWnl5LnsJms9Tdq V6XCBoI8RPOZrNTaApSA/liJYW6SyIwqZY9e7uoAt4GYAhPvo+dVrl09QQQOq3QqFRG6 7Apw== 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=XHNQ406h/hUxehvnJIpfjbI2MbuZU/f56i9/YECKVw0=; b=dKfV0djJXCkchOZftRH0AbN4tCxLT4X+M6gvVWvxcuu3REZH9BwnM6FhrkGPUy7i35 WCfp5QmUe1yeXe5806nPo6UUQMgNQo9kdSPZ2Fj5qUZ+e1cdJmCr3ZOqZGEWdebdz8LA BH96uvjNlgU3umEJgsex0TnUyO7VuUXOHfd4I9SZZOTr4mLDtaxgwlV78xjH162NOBuN Dj9t8d4sc9sQZZPDJf7Ld1K49RDjaIMSBCIM2CAFvKdmhOhX3N2OhgfqFzJ1ckjlELWi H3yaiHVZ33oM6MNs4QP+aMCel629fHC4hQLX4KxQ8N6UWSdpNevc1uomehPC/mLpEA+m OwnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zvz3vA47; 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 187-20020a370ac4000000b0073b79da2960si9075394qkk.39.2023.02.28.18.58.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Feb 2023 18:58:05 -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=zvz3vA47; 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 1pXCfC-000372-NA; Tue, 28 Feb 2023 21:57:54 -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 1pXCfB-0002zy-UP for qemu-devel@nongnu.org; Tue, 28 Feb 2023 21:57:53 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXCfA-0003L1-38 for qemu-devel@nongnu.org; Tue, 28 Feb 2023 21:57:53 -0500 Received: by mail-pj1-x1029.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so11616636pjp.2 for ; Tue, 28 Feb 2023 18:57:51 -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=XHNQ406h/hUxehvnJIpfjbI2MbuZU/f56i9/YECKVw0=; b=zvz3vA47xKehc+VGKZsOyfbMJePjfQ1mdvvEtAiteXlhkNZmE1pfI5ZeaVs/JOSyka nshEZRlFVgxbGZO/E5dXwz1fvQ76y5pyJn//yDBZZEAe7ZzUdZ/tnqqPxay8DBIuBhk2 FMnYIFP5XYj5boj5sUKySIgKWXmY4OhKObWeDeMt8FhXrgTlRwTfVuTA5nAKy5u6477A +HBlt0sqaVt3xyvHFlj9dSBqXodL1FPOBhha/wMEmZlNRM4HuCkvYkIlzyv+Dj0bstj5 ktj0Cil7NGGbfXVLzJIWcK8kXfPXArBCisZ3nQ+gGdRMcRyKdwghtIxP+mcCqrz6sH// 47hQ== 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=XHNQ406h/hUxehvnJIpfjbI2MbuZU/f56i9/YECKVw0=; b=o0LtvbWYKtP3cP9LQpoU8Z1lMxVlgbQcfiEB/TL5ns8SlUSESD6JqiGceOaaj7g0DD PGfYFyO9b/oOE4brYmKjArQ/TQVdIHRzfS0Oa3h9sy/xIZJsWjRhVcDwQT+J7546YTjz rp5UtzNRghduN8WmcNT2yc5H/mOsoqojWj9+AaFuPW6eLdLwdPd0FJKVx0xZGFQaNtfV r7T38112f2mqgjlbOKObKqO8roD/d/3V5HX85HcrPb160b2jNIDGtRg0ZMc0+PmX8121 DGangcxNn1dgISTsBwm2D5WhAkV8X1SgZ7s72ytleD5HJaFL1cIPbpHstFw2pSwRckat 2mSg== X-Gm-Message-State: AO0yUKWSekELRrTyxUWaxk2h0UoInJSY0lV+yD167VS/c7eaY4Ggx+gT wTMPp2j5uszbxPNkAMtt13zV4zw5oDoNs1tpQ54= X-Received: by 2002:a17:902:cec1:b0:19a:a305:e367 with SMTP id d1-20020a170902cec100b0019aa305e367mr5594986plg.30.1677639470558; Tue, 28 Feb 2023 18:57:50 -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 jg15-20020a17090326cf00b0019adbef6a63sm7210120plb.235.2023.02.28.18.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 18:57:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 38/62] tcg: Add liveness_pass_0 Date: Tue, 28 Feb 2023 16:56:19 -1000 Message-Id: <20230301025643.1227244-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301025643.1227244-1-richard.henderson@linaro.org> References: <20230301025643.1227244-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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. Reviewed-by: Alex Bennée 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 71b6843eb1..1dbb24294e 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2857,6 +2857,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. */ @@ -4872,6 +4941,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) {