From patchwork Wed Nov 28 05:38:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152188 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp690131ljp; Tue, 27 Nov 2018 21:44:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WerYlP+iL9sCP4JCV8MH3o++9xKm89Iq1Lpjl97lOh4g0CHZrxIjr4OxXSBZdVBRlZXkxP X-Received: by 2002:a0d:ea8e:: with SMTP id t136mr33856053ywe.376.1543383898577; Tue, 27 Nov 2018 21:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383898; cv=none; d=google.com; s=arc-20160816; b=SJrJf9SZzgBcSJPXK7WBYzOyvGO6Gs+T43LSXHLSDgebn6EOg29AARuKu8xPoi7HVS xkwUiWEXhBcKDNkB9P9pEKoimf7t6NnNRJrlFQqLZlb92AfVULQYo18T3Viufjip+RHd h31uKgTC6+LcCxdp3I4zJ+DRQztOMHcvXrlZkdcMPQ7S83jfvfJflj4cgGCCpCS/nmh3 3C0sjWUeyciOrY0XEwNQ9gv2j53kddh3d63FwN+nifLDn1+ADMN4xdt1YvoVfkVAYewy RUkw6SiVYOvwif8Lgdn8QAFieL0+JAk/QDuZ3qNXHWqlejxzljU2a7CoalQiFmX3V1J8 witg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=IP0lLIkXSgPKwsDsoLUp8fVauLPqwdeD0c88AkY4Qpw=; b=a9qFsbBRQkrupV3fFf8JCw9DhktG/JNPcr2NCR6Ojcdjp4wtrHy+oaTpkb3Owz+89A XGVTyuWXrnUET5Jbho9DzlWLbqHHR3Cii5Fgu+ADxS581i6qoJZejz1SjMJNFooNkPtJ mSgYi64Q4gimE8HxYIvzrj3ZwKSAVXmoqrDoZQxma0iGJM9fqgrYUhRgUN5GjDsI4Y9i TB9WRwSHG7K1V+LGQ9EbBFVq//eHYlnzWLrt7gJmwzxPEv6BuHBceHCfZxybIeDDmoCa +V2C449sxnpPLOa2vF5pMSqyd7S467ZvtIfBQpC5FF+lHw5vid6VESa4Rdz16tejzVfR 1Yew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ji/hY/kO"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x131si4184527ywd.27.2018.11.27.21.44.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:44:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ji/hY/kO"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsef-0001iN-Q9 for patch@linaro.org; Wed, 28 Nov 2018 00:44:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYl-000414-RY for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYi-0004Mh-ID for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:39467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYg-0004Ka-HA for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: by mail-pf1-x441.google.com with SMTP id c72so9608847pfc.6 for ; Tue, 27 Nov 2018 21:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IP0lLIkXSgPKwsDsoLUp8fVauLPqwdeD0c88AkY4Qpw=; b=ji/hY/kOjrrTE8vBuCS3aTph+n89QXAdvHZzkCdK5zv0vVA8E79VXk1UaCNjWcJTrs 47vJnjv+OPXIEBAY9/sK5NHX+0JwL6B88wUH/t38G/GJUG9P1a+L8svl33ljZdy7ZbCZ 0T1Y96ZxeXeaX58tPrQg+YRq+aP1LEvpSUbw4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IP0lLIkXSgPKwsDsoLUp8fVauLPqwdeD0c88AkY4Qpw=; b=rwI0PhoS6q4MJNIPJ1keFBSnLD5GlRGCKy1kkvmZ/TRG7Tv/cIthGD5/dWe0kTlGgM WXAKn4YrQD5XmuigT3h4fpcJWUaNKPcUIST3Iq/4sEVVi5gqBgDGGr1wwe6T/jtYHNQE NtZZBqTDYK/0GnWzYBLS103afFxnDISJ51iZMgE7MCkXN3g82BM7HT1De+uKQW8jh9ba 31Nd3c02zAnjSaAfRV7qBxIosXzjoquzyMVjxmE0PqPdx2t7NBBXWKw/kf2uT78EbLDM aLTs9rS5HUnzP3VUbvE4RQtSiTRJ2GC3Qt2BaRpzkHuV6HwIvv9bQB+jbx0ksyV8M82a R//Q== X-Gm-Message-State: AA+aEWYs8csB7a1qGFp3f4kw8yN2X174mhwsYlVHuWXdSPMBZLb8V/v8 iwqkzqdfLgDamG5RE+yS7iDPXemdKB4= X-Received: by 2002:a63:88c7:: with SMTP id l190mr31308104pgd.110.1543383523760; Tue, 27 Nov 2018 21:38:43 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:28 -0800 Message-Id: <20181128053834.10861-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 06/12] tcg: Improve register allocation for matching constraints X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Try harder to honor the output_pref. When we're forced to allocate a second register for the input, it does not need to use the input constraint; that will be honored by the register we allocate for the output and a move is already required. Signed-off-by: Richard Henderson --- tcg/tcg.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index f86415ce29..adf6570c36 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3235,6 +3235,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; + i = def->sorted_args[nb_oargs + k]; arg = op->args[i]; arg_ct = &def->args_ct[i]; @@ -3245,17 +3247,18 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* constant is OK for instruction */ const_args[i] = 1; new_args[i] = ts->val; - goto iarg_end; + continue; } - temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, 0); - + i_preferred_regs = o_preferred_regs = 0; if (arg_ct->ct & TCG_CT_IALIAS) { + o_preferred_regs = op->output_pref[arg_ct->alias_index]; if (ts->fixed_reg) { /* if fixed register, we must allocate a new register if the alias is not the same register */ - if (arg != op->args[arg_ct->alias_index]) + if (arg != op->args[arg_ct->alias_index]) { goto allocate_in_reg; + } } else { /* if the input is aliased to an output and if it is not dead after the instruction, we must allocate @@ -3263,33 +3266,42 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) if (!IS_DEAD_ARG(i)) { goto allocate_in_reg; } + /* check if the current register has already been allocated for another input aliased to an output */ - int k2, i2; - for (k2 = 0 ; k2 < k ; k2++) { - i2 = def->sorted_args[nb_oargs + k2]; - if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && - (new_args[i2] == ts->reg)) { - goto allocate_in_reg; + if (ts->val_type == TEMP_VAL_REG) { + int k2, i2; + reg = ts->reg; + for (k2 = 0 ; k2 < k ; k2++) { + i2 = def->sorted_args[nb_oargs + k2]; + if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && + reg == new_args[i2]) { + goto allocate_in_reg; + } } } + i_preferred_regs = o_preferred_regs; } } + + temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, i_preferred_regs); reg = ts->reg; + if (tcg_regset_test_reg(arg_ct->u.regs, reg)) { /* nothing to do : the constraint is satisfied */ } else { allocate_in_reg: /* allocate a new register matching the constraint and move the temporary register into it */ + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, - 0, ts->indirect_base); + o_preferred_regs, ts->indirect_base); tcg_out_mov(s, ts->type, reg, ts->reg); } new_args[i] = reg; const_args[i] = 0; tcg_regset_set_reg(i_allocated_regs, reg); - iarg_end: ; } /* mark dead temporaries and free the associated registers */