From patchwork Sat Dec 24 23:56:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 636685 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp931630pvb; Sat, 24 Dec 2022 16:08:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXtB7UzEAiS/O/dnENFyL36RxXDsu2OD6fM9NdCo8QGRNmFhuI6XTk4VM+0ZS/WA1wS1Av7j X-Received: by 2002:a05:6214:15c6:b0:4c6:d665:a6ba with SMTP id p6-20020a05621415c600b004c6d665a6bamr36099499qvz.22.1671926929804; Sat, 24 Dec 2022 16:08:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671926929; cv=none; d=google.com; s=arc-20160816; b=jDFB2/M+zWKaOSLSYBeMCp6JTzyC7B/xIMN/9ZRnuhVQiqeLNBNUyxR9KpQqZaq3YP tO3AhZfVudrqygqhwYhTbXI5NMVcK+QA7nGpzhf6erVvK6s0n3nCzfX8DiB7PzpDK35G b4T4MQLui2cvvRCpQq44rk3SowLAmbPo/RGPSO9T6gWnXaaUJXoESmQW5JiJ//h0HXqu GHr3W2XPUFkQ4OITMM9aeujjkl/8OTFdzSxx11R7sPtNl4t+4+z6ZfGelaa4TnTVrTYJ wZr4S87EejuHy32GIGZbPnS7Pkot/r33GFBGMvtpP4/uogRqEyQeVrZQd41FHkFYVFhF G6BA== 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=vtHTxOsR6ht0+9SPiWHuqeFVG+XUj4+DdhfsvFYW/Qc=; b=b5TiWPBPtlQP0c3bt3lu7jB8jCI6bSOfjhpJTVleJPHY9pwy5R0XS2t7uOq86RW4GK u0rXal17+zdp/drkdmpONZsCyweJ/NPPqMk9cboKWnmyctCHiz78mkyeIZuVaILIoaED z/ZEk7dyItKvlreE9xhjhuo2y0BhT09wL39rF/f8uptjhRtyAmDOrXuPkFz4K8QoTvHJ sN+M6b2phetK5RLHEIxMBpAqkmIlIfrnwdiVYYBYk3DWdQjU2cpViFt7URCGyK2Wdgu7 TrRAUOF7ro8YjTJPz8Dv4gJogcAo2khkhPc9cJ+3fIkgJB+6K2JlUEkbk5gnHXS/BWil TRJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qT5zVeDN; 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 gu8-20020a056214260800b0052553dd6c8dsi2903562qvb.362.2022.12.24.16.08.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Dec 2022 16:08:49 -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=qT5zVeDN; 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 1p9EOY-0002Ko-Hq; Sat, 24 Dec 2022 18:57:38 -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 1p9EOW-0002Jl-Pr for qemu-devel@nongnu.org; Sat, 24 Dec 2022 18:57:36 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9EOV-0006GI-48 for qemu-devel@nongnu.org; Sat, 24 Dec 2022 18:57:36 -0500 Received: by mail-pj1-x102b.google.com with SMTP id p4so7977125pjk.2 for ; Sat, 24 Dec 2022 15:57:34 -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=vtHTxOsR6ht0+9SPiWHuqeFVG+XUj4+DdhfsvFYW/Qc=; b=qT5zVeDNWmXJlpLGFcl6eBYmLzZT5M5rf1RsTaAvmzwWUGKEfOl02tIZjrOdoKJ2K9 3uH6+NF84wnrGzso60m5pDu+PJGWPCtrN6zDmbkogCl2guzIF1rf7qrxQuDscVyu1dX4 3ocTiFPrGd6h+OR63qtETHgfS3Byx8NQPAy6e79FkqmJhVx72dWRmbl9dPZyTfCytAd5 vqFy4GaYsqqfkYaFZnOB/clF/GN7AgG7LE16IkyYP7joPjK0+RwSd6iAjyUTrYCWHsy5 gm67Hznk/xeJ48/vK9Az04VpA/dWmkoerzqShv70I/bwXAHe1pPBC7eVEqLG+Y0N+dXx GEgA== 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=vtHTxOsR6ht0+9SPiWHuqeFVG+XUj4+DdhfsvFYW/Qc=; b=wh+pG1pdjVThTohEJua0UJyEWT2Lrmqo1/kbqf/Qj2+aabzyjWaufZEt5f+dHTbzRS jfuPb0tKkvI4YciDbRBc9KH+yA3LdfND1BHOlkPYoJONPKggNEYFFH+s71IP2VbyWqWX u1qSfLmdkse2P8qVQOdNfXxyoZOBIIT5WUgp1dzjEQ8m6YD2/MGzndmHwz4kcKWm0V0M WrFkCmWUu1HqsL8fGcG7iSqvKuVVkL4iFRAlL8Ff+Eo/IPeoPPLhIztqyhy6+wffD/s4 GgUNbAgSwHpLiStkEcPTv1V0lScSLEI7rRP7H+RKVPgoMWJXQIJLJn9p9qXjmub6wGcF 8uwA== X-Gm-Message-State: AFqh2kpYWGluSdParm0tYR1Eq/QqdmOxCldsNq0hgTqgnOmIzYD8BjaW CFbYpPUh+3RBM4D6B86M/ywzE1X4bMqK+5ha X-Received: by 2002:a05:6a20:7d8b:b0:aa:23cb:a1a6 with SMTP id v11-20020a056a207d8b00b000aa23cba1a6mr46409724pzj.0.1671926254310; Sat, 24 Dec 2022 15:57:34 -0800 (PST) Received: from stoup.. (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id cp12-20020a170902e78c00b00187022627d7sm4599716plb.36.2022.12.24.15.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Dec 2022 15:57:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH v5 12/43] tcg: Tidy tcg_reg_alloc_op Date: Sat, 24 Dec 2022 15:56:49 -0800 Message-Id: <20221224235720.842093-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221224235720.842093-1-richard.henderson@linaro.org> References: <20221224235720.842093-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 Replace goto allocate_in_reg with a boolean. Remove o_preferred_regs which isn't used, except to copy. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index db64799e03..215ddf2db5 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3607,7 +3607,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { - TCGRegSet i_preferred_regs, o_preferred_regs; + TCGRegSet i_preferred_regs; + bool allocate_new_reg; i = def->args_ct[nb_oargs + k].sort_index; arg = op->args[i]; @@ -3622,9 +3623,12 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) continue; } - i_preferred_regs = o_preferred_regs = 0; + reg = ts->reg; + i_preferred_regs = 0; + allocate_new_reg = false; + if (arg_ct->ialias) { - o_preferred_regs = op->output_pref[arg_ct->alias_index]; + i_preferred_regs = op->output_pref[arg_ct->alias_index]; /* * If the input is readonly, then it cannot also be an @@ -3633,30 +3637,23 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) * register and move it. */ if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { - goto allocate_in_reg; + allocate_new_reg = true; + } else if (ts->val_type == TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg = tcg_regset_test_reg(i_allocated_regs, reg); } - - /* - * Check if the current register has already been allocated - * for another input aliased to an output. - */ - if (ts->val_type == TEMP_VAL_REG) { - reg = ts->reg; - for (int k2 = 0; k2 < k; k2++) { - int i2 = def->args_ct[nb_oargs + k2].sort_index; - if (def->args_ct[i2].ialias && reg == new_args[i2]) { - goto allocate_in_reg; - } - } - } - i_preferred_regs = o_preferred_regs; } - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); - reg = ts->reg; + if (!allocate_new_reg) { + temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); + reg = ts->reg; + allocate_new_reg = !tcg_regset_test_reg(arg_ct->regs, reg); + } - if (!tcg_regset_test_reg(arg_ct->regs, reg)) { - allocate_in_reg: + if (allocate_new_reg) { /* * Allocate a new register matching the constraint * and move the temporary register into it. @@ -3664,7 +3661,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) temp_load(s, ts, tcg_target_available_regs[ts->type], i_allocated_regs, 0); reg = tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs, - o_preferred_regs, ts->indirect_base); + i_preferred_regs, ts->indirect_base); if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { /* * Cross register class move not supported. Sync the