From patchwork Thu Oct 20 11:52:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 616788 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp334354pvb; Thu, 20 Oct 2022 08:16:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7GOXF61Owi1I9trKNBD+OOYFFgjuqM91z1WWr6TlxpjVbmV7eZoI+4LWoJ20T17hf6LKxX X-Received: by 2002:a05:620a:1329:b0:6ee:dfb8:d438 with SMTP id p9-20020a05620a132900b006eedfb8d438mr9124562qkj.686.1666278983977; Thu, 20 Oct 2022 08:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666278983; cv=none; d=google.com; s=arc-20160816; b=Y6MNS3VstD+8p4n/W7mUCIq+X582QYg2DCh9Maz3SWaBF08ZotD0WtxkPga9T9xnI/ CCt9WB1qYBp2/69cEjq1MFZ0lUEVr15zRaf/z2yMFG0/ya3DFOYFe6YQbJwlNINj/ylY bkOwDoRU99qfRLQILwX6whfq+bS1hDr1V+DaNQ0f7+9EdfhzUPQb5aDNbmAYttnGUq4e 5sw8ubKcfCWtBfueCmWaamQfRPpCCGuJ91n1LsHqQyPZ7Yt2mh9znRAlu0zoyRGv1AJh ptqDA+yxLBEy6URkWZRIJ+1mMd4h8tQmHgMaLn/EYptTUhPvElhJ22qlW1wZkB6b1y6y vGIw== 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=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=p6wig7am/wu2jebOC8bItaWTFiZ9qPjOPTVIJmjPt0u3LhJRufpBs4Va5ZIyG+Ueg8 jeOh9VLEARaFbzLnWM4GCXyVZXA12phcv++pEoK0hFUI5gXOy/dLgGBXJDvWr5+i9qyZ qSSYnP1vhOHFgBzvwWOqsJvYtry9wg0VqEjjXnRuGHiJw6WXkAArgrIpaJumuOvAOLAy jlGOWqzX/orLKtUDnCiFfP87HgPBydQulP0CS/A7zw20NViGHOeiZoNowpHQsgeMzzxQ MTFTDbAxcWpnR7RKvEb6OUDHEnpondHnw686v1e29U4u8bC73mMqxg1clZHhhH8+uuY8 HI1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oIOEqy8l; 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 d8-20020a05621421c800b004acd6af5b16si829384qvh.435.2022.10.20.08.16.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Oct 2022 08:16:23 -0700 (PDT) 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=oIOEqy8l; 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]:37676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olXHK-0006bO-WB for patch@linaro.org; Thu, 20 Oct 2022 11:16:15 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olXE2-0003hG-3W for patch@linaro.org; Thu, 20 Oct 2022 11:12:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olU7G-00044e-LH for qemu-devel@nongnu.org; Thu, 20 Oct 2022 07:53:38 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:39686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olU71-0000va-Ae for qemu-devel@nongnu.org; Thu, 20 Oct 2022 07:53:38 -0400 Received: by mail-pj1-x102a.google.com with SMTP id o17-20020a17090aac1100b0020d98b0c0f4so3198533pjq.4 for ; Thu, 20 Oct 2022 04:53:22 -0700 (PDT) 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=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=oIOEqy8lhREixIlMf4h7ABgBYyrAjtSKZUqccQGwczGS6LRyE+8NB5BDznXvxoCIrA LATMqO3ShRGsamPF/MWdZXa+Hx9RcEKILTZRgXZdklVAUgEQhDu8hnvCfj3rz8ogr4a9 hCBW9veFyunR6TQm7cP+f/FGe8YUDjaVBvZx0uyuH4KKNAfH5wB0qMFOJBeB5VHQWqY4 yOuqR2eubPUocAMIRoF4HVuQtYRvD02n89hfNEHEGL7/Or0+cPAXHRI9nJVM6cg+xqSg kwiutXi0YJIOKzl45rtNXv/zskR1K6oQeUb0ZyaIShmYU1fkEy4putJa2TgGpkML4jLr qd3w== 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=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=kVO0xKPIH6tZASG0VbdespM993n1jzNbl69FUqnNiF6d61D0pMhRJ6+sBKhanwywG5 GysVnKaSjfJlAUC77ZkZKxgI0DFR+avNNbRdHsy4GxWudV0YyprDQa2tY2LilMGXNnuA 7V/K9YuCXzfEBykcT1zNyGJV/m59g3B6ct7XlJnI5Z80RFJxnmZVxWNt3DpayhCxbkCs NBv35n/I0jZ3+CzglW4uOkAjQWuf2a305fqT2S0iIcLA82DMy6Tn2ArjSRWkJguDY+4/ 7FNUtdFhckKkhw3g6E7bLp6pJJx3bA51PfBDv/OJzuWcG4szOxBHA5MK5m/0bfzeHDD7 czVw== X-Gm-Message-State: ACrzQf3O6w0vcR9FYQQNLfjPj3H8C6d4MtCJPAZOJx27oWEfZEkbu/yi nDJW73nIXy2BrG8od7zrpUPFki+XLxgoobFZ X-Received: by 2002:a17:902:c946:b0:183:4bdf:9478 with SMTP id i6-20020a170902c94600b001834bdf9478mr13138450pla.139.1666266801916; Thu, 20 Oct 2022 04:53:21 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id w206-20020a627bd7000000b0056109e15638sm13065464pfc.54.2022.10.20.04.53.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 04:53:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/31] tcg: Tidy tcg_reg_alloc_op Date: Thu, 20 Oct 2022 21:52:12 +1000 Message-Id: <20221020115242.2301066-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020115242.2301066-1-richard.henderson@linaro.org> References: <20221020115242.2301066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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, 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" Replace goto allocate_in_reg with a boolean. Remove o_preferred_regs which isn't used, except to copy. 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 c9e664ee31..660d5eb098 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3606,7 +3606,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]; @@ -3621,9 +3622,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 @@ -3632,30 +3636,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. @@ -3663,7 +3660,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