From patchwork Tue May 19 10:26:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 473803 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 A257C1400A0 for ; Tue, 19 May 2015 20:27:22 +1000 (AEST) Received: from localhost ([::1]:44870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuek3-0000vc-H9 for incoming@patchwork.ozlabs.org; Tue, 19 May 2015 06:27:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuejo-0000dN-Ho for qemu-devel@nongnu.org; Tue, 19 May 2015 06:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yuejk-0006SH-2I for qemu-devel@nongnu.org; Tue, 19 May 2015 06:27:04 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:101::1]:36373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yuejj-0006Rs-Sc for qemu-devel@nongnu.org; Tue, 19 May 2015 06:26:59 -0400 Received: from 191.red-80-33-14.staticip.rima-tde.net ([80.33.14.191] helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1Yuejh-0008Di-Jt; Tue, 19 May 2015 12:26:57 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.84) (envelope-from ) id 1Yueja-0005E5-9b; Tue, 19 May 2015 12:26:50 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Tue, 19 May 2015 12:26:48 +0200 Message-Id: <1432031208-20020-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] 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 --- tcg/tcg.c | 3 +++ 1 file changed, 3 insertions(+) NB: The dead computation loop for call has the same problem, but it will not improve the generated code as anyway the value has to be copied to a register or memory. I am therefore not sure it is worth fixing it as it might bring some performance penalty. diff --git a/tcg/tcg.c b/tcg/tcg.c index f1558b7..58ca693 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1522,6 +1522,9 @@ static void tcg_liveness_analysis(TCGContext *s) if (dead_temps[arg]) { dead_args |= (1 << i); } + } + for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { + arg = args[i]; dead_temps[arg] = 0; } s->op_dead_args[oi] = dead_args;