From patchwork Thu May 21 19:35:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 475122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9882E140DEE for ; Fri, 22 May 2015 05:36:03 +1000 (AEST) Received: from localhost ([::1]:59247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvWG7-0005nO-Gn for incoming@patchwork.ozlabs.org; Thu, 21 May 2015 15:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvWFe-0005Oz-4M for qemu-devel@nongnu.org; Thu, 21 May 2015 15:35:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvWFd-0006qK-0f for qemu-devel@nongnu.org; Thu, 21 May 2015 15:35:30 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:101::1]:51471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvWFc-0006qE-GN for qemu-devel@nongnu.org; Thu, 21 May 2015 15:35:28 -0400 Received: from weber.rr44.fr ([2001:470:d4ed:0:7e05:7ff:fe0d:f152]) by hall.aurel32.net with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1YvWFa-0006vA-KX; Thu, 21 May 2015 21:35:26 +0200 Received: from aurel32 by weber.rr44.fr with local (Exim 4.85) (envelope-from ) id 1YvWFZ-00040H-Od; Thu, 21 May 2015 21:35:25 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Thu, 21 May 2015 21:35:21 +0200 Message-Id: <1432236921-15267-1-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:bc8:30d7:101::1 Cc: Aurelien Jarno , Richard Henderson Subject: [Qemu-devel] [PATCH v2] tcg: fix dead computation for repeated input arguments 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 When the same temp is used twice or more as an input argument to a TCG instruction, the dead computation code doesn't recognize the second use as a dead temp. This is because the temp is marked as live in the same loop where dead inputs are checked. The fix is to split the loop in two parts. This avoid emitting a move and using a register for the movcond instruction when used as "move if true" on x86-64. This might bring more improvements on RISC TCG targets which don't have outputs aliased to inputs. Cc: Richard Henderson Signed-off-by: Aurelien Jarno Reviewed-by: Richard Henderson --- tcg/tcg.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) v1-v2 1. Apply the same fix for helpers 2. Add comments as suggested by Richard diff --git a/tcg/tcg.c b/tcg/tcg.c index 8b43bbb..3960eba 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1378,16 +1378,20 @@ static void tcg_liveness_analysis(TCGContext *s) memset(dead_temps, 1, s->nb_globals); } - /* input args are live */ + /* record arguments that die in this helper */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { arg = args[i]; if (arg != TCG_CALL_DUMMY_ARG) { if (dead_temps[arg]) { dead_args |= (1 << i); } - dead_temps[arg] = 0; } } + /* input arguments are live for preceeding opcodes */ + for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { + arg = args[i]; + dead_temps[arg] = 0; + } s->op_dead_args[oi] = dead_args; s->op_sync_args[oi] = sync_args; } @@ -1522,12 +1526,16 @@ static void tcg_liveness_analysis(TCGContext *s) memset(mem_temps, 1, s->nb_globals); } - /* input args are live */ + /* record arguments that die in this opcode */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { arg = args[i]; if (dead_temps[arg]) { dead_args |= (1 << i); } + } + /* input arguments are live for preceeding opcodes */ + for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { + arg = args[i]; dead_temps[arg] = 0; } s->op_dead_args[oi] = dead_args;