From patchwork Wed Feb 22 23:27:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655710 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp36346wrb; Wed, 22 Feb 2023 15:29:25 -0800 (PST) X-Google-Smtp-Source: AK7set/zyfxIFAUlNxwvzA1vL+o9aDaRMPfd4d8lqF+iRGTBkFsdZnq7xUN+ymOyrfWPDtgLOS28 X-Received: by 2002:a05:622a:304:b0:3b8:4694:b727 with SMTP id q4-20020a05622a030400b003b84694b727mr18796192qtw.55.1677108564947; Wed, 22 Feb 2023 15:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677108564; cv=none; d=google.com; s=arc-20160816; b=q/WqmsfYIKu8iziUD+uYYtb/YW2kgHbdAi3DvblVJAL4U7bnA5o4RB4ORGdRCkan/d ih+8I/dwEHcBzr90parhl70CEfHxa8YvKGai4Wt41hRKm26bupskvRjc99bMEjLSCSJ7 a+bHWVbXTZRAdKCVk6daQN0FRuyXyCtH0/FyXL76vQzNlgKrB4qOzRKznoVJH7gYaFor M+eLe8xA3QUDqgfyyFyYMUcyN+WWlSgnDqcJLjT518UUKe/xjLpizGs0yXvD5V+0GKzc 3dL7jLfrnd33NFVEeWCwGVUELwiAZ/X9wux+cqf5y1jn/ZzRHTtWE/2Jaqot/TPVmrXS ZyqQ== 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=nZywVGNbdFCpTtKhrWeTFNuLpgXZYO5r09C/W3W1oBU=; b=wQPgVnoRWdYqMhTGCfmM6TSlUQzDdbwIVZz3oCK1zsdHQYA1tqtz1aMtyTa6CIt88R mHn+bYuauJZXSDjhKZb2nWFbYRV9SrR2Imob6oxEoM3FZ85/PXxDhVMiV6h3kowUdCeP 8vOUSxpXWp00yPHj9PQNpt1pCxRnOAM+KjjYk/OkruTebTq6e6xfyqjBmAhJIqXuzhGF zhhWs/yLlkEY2Dy58F+63Nf3FeXp2c4L5JYD3Dqzxxrt9iLPp/yVzWMi+kkwQuP04+Ex wR992qAgHiTW2/me1oinTGcNoJqER10EjIaIrWxNYOiNK7CyyWgLgsZ4Zjy+lbGlINil BJYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JXhBYk2R; 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 q15-20020a05622a030f00b003b9c57746besi1108208qtw.622.2023.02.22.15.29.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Feb 2023 15:29:24 -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=JXhBYk2R; 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 1pUyWU-0000Tk-7b; Wed, 22 Feb 2023 18:27:42 -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 1pUyWS-0000T6-Pz for qemu-devel@nongnu.org; Wed, 22 Feb 2023 18:27:40 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUyWR-0005LL-4K for qemu-devel@nongnu.org; Wed, 22 Feb 2023 18:27:40 -0500 Received: by mail-pl1-x635.google.com with SMTP id h14so10922382plf.10 for ; Wed, 22 Feb 2023 15:27:38 -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=nZywVGNbdFCpTtKhrWeTFNuLpgXZYO5r09C/W3W1oBU=; b=JXhBYk2RJ0D8xhYjhS74pPcrEdM0VjsxQa4VzbPbls4FUETToagiyVDs+ugnXQEVdO 900NEUbtJ9N+o9fK8aLYvetyD0/odZL5q51Z6PuPzZvwRR09ADyfXfq+pLZwhgwBtnk2 clhJvK6BKdtdQqUVbF/yraHjyIt+oB9Fp++05y4NxEt6VdipO6kYcwLXR/xGteynObRw 76fkevrZQo7UCIJfXtkNGRM5wpKO+vUvBzmIRe0r10hROlrIBAxBorz9Y9OsgQGcH2hN rvRSEEzAIK4ckxg33JzH22bh1y0XGPQEh3Wfg934P1SABKI9ahbdywQkKvvRl12z3PF7 a13w== 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=nZywVGNbdFCpTtKhrWeTFNuLpgXZYO5r09C/W3W1oBU=; b=7AU2UYSgxXCfLkUhLYH1OK8EDmO5LD7k18ibcJm2LbcoKweJRFHL48xPwIxw/s/BZF KqWvcbLLhSg0OaC6cQnhAG03hSwkz1Uq1PSNeo1oRePgfXXO2SAYM7/aZIs33zXhPYK/ jjABvv7U1FqXhgPWU5AExN6RNXL/jMtDRONUvEC8UjSaq/B1wy4HJUXFB1KxukxVnGaQ 8oi2J28fDvTO7dQg1AHiY8GMyqskOWK+wIps/DphZHhBD34/zpACUy5ktK9hbeKFtS/3 ORMLvBqNQsXPmDRgEwOjFh8IkfcqN9cNMPjQ++Qgr/z1es+draZruMcxP+DfCYbZTDCQ xgrQ== X-Gm-Message-State: AO0yUKUAsKH9USk4t7IHEvQm1JqwfwkOI7aawDF0JMtYPrU7wSngIjmf Y+DteIYCkIFBNIBhk6mxHlecMquGP/evEDjopnk= X-Received: by 2002:a17:90a:1944:b0:236:a3a0:f49b with SMTP id 4-20020a17090a194400b00236a3a0f49bmr11809715pjh.41.1677108457488; Wed, 22 Feb 2023 15:27:37 -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.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 15:27:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/28] tcg: Don't re-use TEMP_TB temporaries Date: Wed, 22 Feb 2023 13:27:01 -1000 Message-Id: <20230222232715.15034-15-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Reusing TEMP_TB interferes with detecting whether the temp can be adjusted to TEMP_EBB. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 101 ++++++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 0c2041bcf7..6cc6758cd6 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -612,7 +612,7 @@ struct TCGContext { #endif GHashTable *const_table[TCG_TYPE_COUNT]; - TCGTempSet free_temps[TCG_TYPE_COUNT * 2]; + TCGTempSet free_temps[TCG_TYPE_COUNT]; TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */ QTAILQ_HEAD(, TCGOp) ops, free_ops; diff --git a/tcg/tcg.c b/tcg/tcg.c index 06ac9d5ab8..9f1b042ecd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1258,63 +1258,66 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) { TCGContext *s = tcg_ctx; - bool temp_local = kind == TEMP_TB; TCGTemp *ts; - int idx, k; + int n; - k = type + (temp_local ? TCG_TYPE_COUNT : 0); - idx = find_first_bit(s->free_temps[k].l, TCG_MAX_TEMPS); - if (idx < TCG_MAX_TEMPS) { - /* There is already an available temp with the right type. */ - clear_bit(idx, s->free_temps[k].l); + if (kind == TEMP_EBB) { + int idx = find_first_bit(s->free_temps[type].l, TCG_MAX_TEMPS); - ts = &s->temps[idx]; - ts->temp_allocated = 1; - tcg_debug_assert(ts->base_type == type); - tcg_debug_assert(ts->kind == kind); - } else { - int i, n; + if (idx < TCG_MAX_TEMPS) { + /* There is already an available temp with the right type. */ + clear_bit(idx, s->free_temps[type].l); - switch (type) { - case TCG_TYPE_I32: - case TCG_TYPE_V64: - case TCG_TYPE_V128: - case TCG_TYPE_V256: - n = 1; - break; - case TCG_TYPE_I64: - n = 64 / TCG_TARGET_REG_BITS; - break; - case TCG_TYPE_I128: - n = 128 / TCG_TARGET_REG_BITS; - break; - default: - g_assert_not_reached(); + ts = &s->temps[idx]; + ts->temp_allocated = 1; + tcg_debug_assert(ts->base_type == type); + tcg_debug_assert(ts->kind == kind); + goto done; } + } else { + tcg_debug_assert(kind == TEMP_TB); + } - ts = tcg_temp_alloc(s); - ts->base_type = type; - ts->temp_allocated = 1; - ts->kind = kind; + switch (type) { + case TCG_TYPE_I32: + case TCG_TYPE_V64: + case TCG_TYPE_V128: + case TCG_TYPE_V256: + n = 1; + break; + case TCG_TYPE_I64: + n = 64 / TCG_TARGET_REG_BITS; + break; + case TCG_TYPE_I128: + n = 128 / TCG_TARGET_REG_BITS; + break; + default: + g_assert_not_reached(); + } - if (n == 1) { - ts->type = type; - } else { - ts->type = TCG_TYPE_REG; + ts = tcg_temp_alloc(s); + ts->base_type = type; + ts->temp_allocated = 1; + ts->kind = kind; - for (i = 1; i < n; ++i) { - TCGTemp *ts2 = tcg_temp_alloc(s); + if (n == 1) { + ts->type = type; + } else { + ts->type = TCG_TYPE_REG; - tcg_debug_assert(ts2 == ts + i); - ts2->base_type = type; - ts2->type = TCG_TYPE_REG; - ts2->temp_allocated = 1; - ts2->temp_subindex = i; - ts2->kind = kind; - } + for (int i = 1; i < n; ++i) { + TCGTemp *ts2 = tcg_temp_alloc(s); + + tcg_debug_assert(ts2 == ts + i); + ts2->base_type = type; + ts2->type = TCG_TYPE_REG; + ts2->temp_allocated = 1; + ts2->temp_subindex = i; + ts2->kind = kind; } } + done: #if defined(CONFIG_DEBUG_TCG) s->temps_in_use++; #endif @@ -1359,7 +1362,6 @@ TCGv_vec tcg_temp_new_vec_matching(TCGv_vec match) void tcg_temp_free_internal(TCGTemp *ts) { TCGContext *s = tcg_ctx; - int k, idx; switch (ts->kind) { case TEMP_CONST: @@ -1383,9 +1385,10 @@ void tcg_temp_free_internal(TCGTemp *ts) s->temps_in_use--; #endif - idx = temp_idx(ts); - k = ts->base_type + (ts->kind == TEMP_EBB ? 0 : TCG_TYPE_COUNT); - set_bit(idx, s->free_temps[k].l); + if (ts->kind == TEMP_EBB) { + int idx = temp_idx(ts); + set_bit(idx, s->free_temps[ts->base_type].l); + } } TCGTemp *tcg_constant_internal(TCGType type, int64_t val)