From patchwork Tue May 17 16:28:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 95958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CF7AB100ACA for ; Wed, 18 May 2011 02:28:50 +1000 (EST) Received: from localhost ([::1]:59425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMN8Z-0003Wa-Ja for incoming@patchwork.ozlabs.org; Tue, 17 May 2011 12:28:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMN8F-0003WI-NJ for qemu-devel@nongnu.org; Tue, 17 May 2011 12:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMN8E-0004Yj-PT for qemu-devel@nongnu.org; Tue, 17 May 2011 12:28:27 -0400 Received: from hall.aurel32.net ([88.191.126.93]:51067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMN8E-0004YP-Hs for qemu-devel@nongnu.org; Tue, 17 May 2011 12:28:26 -0400 Received: from [2001:470:d4ed:0:5e26:aff:fe2b:6f5b] (helo=volta.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1QMN8D-0003by-1a; Tue, 17 May 2011 18:28:25 +0200 Received: from aurel32 by volta.aurel32.net with local (Exim 4.72) (envelope-from ) id 1QMN8C-0002u2-19; Tue, 17 May 2011 18:28:24 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Tue, 17 May 2011 18:28:20 +0200 Message-Id: <1305649700-9078-4-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1305649700-9078-1-git-send-email-aurelien@aurel32.net> References: <1305649700-9078-1-git-send-email-aurelien@aurel32.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 88.191.126.93 Cc: Aurelien Jarno Subject: [Qemu-devel] [PATCH 3/3] tcg: don't keep dead outputs in registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If an op with dead outputs is not removed, because it has side effects or has multiple output arguments and only one dead, mark the TCG registers as dead instead of keeping them allocated. This avoid a few register spills on TCG targets with low register count, especially with div2 and mul2 ops, or when a qemu_ld* result is not used (prefetch emulation for example). Signed-off-by: Aurelien Jarno --- tcg/tcg.c | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 82d3e1d..fad92f9 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1782,12 +1782,16 @@ static void tcg_reg_alloc_op(TCGContext *s, if (!ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) s->reg_to_temp[ts->reg] = -1; - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - /* temp value is modified, so the value kept in memory is - potentially not the same */ - ts->mem_coherent = 0; - s->reg_to_temp[reg] = arg; + if (IS_DEAD_ARG(i)) { + ts->val_type = TEMP_VAL_DEAD; + } else { + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + /* temp value is modified, so the value kept in memory is + potentially not the same */ + ts->mem_coherent = 0; + s->reg_to_temp[reg] = arg; + } } oarg_end: new_args[i] = reg; @@ -1981,10 +1985,14 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, } else { if (ts->val_type == TEMP_VAL_REG) s->reg_to_temp[ts->reg] = -1; - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - ts->mem_coherent = 0; - s->reg_to_temp[reg] = arg; + if (IS_DEAD_ARG(i)) { + ts->val_type = TEMP_VAL_DEAD; + } else { + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + ts->mem_coherent = 0; + s->reg_to_temp[reg] = arg; + } } }