From patchwork Tue Dec 25 20:55:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 154497 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5220548ljp; Tue, 25 Dec 2018 13:16:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN5944kNTs675WFQHLpYQdl6LsXzaJsyDRI5MDTtYQIbO6QKIeLND2gPjasbAcwImCSvEPAK X-Received: by 2002:a37:8846:: with SMTP id k67mr15963555qkd.214.1545772562148; Tue, 25 Dec 2018 13:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545772562; cv=none; d=google.com; s=arc-20160816; b=b1W3a+gVgg0dhKgLhPusitf53zSKPAOAsfN2Vn3vwhEguY/s6FuPUs/FWQxNOqsNJi mDJ5dhUwehDsqhK5xOEAWfL07HHv4yw/sSVarfcJmX25tiuU/QOWG9K/sbKxSVDaw30d GoiPz8SPXY7rIsYIvK0ZzFrTSadwaImqybRQyORjqmIGZaesUU9v8l8Yrmfd6HNrka47 LHZqKAVzaIiaj9aVb2Rw+E+F1X88B/h4OkUAmLmeuntSOj/i/dgUoDXvCSgDfqkfUGw8 kkrV84RhN15EgK+Lp8e+ZuWNaLuign4vnZzE7d6uA9MSPbhHH1/vQLyX6GbQmHF5MfUM gAqQ== 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=56EjDY6ANEGb+ct0dYN5b/CxMpRlxa3rLozxowxzSls=; b=bD0W0G8Gb4oRmSEgIA7cIGhdGh1nPN0/5rUD6gCw2g30emIilD9m6/ywYq8BSxP83P D0ZzLHyZkJwGOpR72XeZRO+sdmzbLx0aWmeQs/FZvjlQlwsdXrpl4leN+6QQhTpsFxpe LaLi34LHQjnda8QxNEoq+hKleGCvh1gjmJv333QxNbiK3NVAHMc3pzTk33rfU6Jm9dgO uWjD0cKLxh9PGw1GtQeGkLpNgiwHFjRy9kgAinkD/oJitIG69gRpFDXtMuUFfCSUSe7q GHPdML/g4yJrrJ+NTLUS6mLJ8W48hEOt/xFxJGSgv9MNT1u2A5V8FjP0J4iLR5Sc9gpI JkGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MfFKoQj7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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. [208.118.235.17]) by mx.google.com with ESMTPS id 16si611381qve.150.2018.12.25.13.16.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 25 Dec 2018 13:16:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MfFKoQj7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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 ([127.0.0.1]:43196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbu3V-0004MO-Go for patch@linaro.org; Tue, 25 Dec 2018 16:16:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbtnn-0007zk-7M for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:59:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbtnk-0001eq-3A for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:59:47 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:43408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbtnj-0001e8-Tr for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:59:44 -0500 Received: by mail-pg1-x532.google.com with SMTP id v28so6812052pgk.10 for ; Tue, 25 Dec 2018 12:59:43 -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=56EjDY6ANEGb+ct0dYN5b/CxMpRlxa3rLozxowxzSls=; b=MfFKoQj7xWfBFAJAiDOBDJlrgQ6MrJ13rv+H859Es/Cw3PyDgx5IqEe9SBpr7jYXbE wutoYf8NPk7EBvmr4Hfx01m2SVTpIZiIhWB0u+D5CPt02qQjxNqMR/4d53D7S5L3Tl7w 5LBlSBbFskY2Thover4+fuFWrwzyu9eyQEGWE= 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=56EjDY6ANEGb+ct0dYN5b/CxMpRlxa3rLozxowxzSls=; b=nqBNtyLbQbFXXmA3ZxKdPTZd7e+iQxwwWc+o/ObCke+dKXDA+SeNJrrEPDrIA6whdC CLFst1FwLyuGRsPGjEvFKhIz4vuq9KduoL7/wf8lY1eb0XZH1HiAA/Oq48oE3Fn8j4sQ Kn1+NZhzg4EmJcvw8mOMAu88/TnDjoTuVORYPAkS58FzZqJRNCoR/KAWV4ZMjKfwf/wz zBzz+spHGW2thSs0lXeCyBuhbur+iKNqKt9jR5H9AXJlRISR/EmqD+dRLgRs3JQkzKtx 0Yz0iPOcm1W+GE8ECvNDRP98E7kWMPkt0mbcBMN61i/IhHAs8z1iqn/qBmpGBskiN35g Ps3Q== X-Gm-Message-State: AJcUukcbneX2lQj+jIOu8rzdZZntFEc4VmiUY/KEsQVptNeEoweTgefX ExzvSS3albEGcKMPmzlUzA9pQhw8Vdw= X-Received: by 2002:a63:374e:: with SMTP id g14mr16986699pgn.59.1545771582539; Tue, 25 Dec 2018 12:59:42 -0800 (PST) Received: from cloudburst.home (c211-28-135-144.sunsh3.vic.optusnet.com.au. [211.28.135.144]) by smtp.gmail.com with ESMTPSA id t21sm48501628pgg.24.2018.12.25.12.59.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Dec 2018 12:59:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Dec 2018 07:55:22 +1100 Message-Id: <20181225205529.10874-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181225205529.10874-1-richard.henderson@linaro.org> References: <20181225205529.10874-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::532 Subject: [Qemu-devel] [PULL 35/42] 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: peter.maydell@linaro.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. Reviewed-by: Emilio G. Cota 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 32c66dae7d..32bac5e792 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3213,6 +3213,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]; @@ -3223,17 +3225,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 @@ -3241,33 +3244,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 */