From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Aurelien Jarno Date: Tue, 17 May 2011 18:28:20 +0200 Message-Id: <1305649700-9078-4-git-send-email-aurelien@aurel32.net> In-Reply-To: <1305649700-9078-1-git-send-email-aurelien@aurel32.net> References: <1305649700-9078-1-git-send-email-aurelien@aurel32.net> Subject: [Qemu-devel] [PATCH 3/3] tcg: don't keep dead outputs in registers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Aurelien Jarno 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; + } } } -- 1.7.2.3